From 33f3fa6865253fd676cb13da47cefc2ba95509d3 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 14 Sep 2021 23:01:29 +0200 Subject: [PATCH] Mesh: define the typenames FacetIndex and PointIndex to distinguish between facet and point related indexes --- src/Mod/Mesh/App/Core/Algorithm.cpp | 494 +++++++---------- src/Mod/Mesh/App/Core/Algorithm.h | 168 +++--- src/Mod/Mesh/App/Core/Approximation.cpp | 6 +- src/Mod/Mesh/App/Core/Approximation.h | 4 +- src/Mod/Mesh/App/Core/Builder.cpp | 18 +- src/Mod/Mesh/App/Core/Builder.h | 10 +- src/Mod/Mesh/App/Core/Curvature.cpp | 22 +- src/Mod/Mesh/App/Core/Curvature.h | 7 +- src/Mod/Mesh/App/Core/Definitions.cpp | 2 +- src/Mod/Mesh/App/Core/Definitions.h | 14 +- src/Mod/Mesh/App/Core/Degeneration.cpp | 280 ++++------ src/Mod/Mesh/App/Core/Degeneration.h | 42 +- src/Mod/Mesh/App/Core/Elements.cpp | 30 +- src/Mod/Mesh/App/Core/Elements.h | 160 +++--- src/Mod/Mesh/App/Core/Evaluation.cpp | 149 +++--- src/Mod/Mesh/App/Core/Evaluation.h | 66 +-- src/Mod/Mesh/App/Core/Grid.cpp | 76 +-- src/Mod/Mesh/App/Core/Grid.h | 116 ++-- src/Mod/Mesh/App/Core/Helpers.h | 69 +-- src/Mod/Mesh/App/Core/Info.cpp | 16 +- src/Mod/Mesh/App/Core/Info.h | 4 +- src/Mod/Mesh/App/Core/Iterator.h | 100 ++-- src/Mod/Mesh/App/Core/KDTree.cpp | 36 +- src/Mod/Mesh/App/Core/KDTree.h | 8 +- src/Mod/Mesh/App/Core/MeshIO.cpp | 25 +- src/Mod/Mesh/App/Core/MeshIO.h | 2 +- src/Mod/Mesh/App/Core/MeshKernel.cpp | 202 ++++--- src/Mod/Mesh/App/Core/MeshKernel.h | 98 ++-- src/Mod/Mesh/App/Core/Projection.cpp | 9 +- src/Mod/Mesh/App/Core/Projection.h | 5 +- src/Mod/Mesh/App/Core/Segmentation.cpp | 34 +- src/Mod/Mesh/App/Core/Segmentation.h | 24 +- src/Mod/Mesh/App/Core/SetOperations.cpp | 32 +- src/Mod/Mesh/App/Core/SetOperations.h | 16 +- src/Mod/Mesh/App/Core/Smoothing.cpp | 38 +- src/Mod/Mesh/App/Core/Smoothing.h | 11 +- src/Mod/Mesh/App/Core/Tools.cpp | 50 +- src/Mod/Mesh/App/Core/Tools.h | 29 +- src/Mod/Mesh/App/Core/TopoAlgorithm.cpp | 498 +++++++++--------- src/Mod/Mesh/App/Core/TopoAlgorithm.h | 82 +-- src/Mod/Mesh/App/Core/Triangulation.cpp | 44 +- src/Mod/Mesh/App/Core/Triangulation.h | 10 +- src/Mod/Mesh/App/Core/Trim.cpp | 34 +- src/Mod/Mesh/App/Core/Trim.h | 14 +- src/Mod/Mesh/App/Core/TrimByPlane.cpp | 6 +- src/Mod/Mesh/App/Core/TrimByPlane.h | 4 +- src/Mod/Mesh/App/Core/Visitor.cpp | 44 +- src/Mod/Mesh/App/Core/Visitor.h | 36 +- src/Mod/Mesh/App/Exporter.cpp | 8 +- src/Mod/Mesh/App/Facet.cpp | 4 +- src/Mod/Mesh/App/Facet.h | 10 +- src/Mod/Mesh/App/FacetPyImp.cpp | 42 +- src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp | 22 +- src/Mod/Mesh/App/FeatureMeshSegmentByMesh.h | 2 +- src/Mod/Mesh/App/Mesh.cpp | 206 ++++---- src/Mod/Mesh/App/Mesh.h | 90 ++-- src/Mod/Mesh/App/MeshProperties.cpp | 4 +- src/Mod/Mesh/App/MeshProperties.h | 2 +- src/Mod/Mesh/App/MeshPyImp.cpp | 36 +- src/Mod/Mesh/App/MeshTexture.cpp | 22 +- src/Mod/Mesh/App/MeshTexture.h | 2 +- src/Mod/Mesh/App/Segment.cpp | 18 +- src/Mod/Mesh/App/Segment.h | 15 +- src/Mod/Mesh/App/Types.h | 40 ++ src/Mod/Mesh/Gui/Command.cpp | 2 +- src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp | 30 +- src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h | 3 +- src/Mod/Mesh/Gui/DlgSmoothing.cpp | 6 +- src/Mod/Mesh/Gui/MeshEditor.cpp | 34 +- src/Mod/Mesh/Gui/MeshEditor.h | 14 +- src/Mod/Mesh/Gui/MeshSelection.cpp | 40 +- src/Mod/Mesh/Gui/SegmentationBestFit.cpp | 2 +- src/Mod/Mesh/Gui/SoFCMeshObject.cpp | 32 +- src/Mod/Mesh/Gui/ViewProvider.cpp | 122 ++--- src/Mod/Mesh/Gui/ViewProvider.h | 32 +- src/Mod/Mesh/Gui/ViewProviderCurvature.cpp | 2 +- src/Mod/Mesh/Gui/ViewProviderDefects.cpp | 76 +-- src/Mod/Mesh/Gui/ViewProviderDefects.h | 20 +- src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp | 6 +- src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp | 12 +- .../Gui/ViewProviderTransformDemolding.cpp | 2 +- src/Mod/MeshPart/App/AppMeshPartPy.cpp | 2 +- src/Mod/MeshPart/App/CurveProjector.cpp | 66 +-- src/Mod/MeshPart/App/CurveProjector.h | 8 +- src/Mod/MeshPart/App/MeshAlgos.cpp | 6 +- src/Mod/MeshPart/App/Mesher.cpp | 6 +- src/Mod/MeshPart/Gui/CurveOnMesh.cpp | 2 +- .../App/SurfaceTriangulation.cpp | 4 +- src/Mod/ReverseEngineering/Gui/Command.cpp | 6 +- .../ReverseEngineering/Gui/Segmentation.cpp | 4 +- .../Gui/SegmentationManual.cpp | 5 +- 91 files changed, 2057 insertions(+), 2254 deletions(-) create mode 100644 src/Mod/Mesh/App/Types.h diff --git a/src/Mod/Mesh/App/Core/Algorithm.cpp b/src/Mod/Mesh/App/Core/Algorithm.cpp index bc58c6e6cf..d18cbb229e 100644 --- a/src/Mod/Mesh/App/Core/Algorithm.cpp +++ b/src/Mod/Mesh/App/Core/Algorithm.cpp @@ -47,7 +47,8 @@ bool MeshAlgorithm::IsVertexVisible (const Base::Vector3f &rcVertex, const Base: { Base::Vector3f cDirection = rcVertex - rcView; float fDistance = cDirection.Length(); - Base::Vector3f cIntsct; unsigned long uInd; + Base::Vector3f cIntsct; + FacetIndex uInd; // search for the nearest facet to rcView in direction to rcVertex if (NearestFacetOnRay(rcView, cDirection, /*1.2f*fDistance,*/ rclGrid, cIntsct, uInd)) { @@ -66,11 +67,11 @@ bool MeshAlgorithm::IsVertexVisible (const Base::Vector3f &rcVertex, const Base: } bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, Base::Vector3f &rclRes, - unsigned long &rulFacet) const + FacetIndex &rulFacet) const { Base::Vector3f clProj, clRes; bool bSol = false; - unsigned long ulInd = 0; + FacetIndex ulInd = 0; // langsame Ausfuehrung ohne Grid MeshFacetIterator clFIter(_rclMesh); @@ -99,9 +100,9 @@ bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base:: } bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const MeshFacetGrid &rclGrid, - Base::Vector3f &rclRes, unsigned long &rulFacet) const + Base::Vector3f &rclRes, FacetIndex &rulFacet) const { - std::vector aulFacets; + std::vector aulFacets; MeshGridIterator clGridIter(rclGrid); if (clGridIter.InitOnRay(rclPt, rclDir, aulFacets) == true) { @@ -120,9 +121,9 @@ bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base:: } bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea, - const MeshFacetGrid &rclGrid, Base::Vector3f &rclRes, unsigned long &rulFacet) const + const MeshFacetGrid &rclGrid, Base::Vector3f &rclRes, FacetIndex &rulFacet) const { - std::vector aulFacets; + std::vector aulFacets; MeshGridIterator clGridIter(rclGrid); if (clGridIter.InitOnRay(rclPt, rclDir, fMaxSearchArea, aulFacets) == true) { @@ -140,14 +141,14 @@ bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base:: return false; } -bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, - Base::Vector3f &rclRes, unsigned long &rulFacet) const +bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, + Base::Vector3f &rclRes, FacetIndex &rulFacet) const { Base::Vector3f clProj, clRes; bool bSol = false; - unsigned long ulInd = 0; + FacetIndex ulInd = 0; - for (std::vector::const_iterator pI = raulFacets.begin(); pI != raulFacets.end(); ++pI) { + for (std::vector::const_iterator pI = raulFacets.begin(); pI != raulFacets.end(); ++pI) { MeshGeomFacet rclSFacet = _rclMesh.GetFacet(*pI); if (rclSFacet.Foraminate(rclPt, rclDir, clRes) == true) { if (bSol == false) {// erste Loesung @@ -172,14 +173,14 @@ bool MeshAlgorithm::NearestFacetOnRay (const Base::Vector3f &rclPt, const Base:: return bSol; } -bool MeshAlgorithm::RayNearestField (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, - Base::Vector3f &rclRes, unsigned long &rulFacet, float /*fMaxAngle*/) const +bool MeshAlgorithm::RayNearestField (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, + Base::Vector3f &rclRes, FacetIndex &rulFacet, float /*fMaxAngle*/) const { Base::Vector3f clProj, clRes; bool bSol = false; - unsigned long ulInd = 0; + FacetIndex ulInd = 0; - for (std::vector::const_iterator pF = raulFacets.begin(); pF != raulFacets.end(); ++pF) { + for (std::vector::const_iterator pF = raulFacets.begin(); pF != raulFacets.end(); ++pF) { if (_rclMesh.GetFacet(*pF).Foraminate(rclPt, rclDir, clRes/*, fMaxAngle*/) == true) { if (bSol == false) { // erste Loesung bSol = true; @@ -203,18 +204,18 @@ bool MeshAlgorithm::RayNearestField (const Base::Vector3f &rclPt, const Base::Ve return bSol; } -bool MeshAlgorithm::FirstFacetToVertex(const Base::Vector3f &rPt, float fMaxDistance, const MeshFacetGrid &rGrid, unsigned long &uIndex) const +bool MeshAlgorithm::FirstFacetToVertex(const Base::Vector3f &rPt, float fMaxDistance, const MeshFacetGrid &rGrid, FacetIndex &uIndex) const { const float fEps = 0.001f; bool found = false; - std::vector facets; + std::vector facets; // get the facets of the grid the point lies into rGrid.GetElements(rPt, facets); // Check all facets inside the grid if the point is part of it - for (std::vector::iterator it = facets.begin(); it != facets.end(); ++it) { + for (std::vector::iterator it = facets.begin(); it != facets.end(); ++it) { MeshGeomFacet cFacet = this->_rclMesh.GetFacet(*it); if (cFacet.IsPointOfFace(rPt, fMaxDistance)) { found = true; @@ -289,153 +290,60 @@ Base::Vector3f MeshAlgorithm::GetGravityPoint() const void MeshAlgorithm::GetMeshBorders (std::list > &rclBorders) const { - std::vector aulAllFacets(_rclMesh.CountFacets()); - unsigned long k = 0; - for (std::vector::iterator pI = aulAllFacets.begin(); pI != aulAllFacets.end(); ++pI) + std::vector aulAllFacets(_rclMesh.CountFacets()); + FacetIndex k = 0; + for (std::vector::iterator pI = aulAllFacets.begin(); pI != aulAllFacets.end(); ++pI) *pI = k++; GetFacetBorders(aulAllFacets, rclBorders); } -void MeshAlgorithm::GetMeshBorders (std::list > &rclBorders) const +void MeshAlgorithm::GetMeshBorders (std::list > &rclBorders) const { - std::vector aulAllFacets(_rclMesh.CountFacets()); - unsigned long k = 0; - for (std::vector::iterator pI = aulAllFacets.begin(); pI != aulAllFacets.end(); ++pI) + std::vector aulAllFacets(_rclMesh.CountFacets()); + FacetIndex k = 0; + for (std::vector::iterator pI = aulAllFacets.begin(); pI != aulAllFacets.end(); ++pI) *pI = k++; GetFacetBorders(aulAllFacets, rclBorders, true); } -void MeshAlgorithm::GetFacetBorders (const std::vector &raulInd, std::list > &rclBorders) const +void MeshAlgorithm::GetFacetBorders (const std::vector &raulInd, std::list > &rclBorders) const { -#if 1 const MeshPointArray &rclPAry = _rclMesh._aclPointArray; - std::list > aulBorders; + std::list > aulBorders; GetFacetBorders (raulInd, aulBorders, true); - for ( std::list >::iterator it = aulBorders.begin(); it != aulBorders.end(); ++it ) + for ( std::list >::iterator it = aulBorders.begin(); it != aulBorders.end(); ++it ) { std::vector boundary; boundary.reserve( it->size() ); - for ( std::vector::iterator jt = it->begin(); jt != it->end(); ++jt ) + for ( std::vector::iterator jt = it->begin(); jt != it->end(); ++jt ) boundary.push_back(rclPAry[*jt]); rclBorders.push_back( boundary ); } - -#else - const MeshFacetArray &rclFAry = _rclMesh._aclFacetArray; - - // alle Facets markieren die in der Indizie-Liste vorkommen - ResetFacetFlag(MeshFacet::VISIT); - for (std::vector::const_iterator pIter = raulInd.begin(); pIter != raulInd.end(); ++pIter) - rclFAry[*pIter].SetFlag(MeshFacet::VISIT); - - std::list > aclEdges; - // alle Randkanten suchen und ablegen (unsortiert) - for (std::vector::const_iterator pIter2 = raulInd.begin(); pIter2 != raulInd.end(); ++pIter2) - { - const MeshFacet &rclFacet = rclFAry[*pIter2]; - for (int i = 0; i < 3; i++) - { - unsigned long ulNB = rclFacet._aulNeighbours[i]; - if (ulNB != ULONG_MAX) - { - if (rclFAry[ulNB].IsFlag(MeshFacet::VISIT) == true) - continue; - } - - aclEdges.push_back(rclFacet.GetEdge(i)); - } - } - - if (aclEdges.size() == 0) - return; // no borders found (=> solid) - - // Kanten aus der unsortieren Kantenliste suchen - const MeshPointArray &rclPAry = _rclMesh._aclPointArray; - unsigned long ulFirst, ulLast; - std::list clBorder; - ulFirst = aclEdges.begin()->first; - ulLast = aclEdges.begin()->second; - - aclEdges.erase(aclEdges.begin()); - clBorder.push_back(rclPAry[ulFirst]); - clBorder.push_back(rclPAry[ulLast]); - - while (aclEdges.size() > 0) - { - // naechste anliegende Kante suchen - std::list >::iterator pEI; - for (pEI = aclEdges.begin(); pEI != aclEdges.end(); ++pEI) - { - if (pEI->first == ulLast) - { - ulLast = pEI->second; - clBorder.push_back(rclPAry[ulLast]); - aclEdges.erase(pEI); - break; - } - else if (pEI->second == ulLast) - { - ulLast = pEI->first; - clBorder.push_back(rclPAry[ulLast]); - aclEdges.erase(pEI); - break; - } - else if (pEI->first == ulFirst) - { - ulFirst = pEI->second; - clBorder.push_front(rclPAry[ulFirst]); - aclEdges.erase(pEI); - break; - } - else if (pEI->second == ulFirst) - { - ulFirst = pEI->first; - clBorder.push_front(rclPAry[ulFirst]); - aclEdges.erase(pEI); - break; - } - } - if ((pEI == aclEdges.end()) || (ulLast == ulFirst)) - { // keine weitere Kante gefunden bzw. Polylinie geschlossen - rclBorders.push_back(std::vector(clBorder.begin(), clBorder.end())); - clBorder.clear(); - - if (aclEdges.size() > 0) - { // neue Border anfangen - ulFirst = aclEdges.begin()->first; - ulLast = aclEdges.begin()->second; - aclEdges.erase(aclEdges.begin()); - clBorder.push_back(rclPAry[ulFirst]); - clBorder.push_back(rclPAry[ulLast]); - } - } - } -#endif } -void MeshAlgorithm::GetFacetBorders (const std::vector &raulInd, - std::list > &rclBorders, +void MeshAlgorithm::GetFacetBorders (const std::vector &raulInd, + std::list > &rclBorders, bool ignoreOrientation) const { const MeshFacetArray &rclFAry = _rclMesh._aclFacetArray; // mark all facets that are in the indices list ResetFacetFlag(MeshFacet::VISIT); - for (std::vector::const_iterator it = raulInd.begin(); it != raulInd.end(); ++it) + for (std::vector::const_iterator it = raulInd.begin(); it != raulInd.end(); ++it) rclFAry[*it].SetFlag(MeshFacet::VISIT); // collect all boundary edges (unsorted) - std::list > aclEdges; - for (std::vector::const_iterator it = raulInd.begin(); it != raulInd.end(); ++it) { + std::list > aclEdges; + for (std::vector::const_iterator it = raulInd.begin(); it != raulInd.end(); ++it) { const MeshFacet &rclFacet = rclFAry[*it]; for (unsigned short i = 0; i < 3; i++) { - unsigned long ulNB = rclFacet._aulNeighbours[i]; - if (ulNB != ULONG_MAX) { + FacetIndex ulNB = rclFacet._aulNeighbours[i]; + if (ulNB != FACET_INDEX_MAX) { if (rclFAry[ulNB].IsFlag(MeshFacet::VISIT) == true) continue; } @@ -448,8 +356,8 @@ void MeshAlgorithm::GetFacetBorders (const std::vector &raulInd, return; // no borders found (=> solid) // search for edges in the unsorted list - unsigned long ulFirst, ulLast; - std::list clBorder; + PointIndex ulFirst, ulLast; + std::list clBorder; ulFirst = aclEdges.begin()->first; ulLast = aclEdges.begin()->second; @@ -459,7 +367,7 @@ void MeshAlgorithm::GetFacetBorders (const std::vector &raulInd, while (aclEdges.size() > 0) { // get adjacent edge - std::list >::iterator pEI; + std::list >::iterator pEI; for (pEI = aclEdges.begin(); pEI != aclEdges.end(); ++pEI) { if (pEI->first == ulLast) { ulLast = pEI->second; @@ -513,17 +421,17 @@ void MeshAlgorithm::GetFacetBorders (const std::vector &raulInd, } } -void MeshAlgorithm::GetMeshBorder(unsigned long uFacet, std::list& rBorder) const +void MeshAlgorithm::GetMeshBorder(FacetIndex uFacet, std::list& rBorder) const { const MeshFacetArray &rFAry = _rclMesh._aclFacetArray; - std::list > openEdges; + std::list > openEdges; if (uFacet >= rFAry.size()) return; // add the open edge to the beginning of the list MeshFacetArray::_TConstIterator face = rFAry.begin() + uFacet; for (unsigned short i = 0; i < 3; i++) { - if (face->_aulNeighbours[i] == ULONG_MAX) + if (face->_aulNeighbours[i] == FACET_INDEX_MAX) openEdges.push_back(face->GetEdge(i)); } @@ -536,14 +444,14 @@ void MeshAlgorithm::GetMeshBorder(unsigned long uFacet, std::list continue; for (unsigned short i = 0; i < 3; i++) { - if (it->_aulNeighbours[i] == ULONG_MAX) + if (it->_aulNeighbours[i] == FACET_INDEX_MAX) openEdges.push_back(it->GetEdge(i)); } } // Start with the edge that is associated to uFacet - unsigned long ulFirst = openEdges.begin()->first; - unsigned long ulLast = openEdges.begin()->second; + PointIndex ulFirst = openEdges.begin()->first; + PointIndex ulLast = openEdges.begin()->second; openEdges.erase(openEdges.begin()); rBorder.push_back(ulFirst); @@ -552,7 +460,7 @@ void MeshAlgorithm::GetMeshBorder(unsigned long uFacet, std::list while (ulLast != ulFirst) { // find adjacent edge - std::list >::iterator pEI; + std::list >::iterator pEI; for (pEI = openEdges.begin(); pEI != openEdges.end(); ++pEI) { if (pEI->first == ulLast) @@ -579,14 +487,14 @@ void MeshAlgorithm::GetMeshBorder(unsigned long uFacet, std::list } } -void MeshAlgorithm::SplitBoundaryLoops( std::list >& aBorders ) +void MeshAlgorithm::SplitBoundaryLoops( std::list >& aBorders ) { // Count the number of open edges for each point - std::map openPointDegree; + std::map openPointDegree; for (MeshFacetArray::_TConstIterator jt = _rclMesh._aclFacetArray.begin(); jt != _rclMesh._aclFacetArray.end(); ++jt) { for (int i=0; i<3; i++) { - if (jt->_aulNeighbours[i] == ULONG_MAX) { + if (jt->_aulNeighbours[i] == FACET_INDEX_MAX) { openPointDegree[jt->_aulPoints[i]]++; openPointDegree[jt->_aulPoints[(i+1)%3]]++; } @@ -594,11 +502,11 @@ void MeshAlgorithm::SplitBoundaryLoops( std::list >& } // go through all boundaries and split them if needed - std::list > aSplitBorders; - for (std::list >::iterator it = aBorders.begin(); + std::list > aSplitBorders; + for (std::list >::iterator it = aBorders.begin(); it != aBorders.end(); ++it) { bool split=false; - for (std::vector::iterator jt = it->begin(); jt != it->end(); ++jt) { + for (std::vector::iterator jt = it->begin(); jt != it->end(); ++jt) { // two (or more) boundaries meet in one non-manifold point if (openPointDegree[*jt] > 2) { split = true; @@ -615,17 +523,17 @@ void MeshAlgorithm::SplitBoundaryLoops( std::list >& aBorders = aSplitBorders; } -void MeshAlgorithm::SplitBoundaryLoops(const std::vector& rBound, - std::list >& aBorders) +void MeshAlgorithm::SplitBoundaryLoops(const std::vector& rBound, + std::list >& aBorders) { - std::map aPtDegree; - std::vector cBound; - for (std::vector::const_iterator it = rBound.begin(); it != rBound.end(); ++it) { + std::map aPtDegree; + std::vector cBound; + for (std::vector::const_iterator it = rBound.begin(); it != rBound.end(); ++it) { int deg = (aPtDegree[*it]++); if (deg > 0) { - for (std::vector::iterator jt = cBound.begin(); jt != cBound.end(); ++jt) { + for (std::vector::iterator jt = cBound.begin(); jt != cBound.end(); ++jt) { if (*jt == *it) { - std::vector cBoundLoop; + std::vector cBoundLoop; cBoundLoop.insert(cBoundLoop.end(), jt, cBound.end()); cBoundLoop.push_back(*it); cBound.erase(jt, cBound.end()); @@ -640,7 +548,7 @@ void MeshAlgorithm::SplitBoundaryLoops(const std::vector& rBound, } } -bool MeshAlgorithm::FillupHole(const std::vector& boundary, +bool MeshAlgorithm::FillupHole(const std::vector& boundary, AbstractPolygonTriangulator& cTria, MeshFacetArray& rFaces, MeshPointArray& rPoints, int level, const MeshRefPointToFacets* pP2FStructure) const @@ -657,14 +565,14 @@ bool MeshAlgorithm::FillupHole(const std::vector& boundary, // Get a facet as reference coordinate system MeshGeomFacet rTriangle; MeshFacet rFace; - unsigned long refPoint0 = *(boundary.begin()); - unsigned long refPoint1 = *(boundary.begin()+1); + PointIndex refPoint0 = *(boundary.begin()); + PointIndex refPoint1 = *(boundary.begin()+1); if (pP2FStructure) { - const std::set& ring1 = (*pP2FStructure)[refPoint0]; - const std::set& ring2 = (*pP2FStructure)[refPoint1]; - std::vector f_int; + const std::set& ring1 = (*pP2FStructure)[refPoint0]; + const std::set& ring2 = (*pP2FStructure)[refPoint1]; + std::vector f_int; std::set_intersection(ring1.begin(), ring1.end(), ring2.begin(), ring2.end(), - std::back_insert_iterator >(f_int)); + std::back_insert_iterator >(f_int)); if (f_int.size() != 1) return false; // error, this must be an open edge! @@ -691,13 +599,13 @@ bool MeshAlgorithm::FillupHole(const std::vector& boundary, // add points to the polygon std::vector polygon; - for (std::vector::const_iterator jt = boundary.begin(); jt != boundary.end(); ++jt) { + for (std::vector::const_iterator jt = boundary.begin(); jt != boundary.end(); ++jt) { polygon.push_back(_rclMesh._aclPointArray[*jt]); rPoints.push_back(_rclMesh._aclPointArray[*jt]); } // remove the last added point if it is duplicated - std::vector bounds = boundary; + std::vector bounds = boundary; if (boundary.front() == boundary.back()) { bounds.pop_back(); polygon.pop_back(); @@ -712,8 +620,8 @@ bool MeshAlgorithm::FillupHole(const std::vector& boundary, std::vector surf_pts = cTria.GetPolygon(); if (pP2FStructure && level > 0) { - std::set index = pP2FStructure->NeighbourPoints(boundary, level); - for (std::set::iterator it = index.begin(); it != index.end(); ++it) { + std::set index = pP2FStructure->NeighbourPoints(boundary, level); + for (std::set::iterator it = index.begin(); it != index.end(); ++it) { Base::Vector3f pt(_rclMesh._aclPointArray[*it]); surf_pts.push_back(pt); } @@ -816,28 +724,28 @@ bool MeshAlgorithm::FillupHole(const std::vector& boundary, return false; } -void MeshAlgorithm::SetFacetsProperty(const std::vector &raulInds, const std::vector &raulProps) const +void MeshAlgorithm::SetFacetsProperty(const std::vector &raulInds, const std::vector &raulProps) const { if (raulInds.size() != raulProps.size()) return; std::vector::const_iterator iP = raulProps.begin(); - for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i, ++iP) + for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i, ++iP) _rclMesh._aclFacetArray[*i].SetProperty(*iP); } -void MeshAlgorithm::SetFacetsFlag (const std::vector &raulInds, MeshFacet::TFlagType tF) const +void MeshAlgorithm::SetFacetsFlag (const std::vector &raulInds, MeshFacet::TFlagType tF) const { - for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i) + for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i) _rclMesh._aclFacetArray[*i].SetFlag(tF); } -void MeshAlgorithm::SetPointsFlag (const std::vector &raulInds, MeshPoint::TFlagType tF) const +void MeshAlgorithm::SetPointsFlag (const std::vector &raulInds, MeshPoint::TFlagType tF) const { - for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i) + for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i) _rclMesh._aclPointArray[*i].SetFlag(tF); } -void MeshAlgorithm::GetFacetsFlag (std::vector &raulInds, MeshFacet::TFlagType tF) const +void MeshAlgorithm::GetFacetsFlag (std::vector &raulInds, MeshFacet::TFlagType tF) const { raulInds.reserve(raulInds.size() + CountFacetFlag(tF)); MeshFacetArray::_TConstIterator beg = _rclMesh._aclFacetArray.begin(); @@ -848,7 +756,7 @@ void MeshAlgorithm::GetFacetsFlag (std::vector &raulInds, MeshFac } } -void MeshAlgorithm::GetPointsFlag (std::vector &raulInds, MeshPoint::TFlagType tF) const +void MeshAlgorithm::GetPointsFlag (std::vector &raulInds, MeshPoint::TFlagType tF) const { raulInds.reserve(raulInds.size() + CountPointFlag(tF)); MeshPointArray::_TConstIterator beg = _rclMesh._aclPointArray.begin(); @@ -859,15 +767,15 @@ void MeshAlgorithm::GetPointsFlag (std::vector &raulInds, MeshPoi } } -void MeshAlgorithm::ResetFacetsFlag (const std::vector &raulInds, MeshFacet::TFlagType tF) const +void MeshAlgorithm::ResetFacetsFlag (const std::vector &raulInds, MeshFacet::TFlagType tF) const { - for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i) + for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i) _rclMesh._aclFacetArray[*i].ResetFlag(tF); } -void MeshAlgorithm::ResetPointsFlag (const std::vector &raulInds, MeshPoint::TFlagType tF) const +void MeshAlgorithm::ResetPointsFlag (const std::vector &raulInds, MeshPoint::TFlagType tF) const { - for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i) + for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i) _rclMesh._aclPointArray[*i].ResetFlag(tF); } @@ -905,7 +813,7 @@ unsigned long MeshAlgorithm::CountPointFlag (MeshPoint::TFlagType tF) const [flag, tF](const MeshPoint& f) { return flag(f, tF);}); } -void MeshAlgorithm::GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, std::vector &raclCutted ) const +void MeshAlgorithm::GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, std::vector &raclCutted ) const { MeshFacetIterator cFIt(_rclMesh); MeshFacetIterator cTIt(rToolMesh); @@ -948,7 +856,7 @@ void MeshAlgorithm::GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Ba } void MeshAlgorithm::GetFacetsFromToolMesh(const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, - const MeshFacetGrid& rGrid, std::vector &raclCutted) const + const MeshFacetGrid& rGrid, std::vector &raclCutted) const { // iterator over grid structure MeshGridIterator clGridIter(rGrid); @@ -966,7 +874,7 @@ void MeshAlgorithm::GetFacetsFromToolMesh(const MeshKernel& rToolMesh, const Bas // box is inside the toolmesh all facets are stored with no further tests because they must // also lie inside the toolmesh. Finally, if the grid box intersects with the toolmesh we must // also check for each whether it intersects with the toolmesh as well. - std::vector aulInds; + std::vector aulInds; for (clGridIter.Init(); clGridIter.More(); clGridIter.Next()) { int ret = cToolAlg.Surround(clGridIter.GetBoundBox(), rcDir); @@ -997,7 +905,7 @@ void MeshAlgorithm::GetFacetsFromToolMesh(const MeshKernel& rToolMesh, const Bas Base::SequencerLauncher seq("Check facets...", aulInds.size()); // check all facets - for (std::vector::iterator it = aulInds.begin(); it != aulInds.end(); ++it) { + for (std::vector::iterator it = aulInds.begin(); it != aulInds.end(); ++it) { cFIt.Set(*it); // check each point of each facet @@ -1104,9 +1012,9 @@ int MeshAlgorithm::Surround(const Base::BoundBox3f& rBox, const Base::Vector3f& } void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly, - bool bInner, std::vector &raulFacets) const + bool bInner, std::vector &raulFacets) const { - std::vector::iterator it; + std::vector::iterator it; MeshFacetIterator clIter(_rclMesh, 0); Base::Vector3f clPt2d; Base::Vector3f clGravityOfFacet; @@ -1120,7 +1028,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr if (bInner) { BoundBox3f clBBox3d; BoundBox2d clViewBBox; - std::vector aulAllElements; + std::vector aulAllElements; // iterator for the bounding box grids MeshGridIterator clGridIter(rclGrid); for (clGridIter.Init(); clGridIter.More(); clGridIter.Next()) { @@ -1183,7 +1091,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr } void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly, - bool bInner, std::vector &raulFacets) const + bool bInner, std::vector &raulFacets) const { const MeshPointArray& p = _rclMesh.GetPoints(); const MeshFacetArray& f = _rclMesh.GetFacets(); @@ -1193,7 +1101,7 @@ void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base: // Precompute the screen projection matrix as Coin's projection function is expensive Base::ViewProjMatrix fixedProj(pclProj->getComposedProjectionMatrix()); - unsigned long index=0; + FacetIndex index=0; for (MeshFacetArray::_TConstIterator it = f.begin(); it != f.end(); ++it,++index) { for (int i = 0; i < 3; i++) { pt2d = fixedProj(p[it->_aulPoints[i]]); @@ -1208,7 +1116,7 @@ void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base: } } -float MeshAlgorithm::Surface (void) const +float MeshAlgorithm::Surface () const { float fTotal = 0.0f; MeshFacetIterator clFIter(_rclMesh); @@ -1250,13 +1158,13 @@ void MeshAlgorithm::SubSampleByCount (unsigned long ulCtPoints, std::vector &rclPolyline, float fRadius, - const MeshFacetGrid& rclGrid, std::vector &rclResultFacetsIndices) const + const MeshFacetGrid& rclGrid, std::vector &rclResultFacetsIndices) const { rclResultFacetsIndices.clear(); if ( rclPolyline.size() < 3 ) return; // no polygon defined - std::set aclFacets; + std::set aclFacets; for (std::vector::const_iterator pV = rclPolyline.begin(); pV < (rclPolyline.end() - 1); ++pV) { const Base::Vector3f &rclP0 = *pV, &rclP1 = *(pV + 1); @@ -1266,7 +1174,7 @@ void MeshAlgorithm::SearchFacetsFromPolyline (const std::vector clSegmBB.Add(rclP1); clSegmBB.Enlarge(fRadius); // BB um Suchradius vergroessern - std::vector aclBBFacets; + std::vector aclBBFacets; unsigned long k = rclGrid.Inside(clSegmBB, aclBBFacets, false); for (unsigned long i = 0; i < k; i++) { @@ -1278,17 +1186,17 @@ void MeshAlgorithm::SearchFacetsFromPolyline (const std::vector rclResultFacetsIndices.insert(rclResultFacetsIndices.begin(), aclFacets.begin(), aclFacets.end()); } -void MeshAlgorithm::CutBorderFacets (std::vector &raclFacetIndices, unsigned short usLevel) const +void MeshAlgorithm::CutBorderFacets (std::vector &raclFacetIndices, unsigned short usLevel) const { - std::vector aclToDelete; + std::vector aclToDelete; CheckBorderFacets(raclFacetIndices, aclToDelete, usLevel); // alle gefunden "Rand"-Facetsindizes" aus dem Array loeschen - std::vector aclResult; - std::set aclTmp(aclToDelete.begin(), aclToDelete.end()); + std::vector aclResult; + std::set aclTmp(aclToDelete.begin(), aclToDelete.end()); - for (std::vector::iterator pI = raclFacetIndices.begin(); pI != raclFacetIndices.end(); ++pI) + for (std::vector::iterator pI = raclFacetIndices.begin(); pI != raclFacetIndices.end(); ++pI) { if (aclTmp.find(*pI) == aclTmp.end()) aclResult.push_back(*pI); @@ -1304,7 +1212,7 @@ unsigned long MeshAlgorithm::CountBorderEdges() const MeshFacetArray::_TConstIterator end = rclFAry.end(); for (MeshFacetArray::_TConstIterator it = rclFAry.begin(); it != end; ++it) { for (int i=0; i<3; i++) { - if (it->_aulNeighbours[i] == ULONG_MAX) + if (it->_aulNeighbours[i] == FACET_INDEX_MAX) cnt++; } } @@ -1312,7 +1220,7 @@ unsigned long MeshAlgorithm::CountBorderEdges() const return cnt; } -void MeshAlgorithm::CheckBorderFacets (const std::vector &raclFacetIndices, std::vector &raclResultIndices, unsigned short usLevel) const +void MeshAlgorithm::CheckBorderFacets (const std::vector &raclFacetIndices, std::vector &raclResultIndices, unsigned short usLevel) const { ResetFacetFlag(MeshFacet::TMP0); SetFacetsFlag(raclFacetIndices, MeshFacet::TMP0); @@ -1321,12 +1229,12 @@ void MeshAlgorithm::CheckBorderFacets (const std::vector &raclFac for (unsigned short usL = 0; usL < usLevel; usL++) { - for (std::vector::const_iterator pF = raclFacetIndices.begin(); pF != raclFacetIndices.end(); ++pF) + for (std::vector::const_iterator pF = raclFacetIndices.begin(); pF != raclFacetIndices.end(); ++pF) { for (int i = 0; i < 3; i++) { - unsigned long ulNB = rclFAry[*pF]._aulNeighbours[i]; - if (ulNB == ULONG_MAX) + FacetIndex ulNB = rclFAry[*pF]._aulNeighbours[i]; + if (ulNB == FACET_INDEX_MAX) { raclResultIndices.push_back(*pF); rclFAry[*pF].ResetFlag(MeshFacet::TMP0); @@ -1343,20 +1251,20 @@ void MeshAlgorithm::CheckBorderFacets (const std::vector &raclFac } } -void MeshAlgorithm::GetBorderPoints (const std::vector &raclFacetIndices, std::set &raclResultPointsIndices) const +void MeshAlgorithm::GetBorderPoints (const std::vector &raclFacetIndices, std::set &raclResultPointsIndices) const { ResetFacetFlag(MeshFacet::TMP0); SetFacetsFlag(raclFacetIndices, MeshFacet::TMP0); const MeshFacetArray &rclFAry = _rclMesh._aclFacetArray; - for (std::vector::const_iterator pF = raclFacetIndices.begin(); pF != raclFacetIndices.end(); ++pF) + for (std::vector::const_iterator pF = raclFacetIndices.begin(); pF != raclFacetIndices.end(); ++pF) { for (int i = 0; i < 3; i++) { const MeshFacet &rclFacet = rclFAry[*pF]; - unsigned long ulNB = rclFacet._aulNeighbours[i]; - if (ulNB == ULONG_MAX) + FacetIndex ulNB = rclFacet._aulNeighbours[i]; + if (ulNB == FACET_INDEX_MAX) { raclResultPointsIndices.insert(rclFacet._aulPoints[i]); raclResultPointsIndices.insert(rclFacet._aulPoints[(i+1)%3]); @@ -1372,14 +1280,14 @@ void MeshAlgorithm::GetBorderPoints (const std::vector &raclFacet } } -bool MeshAlgorithm::NearestPointFromPoint (const Base::Vector3f &rclPt, unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const +bool MeshAlgorithm::NearestPointFromPoint (const Base::Vector3f &rclPt, FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const { if (_rclMesh.CountFacets() == 0) return false; // calc each facet float fMinDist = FLOAT_MAX; - unsigned long ulInd = ULONG_MAX; + FacetIndex ulInd = FACET_INDEX_MAX; MeshFacetIterator pF(_rclMesh); for (pF.Init(); pF.More(); pF.Next()) { @@ -1398,11 +1306,11 @@ bool MeshAlgorithm::NearestPointFromPoint (const Base::Vector3f &rclPt, unsigned return true; } -bool MeshAlgorithm::NearestPointFromPoint (const Base::Vector3f &rclPt, const MeshFacetGrid& rclGrid, unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const +bool MeshAlgorithm::NearestPointFromPoint (const Base::Vector3f &rclPt, const MeshFacetGrid& rclGrid, FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const { - unsigned long ulInd = rclGrid.SearchNearestFromPoint(rclPt); + FacetIndex ulInd = rclGrid.SearchNearestFromPoint(rclPt); - if (ulInd == ULONG_MAX) + if (ulInd == FACET_INDEX_MAX) { return false; } @@ -1415,11 +1323,11 @@ bool MeshAlgorithm::NearestPointFromPoint (const Base::Vector3f &rclPt, const Me } bool MeshAlgorithm::NearestPointFromPoint (const Base::Vector3f &rclPt, const MeshFacetGrid& rclGrid, float fMaxSearchArea, - unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const + FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const { - unsigned long ulInd = rclGrid.SearchNearestFromPoint(rclPt, fMaxSearchArea); + FacetIndex ulInd = rclGrid.SearchNearestFromPoint(rclPt, fMaxSearchArea); - if (ulInd == ULONG_MAX) + if (ulInd == FACET_INDEX_MAX) return false; // no facets inside BoundingBox MeshGeomFacet rclSFacet = _rclMesh.GetFacet(ulInd); @@ -1432,7 +1340,7 @@ bool MeshAlgorithm::NearestPointFromPoint (const Base::Vector3f &rclPt, const Me bool MeshAlgorithm::CutWithPlane (const Base::Vector3f &clBase, const Base::Vector3f &clNormal, const MeshFacetGrid &rclGrid, std::list > &rclResult, float fMinEps, bool bConnectPolygons) const { - std::vector aulFacets; + std::vector aulFacets; // Grid durschsuchen MeshGridIterator clGridIter(rclGrid); @@ -1450,7 +1358,7 @@ bool MeshAlgorithm::CutWithPlane (const Base::Vector3f &clBase, const Base::Vect // alle Facets mit Ebene schneiden std::list > clTempPoly; // Feld mit Schnittlinien (unsortiert, nicht verkettet) - for (std::vector::iterator pF = aulFacets.begin(); pF != aulFacets.end(); ++pF) + for (std::vector::iterator pF = aulFacets.begin(); pF != aulFacets.end(); ++pF) { Base::Vector3f clE1, clE2; const MeshGeomFacet clF(_rclMesh.GetFacet(*pF)); @@ -1630,9 +1538,9 @@ bool MeshAlgorithm::ConnectPolygons(std::list > &clP } void MeshAlgorithm::GetFacetsFromPlane (const MeshFacetGrid &rclGrid, const Base::Vector3f& clNormal, float d, const Base::Vector3f &rclLeft, - const Base::Vector3f &rclRight, std::vector &rclRes) const + const Base::Vector3f &rclRight, std::vector &rclRes) const { - std::vector aulFacets; + std::vector aulFacets; Base::Vector3f clBase = d * clNormal; @@ -1648,7 +1556,7 @@ void MeshAlgorithm::GetFacetsFromPlane (const MeshFacetGrid &rclGrid, const Base } // testing facet against planes - for (std::vector::iterator pI = aulFacets.begin(); pI != aulFacets.end(); ++pI) { + for (std::vector::iterator pI = aulFacets.begin(); pI != aulFacets.end(); ++pI) { MeshGeomFacet clSFacet = _rclMesh.GetFacet(*pI); if (clSFacet.IntersectWithPlane(clBase, clNormal) == true) { bool bInner = false; @@ -1664,29 +1572,29 @@ void MeshAlgorithm::GetFacetsFromPlane (const MeshFacetGrid &rclGrid, const Base } } -void MeshAlgorithm::PointsFromFacetsIndices (const std::vector &rvecIndices, std::vector &rvecPoints) const +void MeshAlgorithm::PointsFromFacetsIndices (const std::vector &rvecIndices, std::vector &rvecPoints) const { const MeshFacetArray &rclFAry = _rclMesh._aclFacetArray; const MeshPointArray &rclPAry = _rclMesh._aclPointArray; - std::set setPoints; + std::set setPoints; - for (std::vector::const_iterator itI = rvecIndices.begin(); itI != rvecIndices.end(); ++itI) + for (std::vector::const_iterator itI = rvecIndices.begin(); itI != rvecIndices.end(); ++itI) { for (int i = 0; i < 3; i++) setPoints.insert(rclFAry[*itI]._aulPoints[i]); } rvecPoints.clear(); - for (std::set::iterator itP = setPoints.begin(); itP != setPoints.end(); ++itP) + for (std::set::iterator itP = setPoints.begin(); itP != setPoints.end(); ++itP) rvecPoints.push_back(rclPAry[*itP]); } -bool MeshAlgorithm::Distance (const Base::Vector3f &rclPt, unsigned long ulFacetIdx, float fMaxDistance, float &rfDistance) const +bool MeshAlgorithm::Distance (const Base::Vector3f &rclPt, FacetIndex ulFacetIdx, float fMaxDistance, float &rfDistance) const { const MeshFacetArray &rclFAry = _rclMesh._aclFacetArray; const MeshPointArray &rclPAry = _rclMesh._aclPointArray; - const unsigned long *pulIdx = rclFAry[ulFacetIdx]._aulPoints; + const PointIndex *pulIdx = rclFAry[ulFacetIdx]._aulPoints; BoundBox3f clBB; clBB.Add(rclPAry[*(pulIdx++)]); @@ -1714,7 +1622,7 @@ float MeshAlgorithm::CalculateMinimumGridLength(float fLength, const Base::Bound // ---------------------------------------------------- -void MeshRefPointToFacets::Rebuild (void) +void MeshRefPointToFacets::Rebuild () { _map.clear(); @@ -1730,12 +1638,12 @@ void MeshRefPointToFacets::Rebuild (void) } } -Base::Vector3f MeshRefPointToFacets::GetNormal(unsigned long pos) const +Base::Vector3f MeshRefPointToFacets::GetNormal(PointIndex pos) const { - const std::set& n = _map[pos]; + const std::set& n = _map[pos]; Base::Vector3f normal; MeshGeomFacet f; - for (std::set::const_iterator it = n.begin(); it != n.end(); ++it) { + for (std::set::const_iterator it = n.begin(); it != n.end(); ++it) { f = _rclMesh.GetFacet(*it); normal += f.Area() * f.GetNormal(); } @@ -1744,19 +1652,19 @@ Base::Vector3f MeshRefPointToFacets::GetNormal(unsigned long pos) const return normal; } -std::set MeshRefPointToFacets::NeighbourPoints(const std::vector& pt, int level) const +std::set MeshRefPointToFacets::NeighbourPoints(const std::vector& pt, int level) const { - std::set cp,nb,lp; + std::set cp,nb,lp; cp.insert(pt.begin(), pt.end()); lp.insert(pt.begin(), pt.end()); MeshFacetArray::_TConstIterator f_it = _rclMesh.GetFacets().begin(); for (int i=0; i < level; i++) { - std::set cur; - for (std::set::iterator it = lp.begin(); it != lp.end(); ++it) { - const std::set& ft = (*this)[*it]; - for (std::set::const_iterator jt = ft.begin(); jt != ft.end(); ++jt) { + std::set cur; + for (std::set::iterator it = lp.begin(); it != lp.end(); ++it) { + const std::set& ft = (*this)[*it]; + for (std::set::const_iterator jt = ft.begin(); jt != ft.end(); ++jt) { for (int j = 0; j < 3; j++) { - unsigned long index = f_it[*jt]._aulPoints[j]; + PointIndex index = f_it[*jt]._aulPoints[j]; if (cp.find(index) == cp.end() && nb.find(index) == nb.end()) { nb.insert(index); cur.insert(index); @@ -1772,12 +1680,12 @@ std::set MeshRefPointToFacets::NeighbourPoints(const std::vector< return nb; } -std::set MeshRefPointToFacets::NeighbourPoints(unsigned long pos) const +std::set MeshRefPointToFacets::NeighbourPoints(PointIndex pos) const { - std::set p; - const std::set& vf = _map[pos]; - for (std::set::const_iterator it = vf.begin(); it != vf.end(); ++it) { - unsigned long p1, p2, p3; + std::set p; + const std::set& vf = _map[pos]; + for (std::set::const_iterator it = vf.begin(); it != vf.end(); ++it) { + PointIndex p1, p2, p3; _rclMesh.GetFacetPoints(*it, p1, p2, p3); if (p1 != pos) p.insert(p1); @@ -1790,17 +1698,17 @@ std::set MeshRefPointToFacets::NeighbourPoints(unsigned long pos) return p; } -void MeshRefPointToFacets::Neighbours (unsigned long ulFacetInd, float fMaxDist, MeshCollector& collect) const +void MeshRefPointToFacets::Neighbours (FacetIndex ulFacetInd, float fMaxDist, MeshCollector& collect) const { - std::set visited; + std::set visited; Base::Vector3f clCenter = _rclMesh.GetFacet(ulFacetInd).GetGravityPoint(); const MeshFacetArray& rFacets = _rclMesh.GetFacets(); SearchNeighbours(rFacets, ulFacetInd, clCenter, fMaxDist * fMaxDist, visited, collect); } -void MeshRefPointToFacets::SearchNeighbours(const MeshFacetArray& rFacets, unsigned long index, const Base::Vector3f &rclCenter, - float fMaxDist2, std::set& visited, MeshCollector& collect) const +void MeshRefPointToFacets::SearchNeighbours(const MeshFacetArray& rFacets, FacetIndex index, const Base::Vector3f &rclCenter, + float fMaxDist2, std::set& visited, MeshCollector& collect) const { if (visited.find(index) != visited.end()) return; @@ -1812,61 +1720,61 @@ void MeshRefPointToFacets::SearchNeighbours(const MeshFacetArray& rFacets, unsig visited.insert(index); collect.Append(_rclMesh, index); for (int i = 0; i < 3; i++) { - const std::set &f = (*this)[face._aulPoints[i]]; + const std::set &f = (*this)[face._aulPoints[i]]; - for (std::set::const_iterator j = f.begin(); j != f.end(); ++j) { + for (std::set::const_iterator j = f.begin(); j != f.end(); ++j) { SearchNeighbours(rFacets, *j, rclCenter, fMaxDist2, visited, collect); } } } MeshFacetArray::_TConstIterator -MeshRefPointToFacets::GetFacet (unsigned long index) const +MeshRefPointToFacets::GetFacet (FacetIndex index) const { return _rclMesh.GetFacets().begin() + index; } -const std::set& -MeshRefPointToFacets::operator[] (unsigned long pos) const +const std::set& +MeshRefPointToFacets::operator[] (PointIndex pos) const { return _map[pos]; } -std::vector -MeshRefPointToFacets::GetIndices(unsigned long pos1, unsigned long pos2) const +std::vector +MeshRefPointToFacets::GetIndices(PointIndex pos1, PointIndex pos2) const { - std::vector intersection; - std::back_insert_iterator > result(intersection); - const std::set& set1 = _map[pos1]; - const std::set& set2 = _map[pos2]; + std::vector intersection; + std::back_insert_iterator > result(intersection); + const std::set& set1 = _map[pos1]; + const std::set& set2 = _map[pos2]; std::set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(), result); return intersection; } -std::vector -MeshRefPointToFacets::GetIndices(unsigned long pos1, unsigned long pos2, unsigned long pos3) const +std::vector +MeshRefPointToFacets::GetIndices(PointIndex pos1, PointIndex pos2, PointIndex pos3) const { - std::vector intersection; - std::back_insert_iterator > result(intersection); - std::vector set1 = GetIndices(pos1, pos2); - const std::set& set2 = _map[pos3]; + std::vector intersection; + std::back_insert_iterator > result(intersection); + std::vector set1 = GetIndices(pos1, pos2); + const std::set& set2 = _map[pos3]; std::set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(), result); return intersection; } -void MeshRefPointToFacets::AddNeighbour(unsigned long pos, unsigned long facet) +void MeshRefPointToFacets::AddNeighbour(PointIndex pos, FacetIndex facet) { _map[pos].insert(facet); } -void MeshRefPointToFacets::RemoveNeighbour(unsigned long pos, unsigned long facet) +void MeshRefPointToFacets::RemoveNeighbour(PointIndex pos, FacetIndex facet) { _map[pos].erase(facet); } -void MeshRefPointToFacets::RemoveFacet(unsigned long facetIndex) +void MeshRefPointToFacets::RemoveFacet(FacetIndex facetIndex) { - unsigned long p0, p1, p2; + PointIndex p0, p1, p2; _rclMesh.GetFacetPoints(facetIndex, p0, p1, p2); _map[p0].erase(facetIndex); @@ -1876,7 +1784,7 @@ void MeshRefPointToFacets::RemoveFacet(unsigned long facetIndex) //---------------------------------------------------------------------------- -void MeshRefFacetToFacets::Rebuild (void) +void MeshRefFacetToFacets::Rebuild () { _map.clear(); @@ -1887,33 +1795,33 @@ void MeshRefFacetToFacets::Rebuild (void) MeshFacetArray::_TConstIterator pFBegin = rFacets.begin(); for (MeshFacetArray::_TConstIterator pFIter = pFBegin; pFIter != rFacets.end(); ++pFIter) { for (int i = 0; i < 3; i++) { - const std::set& faces = vertexFace[pFIter->_aulPoints[i]]; - for (std::set::const_iterator it = faces.begin(); it != faces.end(); ++it) + const std::set& faces = vertexFace[pFIter->_aulPoints[i]]; + for (std::set::const_iterator it = faces.begin(); it != faces.end(); ++it) _map[pFIter - pFBegin].insert(*it); } } } -const std::set& -MeshRefFacetToFacets::operator[] (unsigned long pos) const +const std::set& +MeshRefFacetToFacets::operator[] (FacetIndex pos) const { return _map[pos]; } -std::vector -MeshRefFacetToFacets::GetIndices(unsigned long pos1, unsigned long pos2) const +std::vector +MeshRefFacetToFacets::GetIndices(FacetIndex pos1, FacetIndex pos2) const { - std::vector intersection; - std::back_insert_iterator > result(intersection); - const std::set& set1 = _map[pos1]; - const std::set& set2 = _map[pos2]; + std::vector intersection; + std::back_insert_iterator > result(intersection); + const std::set& set1 = _map[pos1]; + const std::set& set2 = _map[pos2]; std::set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(), result); return intersection; } //---------------------------------------------------------------------------- -void MeshRefPointToPoints::Rebuild (void) +void MeshRefPointToPoints::Rebuild () { _map.clear(); @@ -1922,9 +1830,9 @@ void MeshRefPointToPoints::Rebuild (void) const MeshFacetArray& rFacets = _rclMesh.GetFacets(); for (MeshFacetArray::_TConstIterator pFIter = rFacets.begin(); pFIter != rFacets.end(); ++pFIter) { - unsigned long ulP0 = pFIter->_aulPoints[0]; - unsigned long ulP1 = pFIter->_aulPoints[1]; - unsigned long ulP2 = pFIter->_aulPoints[2]; + PointIndex ulP0 = pFIter->_aulPoints[0]; + PointIndex ulP1 = pFIter->_aulPoints[1]; + PointIndex ulP2 = pFIter->_aulPoints[2]; _map[ulP0].insert(ulP1); _map[ulP0].insert(ulP2); @@ -1935,14 +1843,14 @@ void MeshRefPointToPoints::Rebuild (void) } } -Base::Vector3f MeshRefPointToPoints::GetNormal(unsigned long pos) const +Base::Vector3f MeshRefPointToPoints::GetNormal(PointIndex pos) const { const MeshPointArray& rPoints = _rclMesh.GetPoints(); MeshCore::PlaneFit pf; pf.AddPoint(rPoints[pos]); MeshCore::MeshPoint center = rPoints[pos]; - const std::set& cv = _map[pos]; - for (std::set::const_iterator cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) { + const std::set& cv = _map[pos]; + for (std::set::const_iterator cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) { pf.AddPoint(rPoints[*cv_it]); center += rPoints[*cv_it]; } @@ -1954,42 +1862,42 @@ Base::Vector3f MeshRefPointToPoints::GetNormal(unsigned long pos) const return normal; } -float MeshRefPointToPoints::GetAverageEdgeLength(unsigned long index) const +float MeshRefPointToPoints::GetAverageEdgeLength(PointIndex index) const { const MeshPointArray& rPoints = _rclMesh.GetPoints(); float len=0.0f; - const std::set& n = (*this)[index]; + const std::set& n = (*this)[index]; const Base::Vector3f& p = rPoints[index]; - for (std::set::const_iterator it = n.begin(); it != n.end(); ++it) { + for (std::set::const_iterator it = n.begin(); it != n.end(); ++it) { len += Base::Distance(p, rPoints[*it]); } return (len/n.size()); } -const std::set& -MeshRefPointToPoints::operator[] (unsigned long pos) const +const std::set& +MeshRefPointToPoints::operator[] (PointIndex pos) const { return _map[pos]; } -void MeshRefPointToPoints::AddNeighbour(unsigned long pos, unsigned long facet) +void MeshRefPointToPoints::AddNeighbour(PointIndex pos, PointIndex facet) { _map[pos].insert(facet); } -void MeshRefPointToPoints::RemoveNeighbour(unsigned long pos, unsigned long facet) +void MeshRefPointToPoints::RemoveNeighbour(PointIndex pos, PointIndex facet) { _map[pos].erase(facet); } //---------------------------------------------------------------------------- -void MeshRefEdgeToFacets::Rebuild (void) +void MeshRefEdgeToFacets::Rebuild () { _map.clear(); const MeshFacetArray& rFacets = _rclMesh.GetFacets(); - unsigned long index = 0; + FacetIndex index = 0; for (MeshFacetArray::_TConstIterator it = rFacets.begin(); it != rFacets.end(); ++it, ++index) { for (int i=0; i<3; i++) { MeshEdge e; @@ -1999,7 +1907,7 @@ void MeshRefEdgeToFacets::Rebuild (void) _map.find(e); if (jt == _map.end()) { _map[e].first = index; - _map[e].second = ULONG_MAX; + _map[e].second = FACET_INDEX_MAX; } else { _map[e].second = index; @@ -2008,7 +1916,7 @@ void MeshRefEdgeToFacets::Rebuild (void) } } -const std::pair& +const std::pair& MeshRefEdgeToFacets::operator[] (const MeshEdge& edge) const { return _map.find(edge)->second; @@ -2016,7 +1924,7 @@ MeshRefEdgeToFacets::operator[] (const MeshEdge& edge) const //---------------------------------------------------------------------------- -void MeshRefNormalToPoints::Rebuild (void) +void MeshRefNormalToPoints::Rebuild () { _norm.clear(); @@ -2042,7 +1950,7 @@ void MeshRefNormalToPoints::Rebuild (void) } const Base::Vector3f& -MeshRefNormalToPoints::operator[] (unsigned long pos) const +MeshRefNormalToPoints::operator[] (PointIndex pos) const { return _norm[pos]; } diff --git a/src/Mod/Mesh/App/Core/Algorithm.h b/src/Mod/Mesh/App/Core/Algorithm.h index 424ffda122..79848d2ee2 100644 --- a/src/Mod/Mesh/App/Core/Algorithm.h +++ b/src/Mod/Mesh/App/Core/Algorithm.h @@ -58,7 +58,7 @@ public: /// Construction MeshAlgorithm (const MeshKernel &rclM) : _rclMesh(rclM) { } /// Destruction - ~MeshAlgorithm (void) { } + ~MeshAlgorithm () { } public: /** @@ -70,7 +70,7 @@ public: * occasionally. */ bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, Base::Vector3f &rclRes, - unsigned long &rulFacet) const; + FacetIndex &rulFacet) const; /** * Searches for the nearest facet to the ray defined by * (\a rclPt, \a rclDir). @@ -80,7 +80,7 @@ public: * used for a lot of tests. */ bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const MeshFacetGrid &rclGrid, - Base::Vector3f &rclRes, unsigned long &rulFacet) const; + Base::Vector3f &rclRes, FacetIndex &rulFacet) const; /** * Searches for the nearest facet to the ray defined by * (\a rclPt, \a rclDir). @@ -90,8 +90,8 @@ public: * the attached mesh. So the caller must ensure that the indices are valid * facets. */ - bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, - Base::Vector3f &rclRes, unsigned long &rulFacet) const; + bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, + Base::Vector3f &rclRes, FacetIndex &rulFacet) const; /** * Searches for the nearest facet to the ray defined by (\a rclPt, \a rclDir). The point \a rclRes holds * the intersection point with the ray and the nearest facet with index \a rulFacet. @@ -99,13 +99,13 @@ public: * \note This method is optimized by using a grid. So this method can be used for a lot of tests. */ bool NearestFacetOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea, - const MeshFacetGrid &rclGrid, Base::Vector3f &rclRes, unsigned long &rulFacet) const; + const MeshFacetGrid &rclGrid, Base::Vector3f &rclRes, FacetIndex &rulFacet) const; /** * Searches for the first facet of the grid element (\a rclGrid) in that the point \a rclPt lies into which is a distance not * higher than \a fMaxDistance. Of no such facet is found \a rulFacet is undefined and false is returned, otherwise true. * \note If the point \a rclPt is outside of the grid \a rclGrid nothing is done. */ - bool FirstFacetToVertex(const Base::Vector3f &rclPt, float fMaxDistance, const MeshFacetGrid &rclGrid, unsigned long &rulFacet) const; + bool FirstFacetToVertex(const Base::Vector3f &rclPt, float fMaxDistance, const MeshFacetGrid &rclGrid, FacetIndex &rulFacet) const; /** * Checks from the viewpoint \a rcView if the vertex \a rcVertex is visible or it is hidden by a facet. * If the vertex is visible true is returned, false otherwise. @@ -135,11 +135,11 @@ public: * Returns all boundaries of the mesh. This method does basically the same as above unless that it returns the point indices * of the boundaries. */ - void GetMeshBorders (std::list > &rclBorders) const; + void GetMeshBorders (std::list > &rclBorders) const; /** * Returns all boundaries of a subset the mesh defined by \a raulInd. */ - void GetFacetBorders (const std::vector &raulInd, std::list > &rclBorders) const; + void GetFacetBorders (const std::vector &raulInd, std::list > &rclBorders) const; /** * Returns all boundaries of a subset the mesh defined by \a raulInd. This method does basically the same as above unless * that it returns the point indices of the boundaries. @@ -148,18 +148,18 @@ public: * orientation even if the mesh is topologically correct. You should let the default value unless you exactly * know what you do. */ - void GetFacetBorders (const std::vector &raulInd, std::list > &rclBorders, + void GetFacetBorders (const std::vector &raulInd, std::list > &rclBorders, bool ignoreOrientation = false) const; /** * Returns the boundary of the mesh to the facet \a uFacet. If this facet does not have an open edge the returned * boundary is empty. */ - void GetMeshBorder(unsigned long uFacet, std::list& rBorder) const; + void GetMeshBorder(FacetIndex uFacet, std::list& rBorder) const; /** * Boundaries that consist of several loops must be split in several independent boundaries * to perform e.g. a polygon triangulation algorithm on them. */ - void SplitBoundaryLoops( std::list >& aBorders ); + void SplitBoundaryLoops( std::list >& aBorders ); /** * Fills up the single boundary if it is a hole with high quality triangles and a maximum area of \a fMaxArea. * The triangulation information is stored in \a rFaces and \a rPoints. @@ -172,14 +172,14 @@ public: * @note If the number of geometric points exceeds the number of boundary indices then the triangulation algorithm has * introduced new points which are added to the end of \a rPoints. */ - bool FillupHole(const std::vector& boundary, + bool FillupHole(const std::vector& boundary, AbstractPolygonTriangulator& cTria, MeshFacetArray& rFaces, MeshPointArray& rPoints, - int level, const MeshRefPointToFacets* pP2FStructure=0) const; + int level, const MeshRefPointToFacets* pP2FStructure=nullptr) const; /** Sets to all facets in \a raulInds the properties in raulProps. * \note Both arrays must have the same size. */ - void SetFacetsProperty(const std::vector &raulInds, const std::vector &raulProps) const; + void SetFacetsProperty(const std::vector &raulInds, const std::vector &raulProps) const; /** Sets to all facets the flag \a tF. */ void SetFacetFlag (MeshFacet::TFlagType tF) const; /** Sets to all points the flag \a tF. */ @@ -189,23 +189,23 @@ public: /** Resets of all points the flag \a tF. */ void ResetPointFlag (MeshPoint::TFlagType tF) const; /** Sets to all facets in \a raulInds the flag \a tF. */ - void SetFacetsFlag (const std::vector &raulInds, MeshFacet::TFlagType tF) const; + void SetFacetsFlag (const std::vector &raulInds, MeshFacet::TFlagType tF) const; /** Sets to all points in \a raulInds the flag \a tF. */ - void SetPointsFlag (const std::vector &raulInds, MeshPoint::TFlagType tF) const; + void SetPointsFlag (const std::vector &raulInds, MeshPoint::TFlagType tF) const; /** Gets all facets in \a raulInds with the flag \a tF. */ - void GetFacetsFlag (std::vector &raulInds, MeshFacet::TFlagType tF) const; + void GetFacetsFlag (std::vector &raulInds, MeshFacet::TFlagType tF) const; /** Gets all points in \a raulInds with the flag \a tF. */ - void GetPointsFlag (std::vector &raulInds, MeshPoint::TFlagType tF) const; + void GetPointsFlag (std::vector &raulInds, MeshPoint::TFlagType tF) const; /** Resets from all facets in \a raulInds the flag \a tF. */ - void ResetFacetsFlag (const std::vector &raulInds, MeshFacet::TFlagType tF) const; + void ResetFacetsFlag (const std::vector &raulInds, MeshFacet::TFlagType tF) const; /** Resets from all points in \a raulInds the flag \a tF. */ - void ResetPointsFlag (const std::vector &raulInds, MeshPoint::TFlagType tF) const; + void ResetPointsFlag (const std::vector &raulInds, MeshPoint::TFlagType tF) const; /** Count all facets with the flag \a tF. */ unsigned long CountFacetFlag (MeshFacet::TFlagType tF) const; /** Count all points with the flag \a tF. */ unsigned long CountPointFlag (MeshPoint::TFlagType tF) const; /** Returns all geometric points from the facets in \a rvecIndices. */ - void PointsFromFacetsIndices (const std::vector &rvecIndices, std::vector &rvecPoints) const; + void PointsFromFacetsIndices (const std::vector &rvecIndices, std::vector &rvecPoints) const; /** * Returns the indices of all facets that have at least one point that lies inside the tool mesh. The direction * \a dir is used to try to foraminate the facets of the tool mesh and counts the number of foraminated facets. @@ -213,11 +213,11 @@ public: * @note The tool mesh must be a valid solid. * @note It's not tested if \a rToolMesh is a valid solid. In case it is not the result is undefined. */ - void GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, std::vector &raclCutted ) const; + void GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, std::vector &raclCutted ) const; /** * Does basically the same as method above except it uses a mesh grid to speed up the computation. */ - void GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, const MeshFacetGrid& rGrid, std::vector &raclCutted ) const; + void GetFacetsFromToolMesh( const MeshKernel& rToolMesh, const Base::Vector3f& rcDir, const MeshFacetGrid& rGrid, std::vector &raclCutted ) const; /** * Checks whether the bounding box \a rBox is surrounded by the attached mesh which must be a solid. * The direction \a rcDir is used to try to foraminate the facets of the tool mesh and counts the number of foraminated facets. @@ -234,34 +234,34 @@ public: * This algorithm is optimized by using a grid. */ void CheckFacets (const MeshFacetGrid &rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly, - bool bInner, std::vector &rclRes) const; + bool bInner, std::vector &rclRes) const; /** * Does the same as the above method unless that it doesn't use a grid. */ void CheckFacets (const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly, - bool bInner, std::vector &rclRes) const; + bool bInner, std::vector &rclRes) const; /** * Determines all facets of the given array \a raclFacetIndices that lie at the edge or that * have at least neighbour facet that is not inside the array. The resulting array \a raclResultIndices * is not be deleted before the algorithm starts. \a usLevel indicates how often the algorithm is * repeated. */ - void CheckBorderFacets (const std::vector &raclFacetIndices, - std::vector &raclResultIndices, unsigned short usLevel = 1) const; + void CheckBorderFacets (const std::vector &raclFacetIndices, + std::vector &raclResultIndices, unsigned short usLevel = 1) const; /** * Invokes CheckBorderFacets() to get all border facets of \a raclFacetIndices. Then the content of * \a raclFacetIndices is replaced by all facets that can be deleted. * \note The mesh structure is not modified by this method. This is in the responsibility of the user. */ - void CutBorderFacets (std::vector &raclFacetIndices, unsigned short usLevel = 1) const; + void CutBorderFacets (std::vector &raclFacetIndices, unsigned short usLevel = 1) const; /** Returns the number of border edges */ unsigned long CountBorderEdges() const; /** * Determines all border points as indices of the facets in \a raclFacetIndices. The points are unsorted. */ - void GetBorderPoints (const std::vector &raclFacetIndices, std::set &raclResultPointsIndices) const; + void GetBorderPoints (const std::vector &raclFacetIndices, std::set &raclResultPointsIndices) const; /** Computes the surface of the mesh. */ - float Surface (void) const; + float Surface () const; /** Subsamples the mesh with point distance \a fDist and stores the points in \a rclPoints. */ void SubSampleByDist (float fDist, std::vector &rclPoints) const; /** @@ -275,15 +275,15 @@ public: * Searches for all facets that intersect the "search tube" with radius \a r around the polyline. */ void SearchFacetsFromPolyline (const std::vector &rclPolyline, float fRadius, - const MeshFacetGrid& rclGrid, std::vector &rclResultFacetsIndices) const; + const MeshFacetGrid& rclGrid, std::vector &rclResultFacetsIndices) const; /** Projects a point directly to the mesh (means nearest facet), the result is the facet index and * the foraminate point, use second version with grid for more performance. */ - bool NearestPointFromPoint (const Base::Vector3f &rclPt, unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const; + bool NearestPointFromPoint (const Base::Vector3f &rclPt, FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const; bool NearestPointFromPoint (const Base::Vector3f &rclPt, const MeshFacetGrid& rclGrid, - unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const; + FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const; bool NearestPointFromPoint (const Base::Vector3f &rclPt, const MeshFacetGrid& rclGrid, float fMaxSearchArea, - unsigned long &rclResFacetIndex, Base::Vector3f &rclResPoint) const; + FacetIndex &rclResFacetIndex, Base::Vector3f &rclResPoint) const; /** Cuts the mesh with a plane. The result is a list of polylines. */ bool CutWithPlane (const Base::Vector3f &clBase, const Base::Vector3f &clNormal, const MeshFacetGrid &rclGrid, std::list > &rclResult, float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const; @@ -292,12 +292,12 @@ public: * The plane is defined by it normalized normal and the signed distance to the origin. */ void GetFacetsFromPlane (const MeshFacetGrid &rclGrid, const Base::Vector3f& clNormal, float dist, - const Base::Vector3f &rclLeft, const Base::Vector3f &rclRight, std::vector &rclRes) const; + const Base::Vector3f &rclLeft, const Base::Vector3f &rclRight, std::vector &rclRes) const; /** Returns true if the distance from the \a rclPt to the facet \a ulFacetIdx is less than \a fMaxDistance. * If this restriction is met \a rfDistance is set to the actual distance, otherwise false is returned. */ - bool Distance (const Base::Vector3f &rclPt, unsigned long ulFacetIdx, float fMaxDistance, float &rfDistance) const; + bool Distance (const Base::Vector3f &rclPt, FacetIndex ulFacetIdx, float fMaxDistance, float &rfDistance) const; /** * Calculates the minimum grid length so that not more elements than \a maxElements will be created when the grid gets * built up. The minimum grid length must be at least \a fLength. @@ -311,12 +311,12 @@ protected: bool ConnectPolygons(std::list > &clPolyList, std::list > &rclLines) const; /** Searches the nearest facet in \a raulFacets to the ray (\a rclPt, \a rclDir). */ - bool RayNearestField (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, - Base::Vector3f &rclRes, unsigned long &rulFacet, float fMaxAngle = Mathf::PI) const; + bool RayNearestField (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, + Base::Vector3f &rclRes, FacetIndex &rulFacet, float fMaxAngle = Mathf::PI) const; /** * Splits the boundary \a rBound in several loops and append this loops to the list of borders. */ - void SplitBoundaryLoops( const std::vector& rBound, std::list >& aBorders ); + void SplitBoundaryLoops( const std::vector& rBound, std::list >& aBorders ); protected: const MeshKernel &_rclMesh; /**< The mesh kernel. */ @@ -327,17 +327,17 @@ class MeshExport MeshCollector public: MeshCollector(){} virtual ~MeshCollector(){} - virtual void Append(const MeshCore::MeshKernel&, unsigned long index) = 0; + virtual void Append(const MeshCore::MeshKernel&, FacetIndex index) = 0; }; class MeshExport PointCollector : public MeshCollector { public: - PointCollector(std::vector& ind) : indices(ind){} + PointCollector(std::vector& ind) : indices(ind){} virtual ~PointCollector(){} - virtual void Append(const MeshCore::MeshKernel& kernel, unsigned long index) + virtual void Append(const MeshCore::MeshKernel& kernel, FacetIndex index) { - unsigned long ulP1, ulP2, ulP3; + PointIndex ulP1, ulP2, ulP3; kernel.GetFacetPoints(index, ulP1, ulP2, ulP3); indices.push_back(ulP1); indices.push_back(ulP2); @@ -345,21 +345,21 @@ public: } private: - std::vector& indices; + std::vector& indices; }; class MeshExport FacetCollector : public MeshCollector { public: - FacetCollector(std::vector& ind) : indices(ind){} + FacetCollector(std::vector& ind) : indices(ind){} virtual ~FacetCollector(){} - void Append(const MeshCore::MeshKernel&, unsigned long index) + void Append(const MeshCore::MeshKernel&, FacetIndex index) { indices.push_back(index); } private: - std::vector& indices; + std::vector& indices; }; /** @@ -375,30 +375,30 @@ public: MeshRefPointToFacets (const MeshKernel &rclM) : _rclMesh(rclM) { Rebuild(); } /// Destruction - ~MeshRefPointToFacets (void) + ~MeshRefPointToFacets () { } /// Rebuilds up data structure - void Rebuild (void); - const std::set& operator[] (unsigned long) const; - std::vector GetIndices(unsigned long, unsigned long) const; - std::vector GetIndices(unsigned long, unsigned long, unsigned long) const; - MeshFacetArray::_TConstIterator GetFacet (unsigned long) const; - std::set NeighbourPoints(const std::vector& , int level) const; - std::set NeighbourPoints(unsigned long) const; - void Neighbours (unsigned long ulFacetInd, float fMaxDist, MeshCollector& collect) const; - Base::Vector3f GetNormal(unsigned long) const; - void AddNeighbour(unsigned long, unsigned long); - void RemoveNeighbour(unsigned long, unsigned long); - void RemoveFacet(unsigned long); + void Rebuild (); + const std::set& operator[] (PointIndex) const; + std::vector GetIndices(PointIndex, PointIndex) const; + std::vector GetIndices(PointIndex, PointIndex, PointIndex) const; + MeshFacetArray::_TConstIterator GetFacet (FacetIndex) const; + std::set NeighbourPoints(const std::vector& , int level) const; + std::set NeighbourPoints(PointIndex) const; + void Neighbours (FacetIndex ulFacetInd, float fMaxDist, MeshCollector& collect) const; + Base::Vector3f GetNormal(PointIndex) const; + void AddNeighbour(PointIndex, FacetIndex); + void RemoveNeighbour(PointIndex, FacetIndex); + void RemoveFacet(FacetIndex); protected: - void SearchNeighbours(const MeshFacetArray& rFacets, unsigned long index, const Base::Vector3f &rclCenter, - float fMaxDist, std::set &visit, MeshCollector& collect) const; + void SearchNeighbours(const MeshFacetArray& rFacets, FacetIndex index, const Base::Vector3f &rclCenter, + float fMaxDist, std::set &visit, MeshCollector& collect) const; protected: const MeshKernel &_rclMesh; /**< The mesh kernel. */ - std::vector > _map; + std::vector > _map; }; /** @@ -414,20 +414,20 @@ public: MeshRefFacetToFacets (const MeshKernel &rclM) : _rclMesh(rclM) { Rebuild(); } /// Destruction - ~MeshRefFacetToFacets (void) + ~MeshRefFacetToFacets () { } /// Rebuilds up data structure - void Rebuild (void); + void Rebuild (); /// Returns a set of facets sharing one or more points with the facet with /// index \a ulFacetIndex. - const std::set& operator[] (unsigned long) const; + const std::set& operator[] (FacetIndex) const; /// Returns an array of common facets of the passed facet indexes. - std::vector GetIndices(unsigned long, unsigned long) const; + std::vector GetIndices(FacetIndex, FacetIndex) const; protected: const MeshKernel &_rclMesh; /**< The mesh kernel. */ - std::vector > _map; + std::vector > _map; }; /** @@ -443,20 +443,20 @@ public: MeshRefPointToPoints (const MeshKernel &rclM) : _rclMesh(rclM) { Rebuild(); } /// Destruction - ~MeshRefPointToPoints (void) + ~MeshRefPointToPoints () { } /// Rebuilds up data structure - void Rebuild (void); - const std::set& operator[] (unsigned long) const; - Base::Vector3f GetNormal(unsigned long) const; - float GetAverageEdgeLength(unsigned long) const; - void AddNeighbour(unsigned long, unsigned long); - void RemoveNeighbour(unsigned long, unsigned long); + void Rebuild (); + const std::set& operator[] (PointIndex) const; + Base::Vector3f GetNormal(PointIndex) const; + float GetAverageEdgeLength(PointIndex) const; + void AddNeighbour(PointIndex, PointIndex); + void RemoveNeighbour(PointIndex, PointIndex); protected: const MeshKernel &_rclMesh; /**< The mesh kernel. */ - std::vector > _map; + std::vector > _map; }; /** @@ -472,12 +472,12 @@ public: MeshRefEdgeToFacets (const MeshKernel &rclM) : _rclMesh(rclM) { Rebuild(); } /// Destruction - ~MeshRefEdgeToFacets (void) + ~MeshRefEdgeToFacets () { } /// Rebuilds up data structure - void Rebuild (void); - const std::pair& operator[] (const MeshEdge&) const; + void Rebuild (); + const std::pair& operator[] (const MeshEdge&) const; protected: class EdgeOrder { @@ -494,7 +494,7 @@ protected: return false; } }; - typedef std::pair MeshFacetPair; + typedef std::pair MeshFacetPair; const MeshKernel &_rclMesh; /**< The mesh kernel. */ std::map _map; }; @@ -511,12 +511,12 @@ public: MeshRefNormalToPoints (const MeshKernel &rclM) : _rclMesh(rclM) { Rebuild(); } /// Destruction - ~MeshRefNormalToPoints (void) + ~MeshRefNormalToPoints () { } /// Rebuilds up data structure - void Rebuild (void); - const Base::Vector3f& operator[] (unsigned long) const; + void Rebuild (); + const Base::Vector3f& operator[] (PointIndex) const; protected: const MeshKernel &_rclMesh; /**< The mesh kernel. */ diff --git a/src/Mod/Mesh/App/Core/Approximation.cpp b/src/Mod/Mesh/App/Core/Approximation.cpp index 19fe054100..e8aa9e3148 100644 --- a/src/Mod/Mesh/App/Core/Approximation.cpp +++ b/src/Mod/Mesh/App/Core/Approximation.cpp @@ -117,7 +117,7 @@ Base::Vector3f Approximation::GetGravity() const return clGravity; } -unsigned long Approximation::CountPoints() const +std::size_t Approximation::CountPoints() const { return _vPoints.size(); } @@ -418,7 +418,7 @@ Base::BoundBox3f PlaneFit::GetBoundings() const { Base::BoundBox3f bbox; std::vector pts = GetLocalPoints(); - for (auto it : pts) + for (const auto& it : pts) bbox.Add(it); return bbox; } @@ -462,7 +462,7 @@ const double& QuadraticFit::GetCoeffArray() const return _fCoeff[0]; } -double QuadraticFit::GetCoeff(unsigned long ulIndex) const +double QuadraticFit::GetCoeff(std::size_t ulIndex) const { assert(ulIndex < 10); diff --git a/src/Mod/Mesh/App/Core/Approximation.h b/src/Mod/Mesh/App/Core/Approximation.h index cd71e568fb..99d73be059 100644 --- a/src/Mod/Mesh/App/Core/Approximation.h +++ b/src/Mod/Mesh/App/Core/Approximation.h @@ -147,7 +147,7 @@ public: * Determines the number of the current added points. * @return Number of points */ - unsigned long CountPoints() const; + std::size_t CountPoints() const; /** * Deletes the inserted points and frees any allocated resources. */ @@ -280,7 +280,7 @@ public: * @param ulIndex Number of coefficient (0..9) * @return double value of coefficient */ - double GetCoeff(unsigned long ulIndex) const; + double GetCoeff(std::size_t ulIndex) const; /** * Get the quadric coefficients as reference to the * internal array diff --git a/src/Mod/Mesh/App/Core/Builder.cpp b/src/Mod/Mesh/App/Core/Builder.cpp index db5a6271f5..e32a2bfcf8 100644 --- a/src/Mod/Mesh/App/Core/Builder.cpp +++ b/src/Mod/Mesh/App/Core/Builder.cpp @@ -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 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::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(), threads); - QVector indices(ulCtPts); + QVector indices(ulCtPts); size_type vertex_count = 0; for (QVector::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(vertex_count - 1); + indices[v->i] = static_cast(vertex_count - 1); } size_type ulCt = verts.size()/3; - MeshFacetArray rFacets(static_cast(ulCt)); + MeshFacetArray rFacets(static_cast(ulCt)); for (size_type i=0; i < ulCt; ++i) { rFacets[static_cast(i)]._aulPoints[0] = indices[3*i]; rFacets[static_cast(i)]._aulPoints[1] = indices[3*i + 1]; diff --git a/src/Mod/Mesh/App/Core/Builder.h b/src/Mod/Mesh/App/Core/Builder.h index 65d24649d1..81415b1d56 100644 --- a/src/Mod/Mesh/App/Core/Builder.h +++ b/src/Mod/Mesh/App/Core/Builder.h @@ -64,9 +64,11 @@ private: class Edge { public: - unsigned long pt1, pt2, facetIdx; + PointIndex pt1; + PointIndex pt2; + FacetIndex facetIdx; - Edge (unsigned long p1, unsigned long p2, unsigned long idx) + Edge (PointIndex p1, PointIndex p2, FacetIndex idx) { facetIdx = idx; if (p1 > p2) @@ -113,7 +115,7 @@ private: public: MeshBuilder(MeshKernel &rclM); - ~MeshBuilder(void); + ~MeshBuilder(); /** * Set the tolerance for the comparison of points. Normally you don't need to set the tolerance. @@ -189,7 +191,7 @@ private: public: typedef int size_type; MeshFastBuilder(MeshKernel &rclM); - ~MeshFastBuilder(void); + ~MeshFastBuilder(); /** Initializes the class. Must be done before adding facets * @param ctFacets count of facets. diff --git a/src/Mod/Mesh/App/Core/Curvature.cpp b/src/Mod/Mesh/App/Core/Curvature.cpp index 4507363fc7..6f29347191 100644 --- a/src/Mod/Mesh/App/Core/Curvature.cpp +++ b/src/Mod/Mesh/App/Core/Curvature.cpp @@ -54,10 +54,10 @@ MeshCurvature::MeshCurvature(const MeshKernel& kernel) : myKernel(kernel), myMinPoints(20), myRadius(0.5f) { mySegment.resize(kernel.CountFacets()); - std::generate(mySegment.begin(), mySegment.end(), Base::iotaGen(0)); + std::generate(mySegment.begin(), mySegment.end(), Base::iotaGen(0)); } -MeshCurvature::MeshCurvature(const MeshKernel& kernel, const std::vector& segm) +MeshCurvature::MeshCurvature(const MeshKernel& kernel, const std::vector& segm) : myKernel(kernel), myMinPoints(20), myRadius(0.5f), mySegment(segm) { } @@ -72,7 +72,7 @@ void MeshCurvature::ComputePerFace(bool parallel) if (!parallel) { Base::SequencerLauncher seq("Curvature estimation", mySegment.size()); - for (std::vector::iterator it = mySegment.begin(); it != mySegment.end(); ++it) { + for (std::vector::iterator it = mySegment.begin(); it != mySegment.end(); ++it) { CurvatureInfo info = face.Compute(*it); myCurvature.push_back(info); seq.next(); @@ -343,10 +343,10 @@ namespace MeshCore { class FitPointCollector : public MeshCollector { public: - FitPointCollector(std::set& ind) : indices(ind){} - virtual void Append(const MeshCore::MeshKernel& kernel, unsigned long index) + FitPointCollector(std::set& ind) : indices(ind){} + virtual void Append(const MeshCore::MeshKernel& kernel, FacetIndex index) { - unsigned long ulP1, ulP2, ulP3; + PointIndex ulP1, ulP2, ulP3; kernel.GetFacetPoints(index, ulP1, ulP2, ulP3); indices.insert(ulP1); indices.insert(ulP2); @@ -354,7 +354,7 @@ public: } private: - std::set& indices; + std::set& indices; }; } @@ -365,15 +365,15 @@ FacetCurvature::FacetCurvature(const MeshKernel& kernel, const MeshRefPointToFac { } -CurvatureInfo FacetCurvature::Compute(unsigned long index) const +CurvatureInfo FacetCurvature::Compute(FacetIndex index) const { - Base::Vector3f rkDir0, rkDir1, rkPnt; + Base::Vector3f rkDir0, rkDir1; Base::Vector3f rkNormal; MeshGeomFacet face = myKernel.GetFacet(index); Base::Vector3f face_gravity = face.GetGravityPoint(); Base::Vector3f face_normal = face.GetNormal(); - std::set point_indices; + std::set point_indices; FitPointCollector collect(point_indices); float searchDist = myRadius; @@ -391,7 +391,7 @@ CurvatureInfo FacetCurvature::Compute(unsigned long index) const std::vector fitPoints; const MeshPointArray& verts = myKernel.GetPoints(); fitPoints.reserve(point_indices.size()); - for (std::set::iterator it = point_indices.begin(); it != point_indices.end(); ++it) { + for (std::set::iterator it = point_indices.begin(); it != point_indices.end(); ++it) { fitPoints.push_back(verts[*it] - face_gravity); } diff --git a/src/Mod/Mesh/App/Core/Curvature.h b/src/Mod/Mesh/App/Core/Curvature.h index 7c200946a4..2e3bc6e63b 100644 --- a/src/Mod/Mesh/App/Core/Curvature.h +++ b/src/Mod/Mesh/App/Core/Curvature.h @@ -25,6 +25,7 @@ #include #include +#include "Definitions.h" namespace MeshCore { @@ -42,7 +43,7 @@ class MeshExport FacetCurvature { public: FacetCurvature(const MeshKernel& kernel, const MeshRefPointToFacets& search, float, unsigned long); - CurvatureInfo Compute(unsigned long index) const; + CurvatureInfo Compute(FacetIndex index) const; private: const MeshKernel& myKernel; @@ -55,7 +56,7 @@ class MeshExport MeshCurvature { public: MeshCurvature(const MeshKernel& kernel); - MeshCurvature(const MeshKernel& kernel, const std::vector& segm); + MeshCurvature(const MeshKernel& kernel, const std::vector& segm); float GetRadius() const { return myRadius; } void SetRadius(float r) { myRadius = r; } void ComputePerFace(bool parallel); @@ -66,7 +67,7 @@ private: const MeshKernel& myKernel; unsigned long myMinPoints; float myRadius; - std::vector mySegment; + std::vector mySegment; std::vector myCurvature; }; diff --git a/src/Mod/Mesh/App/Core/Definitions.cpp b/src/Mod/Mesh/App/Core/Definitions.cpp index 2c1b2819f2..5c0f66290b 100644 --- a/src/Mod/Mesh/App/Core/Definitions.cpp +++ b/src/Mod/Mesh/App/Core/Definitions.cpp @@ -40,7 +40,7 @@ float MeshDefinitions::_fMinEdgeLength = MESH_MIN_EDGE_LEN; bool MeshDefinitions::_bRemoveMinLength = MESH_REMOVE_MIN_LEN; float MeshDefinitions::_fMinEdgeAngle = Base::toRadians(MESH_MIN_EDGE_ANGLE); -MeshDefinitions::MeshDefinitions (void) +MeshDefinitions::MeshDefinitions () { } diff --git a/src/Mod/Mesh/App/Core/Definitions.h b/src/Mod/Mesh/App/Core/Definitions.h index 0aadd101db..4745a015da 100644 --- a/src/Mod/Mesh/App/Core/Definitions.h +++ b/src/Mod/Mesh/App/Core/Definitions.h @@ -28,6 +28,8 @@ #include #endif +#include + // default values #define MESH_MIN_PT_DIST 1.0e-6f #define MESH_MIN_EDGE_LEN 1.0e-3f @@ -54,6 +56,14 @@ namespace MeshCore { +// type definitions +using ElementIndex = unsigned long; +const ElementIndex ELEMENT_INDEX_MAX = ULONG_MAX; +using FacetIndex = ElementIndex; +const FacetIndex FACET_INDEX_MAX = ULONG_MAX; +using PointIndex = ElementIndex; +const PointIndex POINT_INDEX_MAX = ULONG_MAX; + template class Math { @@ -71,8 +81,8 @@ typedef Math Mathd; class MeshExport MeshDefinitions { public: - MeshDefinitions (void); - virtual ~MeshDefinitions (void) + MeshDefinitions (); + virtual ~MeshDefinitions () {} static float _fMinPointDistance; diff --git a/src/Mod/Mesh/App/Core/Degeneration.cpp b/src/Mod/Mesh/App/Core/Degeneration.cpp index 261c30c452..96f8a6b74b 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.cpp +++ b/src/Mod/Mesh/App/Core/Degeneration.cpp @@ -63,12 +63,12 @@ bool MeshEvalInvalids::Evaluate() return true; } -std::vector MeshEvalInvalids::GetIndices() const +std::vector MeshEvalInvalids::GetIndices() const { - std::vector aInds; + std::vector aInds; const MeshFacetArray& rFaces = _rclMesh.GetFacets(); const MeshPointArray& rPoints = _rclMesh.GetPoints(); - unsigned long ind=0; + FacetIndex ind=0; for ( MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++ ) { if ( !it->IsValid() ) @@ -144,7 +144,7 @@ bool MeshEvalDuplicatePoints::Evaluate() return true; } -std::vector MeshEvalDuplicatePoints::GetIndices() const +std::vector MeshEvalDuplicatePoints::GetIndices() const { //Note: We must neither use map or set to get duplicated indices because //the sort algorithms deliver different results compared to std::sort of @@ -157,7 +157,7 @@ std::vector MeshEvalDuplicatePoints::GetIndices() const } // if there are two adjacent vertices which have the same coordinates - std::vector aInds; + std::vector aInds; Vertex_EqualTo pred; std::sort(vertices.begin(), vertices.end(), Vertex_Less()); @@ -187,21 +187,20 @@ bool MeshFixDuplicatePoints::Fixup() } // get the indices of adjacent vertices which have the same coordinates - std::vector aInds; std::sort(vertices.begin(), vertices.end(), Vertex_Less()); Vertex_EqualTo pred; std::vector::iterator next = vertices.begin(); - std::map mapPointIndex; - std::vector pointIndices; + std::map mapPointIndex; + std::vector pointIndices; while (next < vertices.end()) { next = std::adjacent_find(next, vertices.end(), pred); if (next < vertices.end()) { std::vector::iterator first = next; - unsigned long first_index = *first - rPoints.begin(); + PointIndex first_index = *first - rPoints.begin(); ++next; while (next < vertices.end() && pred(*first, *next)) { - unsigned long next_index = *next - rPoints.begin(); + PointIndex next_index = *next - rPoints.begin(); mapPointIndex[next_index] = first_index; pointIndices.push_back(next_index); ++next; @@ -213,7 +212,7 @@ bool MeshFixDuplicatePoints::Fixup() MeshFacetArray& rFacets = _rclMesh._aclFacetArray; for (MeshFacetArray::_TIterator it = rFacets.begin(); it != rFacets.end(); ++it) { for (int i=0; i<3; i++) { - std::map::iterator pt = mapPointIndex.find(it->_aulPoints[i]); + std::map::iterator pt = mapPointIndex.find(it->_aulPoints[i]); if (pt != mapPointIndex.end()) it->_aulPoints[i] = pt->second; } @@ -239,9 +238,9 @@ bool MeshEvalNaNPoints::Evaluate() return true; } -std::vector MeshEvalNaNPoints::GetIndices() const +std::vector MeshEvalNaNPoints::GetIndices() const { - std::vector aInds; + std::vector aInds; const MeshPointArray& rPoints = _rclMesh.GetPoints(); for (MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) { if (boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z)) @@ -253,7 +252,7 @@ std::vector MeshEvalNaNPoints::GetIndices() const bool MeshFixNaNPoints::Fixup() { - std::vector aInds; + std::vector aInds; const MeshPointArray& rPoints = _rclMesh.GetPoints(); for (MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) { if (boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z)) @@ -280,13 +279,13 @@ struct MeshFacet_Less bool operator()(const FaceIterator& x, const FaceIterator& y) const { - unsigned long tmp; - unsigned long x0 = x->_aulPoints[0]; - unsigned long x1 = x->_aulPoints[1]; - unsigned long x2 = x->_aulPoints[2]; - unsigned long y0 = y->_aulPoints[0]; - unsigned long y1 = y->_aulPoints[1]; - unsigned long y2 = y->_aulPoints[2]; + PointIndex tmp; + PointIndex x0 = x->_aulPoints[0]; + PointIndex x1 = x->_aulPoints[1]; + PointIndex x2 = x->_aulPoints[2]; + PointIndex y0 = y->_aulPoints[0]; + PointIndex y1 = y->_aulPoints[1]; + PointIndex y2 = y->_aulPoints[2]; if (x0 > x1) { tmp = x0; x0 = x1; x1 = tmp; } @@ -351,7 +350,7 @@ bool MeshEvalDuplicateFacets::Evaluate() return true; } -std::vector MeshEvalDuplicateFacets::GetIndices() const +std::vector MeshEvalDuplicateFacets::GetIndices() const { #if 1 const MeshFacetArray& rFacets = _rclMesh.GetFacets(); @@ -362,7 +361,7 @@ std::vector MeshEvalDuplicateFacets::GetIndices() const } // if there are two adjacent faces which references the same vertices - std::vector aInds; + std::vector aInds; MeshFacet_EqualTo pred; std::sort(faces.begin(), faces.end(), MeshFacet_Less()); @@ -378,9 +377,9 @@ std::vector MeshEvalDuplicateFacets::GetIndices() const return aInds; #else - std::vector aInds; + std::vector aInds; const MeshFacetArray& rFaces = _rclMesh.GetFacets(); - unsigned long uIndex=0; + FacetIndex uIndex=0; // get all facets std::set aFaceSet; @@ -398,8 +397,8 @@ std::vector MeshEvalDuplicateFacets::GetIndices() const bool MeshFixDuplicateFacets::Fixup() { - unsigned long uIndex=0; - std::vector aRemoveFaces; + FacetIndex uIndex=0; + std::vector aRemoveFaces; const MeshFacetArray& rFaces = _rclMesh.GetFacets(); // get all facets @@ -422,7 +421,7 @@ bool MeshFixDuplicateFacets::Fixup() bool MeshEvalInternalFacets::Evaluate() { _indices.clear(); - unsigned long uIndex=0; + FacetIndex uIndex=0; const MeshFacetArray& rFaces = _rclMesh.GetFacets(); // get all facets @@ -470,9 +469,9 @@ unsigned long MeshEvalDegeneratedFacets::CountEdgeTooSmall (float fMinEdgeLength return k; } -std::vector MeshEvalDegeneratedFacets::GetIndices() const +std::vector MeshEvalDegeneratedFacets::GetIndices() const { - std::vector aInds; + std::vector aInds; MeshFacetIterator it(_rclMesh); for (it.Init(); it.More(); it.Next()) { if (it->IsDegenerated(fEpsilon)) @@ -489,10 +488,9 @@ bool MeshFixDegeneratedFacets::Fixup() MeshFacetIterator it(_rclMesh); for (it.Init(); it.More(); it.Next()) { if (it->IsDegenerated(fEpsilon)) { - unsigned long uCt = _rclMesh.CountFacets(); - unsigned long uId = it.Position(); - cTopAlg.RemoveDegeneratedFacet(uId); - if (uCt != _rclMesh.CountFacets()) { + FacetIndex uId = it.Position(); + bool removed = cTopAlg.RemoveDegeneratedFacet(uId); + if (removed) { // due to a modification of the array the iterator became invalid it.Set(uId-1); } @@ -562,18 +560,18 @@ bool MeshRemoveNeedles::Fixup() ce._toPoint = rclFAry[faceedge.first]._aulPoints[(faceedge.second+1)%3]; ce._removeFacets.push_back(faceedge.first); - unsigned long neighbour = rclFAry[faceedge.first]._aulNeighbours[faceedge.second]; - if (neighbour != ULONG_MAX) + FacetIndex neighbour = rclFAry[faceedge.first]._aulNeighbours[faceedge.second]; + if (neighbour != FACET_INDEX_MAX) ce._removeFacets.push_back(neighbour); - std::set vf = vf_it[ce._fromPoint]; + std::set vf = vf_it[ce._fromPoint]; vf.erase(faceedge.first); - if (neighbour != ULONG_MAX) + if (neighbour != FACET_INDEX_MAX) vf.erase(neighbour); ce._changeFacets.insert(ce._changeFacets.begin(), vf.begin(), vf.end()); // get adjacent points - std::set vv; + std::set vv; vv = vf_it.NeighbourPoints(ce._fromPoint); ce._adjacentFrom.insert(ce._adjacentFrom.begin(), vv.begin(),vv.end()); vv = vf_it.NeighbourPoints(ce._toPoint); @@ -598,98 +596,6 @@ bool MeshRemoveNeedles::Fixup() } return true; -#if 0 - unsigned long ulCtLastLoop, ulCtFacets = _rclMesh.CountFacets(); - - const MeshFacetArray &rclFAry = _rclMesh.GetFacets(); - const MeshPointArray &rclPAry = _rclMesh.GetPoints(); - MeshFacetArray::_TConstIterator f_beg = rclFAry.begin(); - - // repeat until no facet can be removed - do { - MeshRefPointToFacets clPt2Facets(_rclMesh); - - rclFAry.ResetInvalid(); - rclPAry.ResetInvalid(); - rclPAry.ResetFlag(MeshPoint::VISIT); - - std::set > aclPtDelList; - - MeshFacetIterator clFIter(_rclMesh); - for (clFIter.Init(); clFIter.More(); clFIter.Next()) { - MeshGeomFacet clSFacet = *clFIter; - Base::Vector3f clP0 = clSFacet._aclPoints[0]; - Base::Vector3f clP1 = clSFacet._aclPoints[1]; - Base::Vector3f clP2 = clSFacet._aclPoints[2]; - Base::Vector3f clE01 = clP1 - clP0; - Base::Vector3f clE12 = clP2 - clP1; - Base::Vector3f clE20 = clP2 - clP0; - MeshFacet clFacet = clFIter.GetIndices(); - unsigned long ulP0 = clFacet._aulPoints[0]; - unsigned long ulP1 = clFacet._aulPoints[1]; - unsigned long ulP2 = clFacet._aulPoints[2]; - - if (Base::Distance(clP0, clP1) < fMinEdgeLength) { - // delete point P1 on P0 - aclPtDelList.insert(std::make_pair - (std::min(ulP1, ulP0), std::max(ulP1, ulP0))); - clFIter.SetFlag(MeshFacet::INVALID); - } - else if (Base::Distance(clP1, clP2) < fMinEdgeLength) { - // delete point P2 on P1 - aclPtDelList.insert(std::make_pair - (std::min(ulP2, ulP1), std::max(ulP2, ulP1))); - clFIter.SetFlag(MeshFacet::INVALID); - } - else if (Base::Distance(clP2, clP0) < fMinEdgeLength) { - // delete point P0 on P2 - aclPtDelList.insert(std::make_pair - (std::min(ulP0, ulP2), std::max(ulP0, ulP2))); - clFIter.SetFlag(MeshFacet::INVALID); - } - } -#if 0 - // remove points, fix indices - for (std::set >::iterator pI = aclPtDelList.begin(); - pI != aclPtDelList.end(); ++pI) { - // one of the point pairs is already processed - if ((rclPAry[pI->first].IsFlag(MeshPoint::VISIT) == true) || - (rclPAry[pI->second].IsFlag(MeshPoint::VISIT) == true)) - continue; - - rclPAry[pI->first].SetFlag(MeshPoint::VISIT); - rclPAry[pI->second].SetFlag(MeshPoint::VISIT); - rclPAry[pI->second].SetInvalid(); - - // Redirect all point-indices to the new neighbour point of all facets referencing the - // deleted point - const std::set& faces = clPt2Facets[pI->second]; - for (std::set::const_iterator pF = faces.begin(); pF != faces.end(); ++pF) { - const MeshFacet &rclF = f_beg[*pF]; - - for (int i = 0; i < 3; i++) { -// if (rclF._aulPoints[i] == pI->second) -// rclF._aulPoints[i] = pI->first; - } - - // Delete facets with two identical corners - if ((rclF._aulPoints[0] == rclF._aulPoints[1]) || - (rclF._aulPoints[0] == rclF._aulPoints[2]) || - (rclF._aulPoints[1] == rclF._aulPoints[2])) { - rclF.SetInvalid(); - } - } - } -#endif - ulCtLastLoop = _rclMesh.CountFacets(); - _rclMesh.RemoveInvalids(); - } - while (ulCtLastLoop > _rclMesh.CountFacets()); - - _rclMesh.RebuildNeighbours(); - - return ulCtFacets > _rclMesh.CountFacets(); -#endif } // ---------------------------------------------------------------------- @@ -754,9 +660,9 @@ bool MeshFixCaps::Fixup() if (distP2P4/distP2P3 < fSplitFactor || distP3P4/distP2P3 < fSplitFactor) continue; - unsigned long facetpos = facevertex.first; - unsigned long neighbour = rclFAry[facetpos]._aulNeighbours[(facevertex.second+1)%3]; - if (neighbour != ULONG_MAX) + FacetIndex facetpos = facevertex.first; + FacetIndex neighbour = rclFAry[facetpos]._aulNeighbours[(facevertex.second+1)%3]; + if (neighbour != FACET_INDEX_MAX) topAlg.SwapEdge(facetpos, neighbour); } @@ -779,12 +685,12 @@ bool MeshEvalDeformedFacets::Evaluate() return true; } -std::vector MeshEvalDeformedFacets::GetIndices() const +std::vector MeshEvalDeformedFacets::GetIndices() const { float fCosMinAngle = cos(fMinAngle); float fCosMaxAngle = cos(fMaxAngle); - std::vector aInds; + std::vector aInds; MeshFacetIterator it(_rclMesh); for (it.Init(); it.More(); it.Next()) { if (it->IsDeformed(fCosMinAngle, fCosMaxAngle)) @@ -825,8 +731,8 @@ bool MeshFixDeformedFacets::Fixup() float fCosAngle = fCosAngles[i]; if (fCosAngle < fCosMaxAngle) { const MeshFacet& face = it.GetReference(); - unsigned long uNeighbour = face._aulNeighbours[(i+1)%3]; - if (uNeighbour!=ULONG_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) { + FacetIndex uNeighbour = face._aulNeighbours[(i+1)%3]; + if (uNeighbour!=FACET_INDEX_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) { cTopAlg.SwapEdge(it.Position(), uNeighbour); done = true; } @@ -844,14 +750,14 @@ bool MeshFixDeformedFacets::Fixup() if (fCosAngle > fCosMinAngle) { const MeshFacet& face = it.GetReference(); - unsigned long uNeighbour = face._aulNeighbours[j]; - if (uNeighbour!=ULONG_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) { + FacetIndex uNeighbour = face._aulNeighbours[j]; + if (uNeighbour!=FACET_INDEX_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) { cTopAlg.SwapEdge(it.Position(), uNeighbour); break; } uNeighbour = face._aulNeighbours[(j+2)%3]; - if (uNeighbour!=ULONG_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) { + if (uNeighbour!=FACET_INDEX_MAX && cTopAlg.ShouldSwapEdge(it.Position(), uNeighbour, fMaxSwapAngle)) { cTopAlg.SwapEdge(it.Position(), uNeighbour); break; } @@ -879,9 +785,9 @@ bool MeshFixMergeFacets::Fixup() if (vv_it[i].size() == 3 && vf_it[i].size() == 3) { VertexCollapse vc; vc._point = i; - const std::set& adjPts = vv_it[i]; + const std::set& adjPts = vv_it[i]; vc._circumPoints.insert(vc._circumPoints.begin(), adjPts.begin(), adjPts.end()); - const std::set& adjFts = vf_it[i]; + const std::set& adjFts = vf_it[i]; vc._circumFacets.insert(vc._circumFacets.begin(), adjFts.begin(), adjFts.end()); topAlg.CollapseVertex(vc); } @@ -904,16 +810,16 @@ bool MeshEvalDentsOnSurface::Evaluate() Base::Vector3f tmp; unsigned long ctPoints = _rclMesh.CountPoints(); for (unsigned long index=0; index < ctPoints; index++) { - std::vector point; + std::vector point; point.push_back(index); // get the local neighbourhood of the point - std::set nb = clPt2Facets.NeighbourPoints(point,1); - const std::set& faces = clPt2Facets[index]; + std::set nb = clPt2Facets.NeighbourPoints(point,1); + const std::set& faces = clPt2Facets[index]; - for (std::set::iterator pt = nb.begin(); pt != nb.end(); ++pt) { + for (std::set::iterator pt = nb.begin(); pt != nb.end(); ++pt) { const MeshPoint& mp = rPntAry[*pt]; - for (std::set::const_iterator + for (std::set::const_iterator ft = faces.begin(); ft != faces.end(); ++ft) { // the point must not be part of the facet we test if (f_beg[*ft]._aulPoints[0] == *pt) @@ -925,7 +831,7 @@ bool MeshEvalDentsOnSurface::Evaluate() // is the point projectable onto the facet? rTriangle = _rclMesh.GetFacet(f_beg[*ft]); if (rTriangle.IntersectWithLine(mp,rTriangle.GetNormal(),tmp)) { - const std::set& f = clPt2Facets[*pt]; + const std::set& f = clPt2Facets[*pt]; this->indices.insert(this->indices.end(), f.begin(), f.end()); break; } @@ -941,7 +847,7 @@ bool MeshEvalDentsOnSurface::Evaluate() return this->indices.empty(); } -std::vector MeshEvalDentsOnSurface::GetIndices() const +std::vector MeshEvalDentsOnSurface::GetIndices() const { return this->indices; } @@ -961,7 +867,7 @@ bool MeshFixDentsOnSurface::Fixup() { MeshEvalDentsOnSurface eval(_rclMesh); if (!eval.Evaluate()) { - std::vector inds = eval.GetIndices(); + std::vector inds = eval.GetIndices(); _rclMesh.DeleteFacets(inds); } @@ -977,10 +883,10 @@ bool MeshEvalFoldsOnSurface::Evaluate() unsigned long ct=0; for (MeshFacetArray::const_iterator it = rFAry.begin(); it != rFAry.end(); ++it, ct++) { for (int i=0; i<3; i++) { - unsigned long n1 = it->_aulNeighbours[i]; - unsigned long n2 = it->_aulNeighbours[(i+1)%3]; + FacetIndex n1 = it->_aulNeighbours[i]; + FacetIndex n2 = it->_aulNeighbours[(i+1)%3]; Base::Vector3f v1 =_rclMesh.GetFacet(*it).GetNormal(); - if (n1 != ULONG_MAX && n2 != ULONG_MAX) { + if (n1 != FACET_INDEX_MAX && n2 != FACET_INDEX_MAX) { Base::Vector3f v2 = _rclMesh.GetFacet(n1).GetNormal(); Base::Vector3f v3 = _rclMesh.GetFacet(n2).GetNormal(); if (v2 * v3 > 0.0f) { @@ -1001,7 +907,7 @@ bool MeshEvalFoldsOnSurface::Evaluate() return this->indices.empty(); } -std::vector MeshEvalFoldsOnSurface::GetIndices() const +std::vector MeshEvalFoldsOnSurface::GetIndices() const { return this->indices; } @@ -1017,7 +923,7 @@ bool MeshEvalFoldsOnBoundary::Evaluate() for (MeshFacetArray::_TConstIterator it = rFacAry.begin(); it != rFacAry.end(); ++it) { if (it->CountOpenEdges() == 2) { for (int i=0; i<3; i++) { - if (it->_aulNeighbours[i] != ULONG_MAX) { + if (it->_aulNeighbours[i] != FACET_INDEX_MAX) { MeshGeomFacet f1 = _rclMesh.GetFacet(*it); MeshGeomFacet f2 = _rclMesh.GetFacet(it->_aulNeighbours[i]); float cos_angle = f1.GetNormal() * f2.GetNormal(); @@ -1031,7 +937,7 @@ bool MeshEvalFoldsOnBoundary::Evaluate() return this->indices.empty(); } -std::vector MeshEvalFoldsOnBoundary::GetIndices() const +std::vector MeshEvalFoldsOnBoundary::GetIndices() const { return this->indices; } @@ -1040,7 +946,7 @@ bool MeshFixFoldsOnBoundary::Fixup() { MeshEvalFoldsOnBoundary eval(_rclMesh); if (!eval.Evaluate()) { - std::vector inds = eval.GetIndices(); + std::vector inds = eval.GetIndices(); _rclMesh.DeleteFacets(inds); } @@ -1059,9 +965,9 @@ bool MeshEvalFoldOversOnSurface::Evaluate() Base::Vector3f n1, n2; for (f_it = facets.begin(); f_it != f_end; ++f_it) { for (int i=0; i<3; i++) { - unsigned long index1 = f_it->_aulNeighbours[i]; - unsigned long index2 = f_it->_aulNeighbours[(i+1)%3]; - if (index1 != ULONG_MAX && index2 != ULONG_MAX) { + FacetIndex index1 = f_it->_aulNeighbours[i]; + FacetIndex index2 = f_it->_aulNeighbours[(i+1)%3]; + if (index1 != FACET_INDEX_MAX && index2 != FACET_INDEX_MAX) { // if the topology is correct but the normals flip from // two neighbours we have a fold if (f_it->HasSameOrientation(f_beg[index1]) && @@ -1093,7 +999,7 @@ bool MeshEvalBorderFacet::Evaluate() for (f_it = facets.begin(); f_it != f_end; ++f_it) { bool ok = true; for (int i=0; i<3; i++) { - unsigned long index = f_it->_aulPoints[i]; + PointIndex index = f_it->_aulPoints[i]; if (vv_it[index].size() == vf_it[index].size()) { ok = false; break; @@ -1112,11 +1018,11 @@ bool MeshEvalBorderFacet::Evaluate() bool MeshEvalRangeFacet::Evaluate() { const MeshFacetArray& rFaces = _rclMesh.GetFacets(); - unsigned long ulCtFacets = rFaces.size(); + FacetIndex ulCtFacets = rFaces.size(); for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) { for (int i = 0; i < 3; i++) { - if ((it->_aulNeighbours[i] >= ulCtFacets) && (it->_aulNeighbours[i] < ULONG_MAX)) { + if ((it->_aulNeighbours[i] >= ulCtFacets) && (it->_aulNeighbours[i] < FACET_INDEX_MAX)) { return false; } } @@ -1125,16 +1031,16 @@ bool MeshEvalRangeFacet::Evaluate() return true; } -std::vector MeshEvalRangeFacet::GetIndices() const +std::vector MeshEvalRangeFacet::GetIndices() const { - std::vector aInds; + std::vector aInds; const MeshFacetArray& rFaces = _rclMesh.GetFacets(); - unsigned long ulCtFacets = rFaces.size(); + FacetIndex ulCtFacets = rFaces.size(); - unsigned long ind=0; + FacetIndex ind=0; for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++) { for (int i = 0; i < 3; i++) { - if ((it->_aulNeighbours[i] >= ulCtFacets) && (it->_aulNeighbours[i] < ULONG_MAX)) { + if ((it->_aulNeighbours[i] >= ulCtFacets) && (it->_aulNeighbours[i] < FACET_INDEX_MAX)) { aInds.push_back(ind); break; } @@ -1155,25 +1061,25 @@ bool MeshFixRangeFacet::Fixup() bool MeshEvalRangePoint::Evaluate() { const MeshFacetArray& rFaces = _rclMesh.GetFacets(); - unsigned long ulCtPoints = _rclMesh.CountPoints(); + PointIndex ulCtPoints = _rclMesh.CountPoints(); for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) { - if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](unsigned long i) { return i >= ulCtPoints; }) < it->_aulPoints + 3) + if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](PointIndex i) { return i >= ulCtPoints; }) < it->_aulPoints + 3) return false; } return true; } -std::vector MeshEvalRangePoint::GetIndices() const +std::vector MeshEvalRangePoint::GetIndices() const { - std::vector aInds; + std::vector aInds; const MeshFacetArray& rFaces = _rclMesh.GetFacets(); - unsigned long ulCtPoints = _rclMesh.CountPoints(); + PointIndex ulCtPoints = _rclMesh.CountPoints(); - unsigned long ind=0; + PointIndex ind=0; for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++) { - if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](unsigned long i) { return i >= ulCtPoints; }) < it->_aulPoints + 3) + if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](PointIndex i) { return i >= ulCtPoints; }) < it->_aulPoints + 3) aInds.push_back(ind); } @@ -1190,10 +1096,10 @@ bool MeshFixRangePoint::Fixup() else { // facets with point indices out of range cannot be directly deleted because // 'DeleteFacets' will segfault. But setting all point indices to 0 works. - std::vector invalid = eval.GetIndices(); + std::vector invalid = eval.GetIndices(); if (!invalid.empty()) { const MeshFacetArray& rFaces = _rclMesh.GetFacets(); - for (std::vector::iterator it = invalid.begin(); it != invalid.end(); ++it) { + for (std::vector::iterator it = invalid.begin(); it != invalid.end(); ++it) { MeshFacet& face = const_cast(rFaces[*it]); face._aulPoints[0] = 0; face._aulPoints[1] = 0; @@ -1214,25 +1120,21 @@ bool MeshEvalCorruptedFacets::Evaluate() for ( MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it ) { // dupicated point indices - if ((it->_aulPoints[0] == it->_aulPoints[1]) || - (it->_aulPoints[1] == it->_aulPoints[2]) || - (it->_aulPoints[2] == it->_aulPoints[0])) + if (it->IsDegenerated()) return false; } return true; } -std::vector MeshEvalCorruptedFacets::GetIndices() const +std::vector MeshEvalCorruptedFacets::GetIndices() const { - std::vector aInds; + std::vector aInds; const MeshFacetArray& rFaces = _rclMesh.GetFacets(); - unsigned long ind=0; + FacetIndex ind=0; for ( MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++ ) { - if ((it->_aulPoints[0] == it->_aulPoints[1]) || - (it->_aulPoints[1] == it->_aulPoints[2]) || - (it->_aulPoints[2] == it->_aulPoints[0])) + if (it->IsDegenerated()) aInds.push_back(ind); } @@ -1246,7 +1148,7 @@ bool MeshFixCorruptedFacets::Fixup() MeshFacetIterator it(_rclMesh); for ( it.Init(); it.More(); it.Next() ) { - if ( it->Area() <= FLOAT_EPS ) + if ( it.GetReference().IsDegenerated() ) { unsigned long uId = it.Position(); bool removed = cTopAlg.RemoveCorruptedFacet(uId); @@ -1254,7 +1156,7 @@ bool MeshFixCorruptedFacets::Fixup() // due to a modification of the array the iterator became invalid it.Set(uId-1); } - + } } diff --git a/src/Mod/Mesh/App/Core/Degeneration.h b/src/Mod/Mesh/App/Core/Degeneration.h index 17fdebf24d..fdd6dfc876 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.h +++ b/src/Mod/Mesh/App/Core/Degeneration.h @@ -62,7 +62,7 @@ public: /** * Returns the indices of all invalid facets or facets whose points are invalid. */ - std::vector GetIndices() const; + std::vector GetIndices() const; }; /** @@ -113,7 +113,7 @@ public: /** * Returns the indices of all duplicated points. */ - std::vector GetIndices() const; + std::vector GetIndices() const; }; /** @@ -161,7 +161,7 @@ public: /** * Returns the indices of all NaN points. */ - std::vector GetIndices() const; + std::vector GetIndices() const; }; /** @@ -211,7 +211,7 @@ public: /** * Returns the indices of all duplicated facets. */ - std::vector GetIndices() const; + std::vector GetIndices() const; }; /** @@ -258,11 +258,11 @@ public: /** * Return the indices. */ - const std::vector& GetIndices() const + const std::vector& GetIndices() const { return _indices; } private: - std::vector _indices; + std::vector _indices; }; /** @@ -297,7 +297,7 @@ public: /** * Returns the indices of all corrupt facets. */ - std::vector GetIndices() const; + std::vector GetIndices() const; private: float fEpsilon; @@ -417,7 +417,7 @@ public: /** * Returns the indices of deformed facets. */ - std::vector GetIndices() const; + std::vector GetIndices() const; private: float fMinAngle; /**< If an angle of a facet is lower than fMinAngle it's considered as deformed. */ @@ -493,10 +493,10 @@ public: ~MeshEvalDentsOnSurface() {} bool Evaluate(); - std::vector GetIndices() const; + std::vector GetIndices() const; private: - std::vector indices; + std::vector indices; }; class MeshExport MeshFixDentsOnSurface : public MeshValidation @@ -520,10 +520,10 @@ public: ~MeshEvalFoldsOnSurface() {} bool Evaluate(); - std::vector GetIndices() const; + std::vector GetIndices() const; private: - std::vector indices; + std::vector indices; }; /** @@ -539,10 +539,10 @@ public: ~MeshEvalFoldsOnBoundary() {} bool Evaluate(); - std::vector GetIndices() const; + std::vector GetIndices() const; private: - std::vector indices; + std::vector indices; }; class MeshExport MeshFixFoldsOnBoundary : public MeshValidation @@ -565,11 +565,11 @@ public: ~MeshEvalFoldOversOnSurface() {} bool Evaluate(); - std::vector GetIndices() const + std::vector GetIndices() const { return this->indices; } private: - std::vector indices; + std::vector indices; }; /** @@ -580,13 +580,13 @@ private: class MeshExport MeshEvalBorderFacet : public MeshEvaluation { public: - MeshEvalBorderFacet (const MeshKernel &rclB, std::vector& f) + MeshEvalBorderFacet (const MeshKernel &rclB, std::vector& f) : MeshEvaluation(rclB), _facets(f) {} virtual ~MeshEvalBorderFacet () {} bool Evaluate(); protected: - std::vector& _facets; + std::vector& _facets; }; // ---------------------------------------------------- @@ -618,7 +618,7 @@ public: /** * Returns the indices of all facets with invalid neighbour indices. */ - std::vector GetIndices() const; + std::vector GetIndices() const; }; /** @@ -666,7 +666,7 @@ public: /** * Returns the indices of all facets with invalid point indices. */ - std::vector GetIndices() const; + std::vector GetIndices() const; }; /** @@ -715,7 +715,7 @@ public: /** * Returns the indices of all corrupt facets. */ - std::vector GetIndices() const; + std::vector GetIndices() const; }; /** diff --git a/src/Mod/Mesh/App/Core/Elements.cpp b/src/Mod/Mesh/App/Core/Elements.cpp index 2775fd8d30..3d36923482 100644 --- a/src/Mod/Mesh/App/Core/Elements.cpp +++ b/src/Mod/Mesh/App/Core/Elements.cpp @@ -44,7 +44,7 @@ MeshPointArray::MeshPointArray(const MeshPointArray& ary) { } -unsigned long MeshPointArray::Get (const MeshPoint &rclPoint) +PointIndex MeshPointArray::Get (const MeshPoint &rclPoint) { iterator clIter; @@ -52,17 +52,17 @@ unsigned long MeshPointArray::Get (const MeshPoint &rclPoint) if (clIter != end()) return clIter - begin(); else - return ULONG_MAX; + return POINT_INDEX_MAX; } -unsigned long MeshPointArray::GetOrAddIndex (const MeshPoint &rclPoint) +PointIndex MeshPointArray::GetOrAddIndex (const MeshPoint &rclPoint) { - unsigned long ulIndex; + PointIndex ulIndex; - if ((ulIndex = Get(rclPoint)) == ULONG_MAX) + if ((ulIndex = Get(rclPoint)) == POINT_INDEX_MAX) { push_back(rclPoint); - return static_cast(size() - 1); + return static_cast(size() - 1); } else return ulIndex; @@ -83,7 +83,7 @@ void MeshPointArray::SetProperty (unsigned long ulVal) const for (_TConstIterator pP = begin(); pP != end(); ++pP) pP->SetProperty(ulVal); } -void MeshPointArray::ResetInvalid (void) const +void MeshPointArray::ResetInvalid () const { for (_TConstIterator pP = begin(); pP != end(); ++pP) pP->ResetInvalid(); } @@ -110,9 +110,9 @@ MeshFacetArray::MeshFacetArray(const MeshFacetArray& ary) void MeshFacetArray::Erase (_TIterator pIter) { - unsigned long i, *pulN; + FacetIndex i, *pulN; _TIterator pPass, pEnd; - unsigned long ulInd = pIter - begin(); + FacetIndex ulInd = pIter - begin(); erase(pIter); pPass = begin(); pEnd = end(); @@ -121,14 +121,14 @@ void MeshFacetArray::Erase (_TIterator pIter) for (i = 0; i < 3; i++) { pulN = &pPass->_aulNeighbours[i]; - if ((*pulN > ulInd) && (*pulN != ULONG_MAX)) + if ((*pulN > ulInd) && (*pulN != FACET_INDEX_MAX)) (*pulN)--; } pPass++; } } -void MeshFacetArray::TransposeIndices (unsigned long ulOrig, unsigned long ulNew) +void MeshFacetArray::TransposeIndices (PointIndex ulOrig, PointIndex ulNew) { _TIterator pIter = begin(), pEnd = end(); @@ -139,7 +139,7 @@ void MeshFacetArray::TransposeIndices (unsigned long ulOrig, unsigned long ulNew } } -void MeshFacetArray::DecrementIndices (unsigned long ulIndex) +void MeshFacetArray::DecrementIndices (PointIndex ulIndex) { _TIterator pIter = begin(), pEnd = end(); @@ -165,7 +165,7 @@ void MeshFacetArray::SetProperty (unsigned long ulVal) const for (_TConstIterator pF = begin(); pF != end(); ++pF) pF->SetProperty(ulVal); } -void MeshFacetArray::ResetInvalid (void) const +void MeshFacetArray::ResetInvalid () const { for (_TConstIterator pF = begin(); pF != end(); ++pF) pF->ResetInvalid(); } @@ -352,7 +352,7 @@ void MeshGeomEdge::ClosestPointsToLine(const Base::Vector3f &linePt, const Base: // ----------------------------------------------------------------- -MeshGeomFacet::MeshGeomFacet (void) +MeshGeomFacet::MeshGeomFacet () : _bNormalCalculated(false), _ucFlag(0), _ulProp(0) { @@ -497,7 +497,7 @@ void MeshGeomFacet::Enlarge (float fDist) { Base::Vector3f clM, clU, clV, clPNew[3]; float fA, fD; - unsigned long i, ulP1, ulP2, ulP3; + PointIndex i, ulP1, ulP2, ulP3; for (i = 0; i < 3; i++) { diff --git a/src/Mod/Mesh/App/Core/Elements.h b/src/Mod/Mesh/App/Core/Elements.h index 70a8469272..22c48c4cba 100644 --- a/src/Mod/Mesh/App/Core/Elements.h +++ b/src/Mod/Mesh/App/Core/Elements.h @@ -54,7 +54,7 @@ class MeshExport MeshHelpEdge { public: inline bool operator == (const MeshHelpEdge &rclEdge) const; - unsigned long _ulIndex[2]; // point indices + PointIndex _ulIndex[2]; // point indices }; /** @@ -64,28 +64,28 @@ public: class MeshExport MeshIndexEdge { public: - unsigned long _ulFacetIndex; // Facet index + FacetIndex _ulFacetIndex; // Facet index unsigned short _ausCorner[2]; // corner point indices of the facet }; /** MeshEdge just a pair of two point indices */ -typedef std::pair MeshEdge; +typedef std::pair MeshEdge; struct MeshExport EdgeCollapse { - unsigned long _fromPoint; - unsigned long _toPoint; - std::vector _adjacentFrom; // adjacent points to _fromPoint - std::vector _adjacentTo; // adjacent points to _toPoint - std::vector _removeFacets; - std::vector _changeFacets; + PointIndex _fromPoint; + PointIndex _toPoint; + std::vector _adjacentFrom; // adjacent points to _fromPoint + std::vector _adjacentTo; // adjacent points to _toPoint + std::vector _removeFacets; + std::vector _changeFacets; }; struct MeshExport VertexCollapse { - unsigned long _point; - std::vector _circumPoints; - std::vector _circumFacets; + PointIndex _point; + std::vector _circumPoints; + std::vector _circumFacets; }; /** @@ -108,11 +108,11 @@ public: /** @name Construction */ //@{ - MeshPoint (void) : _ucFlag(0), _ulProp(0) { } + MeshPoint () : _ucFlag(0), _ulProp(0) { } inline MeshPoint (float x, float y, float z); inline MeshPoint (const Base::Vector3f &rclPt); inline MeshPoint (const MeshPoint &rclPt); - ~MeshPoint (void) { } + ~MeshPoint () { } //@} public: @@ -126,11 +126,11 @@ public: { const_cast(this)->_ucFlag &= ~static_cast(tF); } bool IsFlag (TFlagType tF) const { return (_ucFlag & static_cast(tF)) == static_cast(tF); } - void ResetInvalid (void) const + void ResetInvalid () const { ResetFlag(INVALID); } - void SetInvalid (void) const + void SetInvalid () const { SetFlag(INVALID); } - bool IsValid (void) const + bool IsValid () const { return !IsFlag(INVALID); } void SetProperty(unsigned long uP) const { const_cast(this)->_ulProp = uP; } @@ -156,7 +156,7 @@ public: class MeshExport MeshGeomEdge { public: - MeshGeomEdge (void) : _bBorder(false) {} + MeshGeomEdge () : _bBorder(false) {} /** Checks if the edge is inside the bounding box or intersects with it. */ bool ContainedByOrIntersectBoundingBox (const Base::BoundBox3f &rclBB ) const; @@ -199,7 +199,7 @@ public: * \li neighbour or edge number of 0 is defined by corner 0 and 1 * \li neighbour or edge number of 1 is defined by corner 1 and 2 * \li neighbour or edge number of 2 is defined by corner 2 and 0 - * \li neighbour index is set to ULONG_MAX if there is no neighbour facet + * \li neighbour index is set to FACET_INDEX_MAX if there is no neighbour facet * * Note: The status flag SEGMENT mark a facet to be part of certain subset, a segment. * This flag must not be set by any algorithm unless it adds or removes facets to a segment. @@ -215,10 +215,10 @@ public: public: /** @name Construction */ //@{ - inline MeshFacet (void); + inline MeshFacet (); inline MeshFacet(const MeshFacet &rclF); - inline MeshFacet(unsigned long p1,unsigned long p2,unsigned long p3,unsigned long n1=ULONG_MAX,unsigned long n2=ULONG_MAX,unsigned long n3=ULONG_MAX); - ~MeshFacet (void) { } + inline MeshFacet(PointIndex p1,PointIndex p2,PointIndex p3,FacetIndex n1=FACET_INDEX_MAX,FacetIndex n2=FACET_INDEX_MAX,FacetIndex n3=FACET_INDEX_MAX); + ~MeshFacet () { } //@} /** @name Flag state @@ -231,7 +231,7 @@ public: { const_cast(this)->_ucFlag &= ~static_cast(tF); } bool IsFlag (TFlagType tF) const { return (_ucFlag & static_cast(tF)) == static_cast(tF); } - void ResetInvalid (void) const + void ResetInvalid () const { ResetFlag(INVALID); } void SetProperty(unsigned long uP) const { const_cast(this)->_ulProp = uP; } @@ -240,16 +240,16 @@ public: * (e.g. deletion of several facets) but must not be set permanently. * From outside the data-structure must not have invalid facets. */ - void SetInvalid (void) const + void SetInvalid () const { SetFlag(INVALID); } - bool IsValid (void) const + bool IsValid () const { return !IsFlag(INVALID); } //@} // Assignment inline MeshFacet& operator = (const MeshFacet &rclF); - inline void SetVertices(unsigned long,unsigned long,unsigned long); - inline void SetNeighbours(unsigned long,unsigned long,unsigned long); + inline void SetVertices(PointIndex,PointIndex,PointIndex); + inline void SetNeighbours(FacetIndex,FacetIndex,FacetIndex); /** * Returns the indices of the corner points of the given edge number. @@ -258,17 +258,17 @@ public: /** * Returns the indices of the corner points of the given edge number. */ - inline std::pair GetEdge (unsigned short usSide) const; + inline std::pair GetEdge (unsigned short usSide) const; /** * Returns the edge-number to the given index of neighbour facet. * If \a ulNIndex is not a neighbour USHRT_MAX is returned. */ - inline unsigned short Side (unsigned long ulNIndex) const; + inline unsigned short Side (FacetIndex ulNIndex) const; /** * Returns the edge-number defined by two points. If one point is * not a corner point USHRT_MAX is returned. */ - inline unsigned short Side (unsigned long ulP0, unsigned long P1) const; + inline unsigned short Side (PointIndex ulP0, PointIndex P1) const; /** * Returns the edge-number defined by the shared edge of both facets. If the facets don't * share a common edge USHRT_MAX is returned. @@ -284,26 +284,26 @@ public: * by \a ulNew. If the facet does not have a corner point with this index * nothing happens. */ - inline void Transpose (unsigned long ulOrig, unsigned long ulNew); + inline void Transpose (PointIndex ulOrig, PointIndex ulNew); /** * Decrement the index for each corner point that is higher than \a ulIndex. */ - inline void Decrement (unsigned long ulIndex); + inline void Decrement (PointIndex ulIndex); /** * Checks if the facets references the given point index. */ - inline bool HasPoint(unsigned long) const; + inline bool HasPoint(PointIndex) const; /** * Replaces the index of the neighbour facet that is equal to \a ulOrig * by \a ulNew. If the facet does not have a neighbourt with this index * nothing happens. */ - inline void ReplaceNeighbour (unsigned long ulOrig, unsigned long ulNew); + inline void ReplaceNeighbour (FacetIndex ulOrig, FacetIndex ulNew); /** * Checks if the neighbour exists at the given edge-number. */ bool HasNeighbour (unsigned short usSide) const - { return (_aulNeighbours[usSide] != ULONG_MAX); } + { return (_aulNeighbours[usSide] != FACET_INDEX_MAX); } /** Counts the number of edges without neighbour. */ inline unsigned short CountOpenEdges() const; /** Returns true if there is an edge without neighbour, otherwise false. */ @@ -315,7 +315,7 @@ public: /** Checks whether the facet is degenerated to a line of point. */ inline bool IsDegenerated() const; /** Flips the orientation of the facet. */ - void FlipNormal (void) + void FlipNormal () { std::swap(_aulPoints[1], _aulPoints[2]); std::swap(_aulNeighbours[0], _aulNeighbours[2]); @@ -324,8 +324,8 @@ public: public: unsigned char _ucFlag; /**< Flag member. */ unsigned long _ulProp; /**< Free usable property. */ - unsigned long _aulPoints[3]; /**< Indices of corner points. */ - unsigned long _aulNeighbours[3]; /**< Indices of neighbour facets. */ + PointIndex _aulPoints[3]; /**< Indices of corner points. */ + FacetIndex _aulNeighbours[3]; /**< Indices of neighbour facets. */ }; /** @@ -338,11 +338,11 @@ public: /** @name Construction */ //@{ /// default constructor - MeshGeomFacet (void); + MeshGeomFacet (); /// Constructor with the corner points MeshGeomFacet (const Base::Vector3f &v1,const Base::Vector3f &v2,const Base::Vector3f &v3); /// Destruction - ~MeshGeomFacet (void) { } + ~MeshGeomFacet () { } //@} public: @@ -403,7 +403,7 @@ public: /** * Calculates the facet normal for storing internally. */ - inline void CalcNormal (void); + inline void CalcNormal (); /** * Arrange the facet normal so the both vectors have the same orientation. */ @@ -411,9 +411,9 @@ public: /** * Adjusts the facet's orientation to its normal. */ - inline void AdjustCirculationDirection (void); + inline void AdjustCirculationDirection (); /** Invalidate the normal. It will be recomputed when querying it. */ - void NormalInvalid (void) { _bNormalCalculated = false; } + void NormalInvalid () { _bNormalCalculated = false; } /** Query the flag state of the facet. */ bool IsFlag (MeshFacet::TFlagType tF) const { return (_ucFlag & static_cast(tF)) == static_cast(tF); } @@ -424,13 +424,13 @@ public: void ResetFlag (MeshFacet::TFlagType tF) { _ucFlag &= ~static_cast(tF); } /** Calculates the facet's gravity point. */ - inline Base::Vector3f GetGravityPoint (void) const; + inline Base::Vector3f GetGravityPoint () const; /** Returns the normal of the facet. */ - inline Base::Vector3f GetNormal (void) const; + inline Base::Vector3f GetNormal () const; /** Sets the facet's normal. */ inline void SetNormal (const Base::Vector3f &rclNormal); /** Returns the wrapping bounding box. */ - inline Base::BoundBox3f GetBoundBox (void) const; + inline Base::BoundBox3f GetBoundBox () const; /** Calculates the perimeter of the facet. */ inline float Perimeter() const; /** Calculates the area of a facet. */ @@ -545,13 +545,13 @@ public: /** @name Construction */ //@{ // constructor - MeshPointArray (void) { } + MeshPointArray () { } // constructor - MeshPointArray (unsigned long ulSize) : TMeshPointArray(ulSize) { } + MeshPointArray (PointIndex ulSize) : TMeshPointArray(ulSize) { } /// copy-constructor MeshPointArray (const MeshPointArray&); // Destructor - ~MeshPointArray (void) { } + ~MeshPointArray () { } //@} /** @name Flag state @@ -563,7 +563,7 @@ public: /// Resets the flag for all points void ResetFlag (MeshPoint::TFlagType tF) const; /// Sets all points invalid - void ResetInvalid (void) const; + void ResetInvalid () const; /// Sets the property for all points void SetProperty (unsigned long ulVal) const; //@} @@ -573,15 +573,15 @@ public: void Transform(const Base::Matrix4D&); /** * Searches for the first point index Two points are equal if the distance is less - * than EPSILON. If no such points is found ULONG_MAX is returned. + * than EPSILON. If no such points is found POINT_INDEX_MAX is returned. */ - unsigned long Get (const MeshPoint &rclPoint); + PointIndex Get (const MeshPoint &rclPoint); /** * Searches for the first point index Two points are equal if the distance is less * than EPSILON. If no such points is found the point is added to the array at end * and its index is returned. */ - unsigned long GetOrAddIndex (const MeshPoint &rclPoint); + PointIndex GetOrAddIndex (const MeshPoint &rclPoint); }; typedef std::vector TMeshFacetArray; @@ -599,13 +599,13 @@ public: /** @name Construction */ //@{ /// constructor - MeshFacetArray (void) { } + MeshFacetArray () { } /// constructor - MeshFacetArray (unsigned long ulSize) : TMeshFacetArray(ulSize) { } + MeshFacetArray (FacetIndex ulSize) : TMeshFacetArray(ulSize) { } /// copy-constructor MeshFacetArray (const MeshFacetArray&); /// destructor - ~MeshFacetArray (void) { } + ~MeshFacetArray () { } //@} /** @name Flag state @@ -618,7 +618,7 @@ public: /// Resets the flag for all facets. void ResetFlag (MeshFacet::TFlagType tF) const; /// Sets all facets invalid - void ResetInvalid (void) const; + void ResetInvalid () const; /// Sets the property for all facets void SetProperty (unsigned long ulVal) const; //@} @@ -634,11 +634,11 @@ public: /** * Checks and flips the point indices if needed. @see MeshFacet::Transpose(). */ - void TransposeIndices (unsigned long ulOrig, unsigned long ulNew); + void TransposeIndices (PointIndex ulOrig, PointIndex ulNew); /** * Decrements all point indices that are higher than \a ulIndex. */ - void DecrementIndices (unsigned long ulIndex); + void DecrementIndices (PointIndex ulIndex); }; /** @@ -684,7 +684,7 @@ public: * that is equal to \a old by \a now. If the facet does not have a corner * point with this index nothing happens. */ - void Transpose(unsigned long pos, unsigned long old, unsigned long now) + void Transpose(PointIndex pos, PointIndex old, PointIndex now) { rFacets[pos].Transpose(old, now); } @@ -765,14 +765,14 @@ inline float MeshGeomFacet::DistancePlaneToPoint (const Base::Vector3f &rclPoint return float(fabs(rclPoint.DistanceToPlane(_aclPoints[0], GetNormal()))); } -inline void MeshGeomFacet::CalcNormal (void) +inline void MeshGeomFacet::CalcNormal () { _clNormal = (_aclPoints[1] - _aclPoints[0]) % (_aclPoints[2] - _aclPoints[0]); _clNormal.Normalize(); _bNormalCalculated = true; } -inline Base::Vector3f MeshGeomFacet::GetNormal (void) const +inline Base::Vector3f MeshGeomFacet::GetNormal () const { if (_bNormalCalculated == false) const_cast(this)->CalcNormal(); @@ -795,19 +795,19 @@ inline void MeshGeomFacet::ArrangeNormal (const Base::Vector3f &rclN) _clNormal = -_clNormal; } -inline Base::Vector3f MeshGeomFacet::GetGravityPoint (void) const +inline Base::Vector3f MeshGeomFacet::GetGravityPoint () const { return (1.0f / 3.0f) * (_aclPoints[0] + _aclPoints[1] + _aclPoints[2]); } -inline void MeshGeomFacet::AdjustCirculationDirection (void) +inline void MeshGeomFacet::AdjustCirculationDirection () { Base::Vector3f clN = (_aclPoints[1] - _aclPoints[0]) % (_aclPoints[2] - _aclPoints[0]); if ((clN * _clNormal) < 0.0f) std::swap(_aclPoints[1], _aclPoints[2]); } -inline Base::BoundBox3f MeshGeomFacet::GetBoundBox (void) const +inline Base::BoundBox3f MeshGeomFacet::GetBoundBox () const { return Base::BoundBox3f(_aclPoints, 3); } @@ -857,12 +857,12 @@ inline bool MeshGeomFacet::IntersectWithPlane (const Base::Vector3f &rclBase, co (bD0 == (_aclPoints[2].DistanceToPlane(rclBase, rclNormal) > 0.0f))); } -inline MeshFacet::MeshFacet (void) +inline MeshFacet::MeshFacet () : _ucFlag(0), _ulProp(0) { - memset(_aulNeighbours, 0xff, sizeof(unsigned long) * 3); - memset(_aulPoints, 0xff, sizeof(unsigned long) * 3); + memset(_aulNeighbours, 0xff, sizeof(FacetIndex) * 3); + memset(_aulPoints, 0xff, sizeof(PointIndex) * 3); } inline MeshFacet::MeshFacet(const MeshFacet &rclF) @@ -878,8 +878,8 @@ inline MeshFacet::MeshFacet(const MeshFacet &rclF) _aulNeighbours[2] = rclF._aulNeighbours[2]; } -inline MeshFacet::MeshFacet(unsigned long p1,unsigned long p2,unsigned long p3, - unsigned long n1,unsigned long n2,unsigned long n3) +inline MeshFacet::MeshFacet(PointIndex p1,PointIndex p2,PointIndex p3, + FacetIndex n1,FacetIndex n2,FacetIndex n3) : _ucFlag(0), _ulProp(0) { @@ -908,14 +908,14 @@ inline MeshFacet& MeshFacet::operator = (const MeshFacet &rclF) return *this; } -void MeshFacet::SetVertices(unsigned long p1,unsigned long p2,unsigned long p3) +void MeshFacet::SetVertices(PointIndex p1,PointIndex p2,PointIndex p3) { _aulPoints[0] = p1; _aulPoints[1] = p2; _aulPoints[2] = p3; } -void MeshFacet::SetNeighbours(unsigned long n1,unsigned long n2,unsigned long n3) +void MeshFacet::SetNeighbours(FacetIndex n1,FacetIndex n2,FacetIndex n3) { _aulNeighbours[0] = n1; _aulNeighbours[1] = n2; @@ -928,12 +928,12 @@ inline void MeshFacet::GetEdge (unsigned short usSide, MeshHelpEdge &rclEdge) co rclEdge._ulIndex[1] = _aulPoints[(usSide+1) % 3]; } -inline std::pair MeshFacet::GetEdge (unsigned short usSide) const +inline std::pair MeshFacet::GetEdge (unsigned short usSide) const { - return std::pair(_aulPoints[usSide], _aulPoints[(usSide+1)%3]); + return std::pair(_aulPoints[usSide], _aulPoints[(usSide+1)%3]); } -inline void MeshFacet::Transpose (unsigned long ulOrig, unsigned long ulNew) +inline void MeshFacet::Transpose (PointIndex ulOrig, PointIndex ulNew) { if (_aulPoints[0] == ulOrig) _aulPoints[0] = ulNew; @@ -943,14 +943,14 @@ inline void MeshFacet::Transpose (unsigned long ulOrig, unsigned long ulNew) _aulPoints[2] = ulNew; } -inline void MeshFacet::Decrement (unsigned long ulIndex) +inline void MeshFacet::Decrement (PointIndex ulIndex) { if (_aulPoints[0] > ulIndex) _aulPoints[0]--; if (_aulPoints[1] > ulIndex) _aulPoints[1]--; if (_aulPoints[2] > ulIndex) _aulPoints[2]--; } -inline bool MeshFacet::HasPoint(unsigned long ulIndex) const +inline bool MeshFacet::HasPoint(PointIndex ulIndex) const { if (_aulPoints[0] == ulIndex) return true; @@ -961,7 +961,7 @@ inline bool MeshFacet::HasPoint(unsigned long ulIndex) const return false; } -inline void MeshFacet::ReplaceNeighbour (unsigned long ulOrig, unsigned long ulNew) +inline void MeshFacet::ReplaceNeighbour (FacetIndex ulOrig, FacetIndex ulNew) { if (_aulNeighbours[0] == ulOrig) _aulNeighbours[0] = ulNew; @@ -1011,7 +1011,7 @@ inline bool MeshFacet::IsDegenerated() const return false; } -inline unsigned short MeshFacet::Side (unsigned long ulNIndex) const +inline unsigned short MeshFacet::Side (FacetIndex ulNIndex) const { if (_aulNeighbours[0] == ulNIndex) return 0; @@ -1023,7 +1023,7 @@ inline unsigned short MeshFacet::Side (unsigned long ulNIndex) const return USHRT_MAX; } -inline unsigned short MeshFacet::Side (unsigned long ulP0, unsigned long ulP1) const +inline unsigned short MeshFacet::Side (PointIndex ulP0, PointIndex ulP1) const { if (_aulPoints[0] == ulP0) { if (_aulPoints[1] == ulP1) diff --git a/src/Mod/Mesh/App/Core/Evaluation.cpp b/src/Mod/Mesh/App/Core/Evaluation.cpp index 440e538fd3..3977282438 100644 --- a/src/Mod/Mesh/App/Core/Evaluation.cpp +++ b/src/Mod/Mesh/App/Core/Evaluation.cpp @@ -52,7 +52,7 @@ MeshOrientationVisitor::MeshOrientationVisitor() : _nonuniformOrientation(false) } bool MeshOrientationVisitor::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, - unsigned long ulFInd, unsigned long ulLevel) + FacetIndex ulFInd, unsigned long ulLevel) { (void)ulFInd; (void)ulLevel; @@ -69,13 +69,13 @@ bool MeshOrientationVisitor::HasNonUnifomOrientedFacets() const return _nonuniformOrientation; } -MeshOrientationCollector::MeshOrientationCollector(std::vector& aulIndices, std::vector& aulComplement) +MeshOrientationCollector::MeshOrientationCollector(std::vector& aulIndices, std::vector& aulComplement) : _aulIndices(aulIndices), _aulComplement(aulComplement) { } bool MeshOrientationCollector::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, - unsigned long ulFInd, unsigned long ulLevel) + FacetIndex ulFInd, unsigned long ulLevel) { (void)ulLevel; // different orientation of rclFacet and rclFrom @@ -104,13 +104,13 @@ bool MeshOrientationCollector::Visit (const MeshFacet &rclFacet, const MeshFacet return true; } -MeshSameOrientationCollector::MeshSameOrientationCollector(std::vector& aulIndices) +MeshSameOrientationCollector::MeshSameOrientationCollector(std::vector& aulIndices) : _aulIndices(aulIndices) { } bool MeshSameOrientationCollector::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, - unsigned long ulFInd, unsigned long ulLevel) + FacetIndex ulFInd, unsigned long ulLevel) { // different orientation of rclFacet and rclFrom (void)ulLevel; @@ -139,7 +139,7 @@ bool MeshEvalOrientation::Evaluate () MeshFacetArray::_TConstIterator iEnd = rFAry.end(); for (MeshFacetArray::_TConstIterator it = iBeg; it != iEnd; ++it) { for (int i = 0; i < 3; i++) { - if (it->_aulNeighbours[i] != ULONG_MAX) { + if (it->_aulNeighbours[i] != FACET_INDEX_MAX) { const MeshFacet& rclFacet = iBeg[it->_aulNeighbours[i]]; for (int j = 0; j < 3; j++) { if (it->_aulPoints[i] == rclFacet._aulPoints[j]) { @@ -156,7 +156,7 @@ bool MeshEvalOrientation::Evaluate () return true; } -unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector& inds) const +unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector& inds) const { // All faces with wrong orientation (i.e. adjacent faces with a normal flip and their neighbours) // build a segment and are marked as TMP0. Now we check all border faces of the segments with @@ -166,10 +166,10 @@ unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { + for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { const MeshFacet& f = iBeg[*it]; for (int i = 0; i < 3; i++) { - if (f._aulNeighbours[i] != ULONG_MAX) { + if (f._aulNeighbours[i] != FACET_INDEX_MAX) { const MeshFacet& n = iBeg[f._aulNeighbours[i]]; if (f.IsFlag(MeshFacet::TMP0) && !n.IsFlag(MeshFacet::TMP0)) { for (int j = 0; j < 3; j++) { @@ -183,15 +183,15 @@ unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector MeshEvalOrientation::GetIndices() const +std::vector MeshEvalOrientation::GetIndices() const { - unsigned long ulStartFacet, ulVisited; + FacetIndex ulStartFacet, ulVisited; if (_rclMesh.CountFacets() == 0) - return std::vector(); + return std::vector(); // reset VISIT flags MeshAlgorithm cAlg(_rclMesh); @@ -205,10 +205,10 @@ std::vector MeshEvalOrientation::GetIndices() const ulStartFacet = 0; - std::vector uIndices, uComplement; + std::vector uIndices, uComplement; MeshOrientationCollector clHarmonizer(uIndices, uComplement); - while (ulStartFacet != ULONG_MAX) { + while (ulStartFacet != FACET_INDEX_MAX) { unsigned long wrongFacets = uIndices.size(); uComplement.clear(); @@ -234,7 +234,7 @@ std::vector MeshEvalOrientation::GetIndices() const if (iTri < iEnd) ulStartFacet = iTri - iBeg; else - ulStartFacet = ULONG_MAX; + ulStartFacet = FACET_INDEX_MAX; } // in some very rare cases where we have some strange artifacts in the mesh structure @@ -242,23 +242,23 @@ std::vector MeshEvalOrientation::GetIndices() const cAlg.ResetFacetFlag(MeshFacet::TMP0); cAlg.SetFacetsFlag(uIndices, MeshFacet::TMP0); ulStartFacet = HasFalsePositives(uIndices); - while (ulStartFacet != ULONG_MAX) { + while (ulStartFacet != FACET_INDEX_MAX) { cAlg.ResetFacetsFlag(uIndices, MeshFacet::VISIT); - std::vector falsePos; + std::vector falsePos; MeshSameOrientationCollector coll(falsePos); _rclMesh.VisitNeighbourFacets(coll, ulStartFacet); std::sort(uIndices.begin(), uIndices.end()); std::sort(falsePos.begin(), falsePos.end()); - std::vector diff; - std::back_insert_iterator > biit(diff); + std::vector diff; + std::back_insert_iterator > biit(diff); std::set_difference(uIndices.begin(), uIndices.end(), falsePos.begin(), falsePos.end(), biit); uIndices = diff; cAlg.ResetFacetFlag(MeshFacet::TMP0); cAlg.SetFacetsFlag(uIndices, MeshFacet::TMP0); - unsigned long current = ulStartFacet; + FacetIndex current = ulStartFacet; ulStartFacet = HasFalsePositives(uIndices); if (current == ulStartFacet) break; // avoid an endless loop @@ -312,7 +312,8 @@ namespace MeshCore { struct Edge_Index { - unsigned long p0, p1, f; + PointIndex p0, p1; + FacetIndex f; }; struct Edge_Less @@ -347,8 +348,8 @@ bool MeshEvalTopology::Evaluate () for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) { for (int i = 0; i < 3; i++) { Edge_Index item; - item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); item.f = pI - rclFAry.begin(); edges.push_back(item); } @@ -360,12 +361,12 @@ bool MeshEvalTopology::Evaluate () std::sort(edges.begin(), edges.end(), Edge_Less()); // search for non-manifold edges - unsigned long p0 = ULONG_MAX, p1 = ULONG_MAX; + PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX; nonManifoldList.clear(); nonManifoldFacets.clear(); int count = 0; - std::vector facets; + std::vector facets; std::vector::iterator pE; for (pE = edges.begin(); pE != edges.end(); ++pE) { if (p0 == pE->p0 && p1 == pE->p1) { @@ -391,7 +392,7 @@ bool MeshEvalTopology::Evaluate () } // generate indexed edge list which tangents non-manifolds -void MeshEvalTopology::GetFacetManifolds (std::vector &raclFacetIndList) const +void MeshEvalTopology::GetFacetManifolds (std::vector &raclFacetIndList) const { raclFacetIndList.clear(); const MeshFacetArray& rclFAry = _rclMesh.GetFacets(); @@ -399,9 +400,9 @@ void MeshEvalTopology::GetFacetManifolds (std::vector &raclFacetI for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) { for (int i = 0; i < 3; i++) { - unsigned long ulPt0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - unsigned long ulPt1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - std::pair edge = std::make_pair(ulPt0, ulPt1); + PointIndex ulPt0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + PointIndex ulPt1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + std::pair edge = std::make_pair(ulPt0, ulPt1); if (std::find(nonManifoldList.begin(), nonManifoldList.end(), edge) != nonManifoldList.end()) raclFacetIndList.push_back(pI - rclFAry.begin()); @@ -430,11 +431,11 @@ bool MeshFixTopology::Fixup () #else const MeshFacetArray& rFaces = _rclMesh.GetFacets(); deletedFaces.reserve(3 * nonManifoldList.size()); // allocate some memory - std::list >::const_iterator it; + std::list >::const_iterator it; for (it = nonManifoldList.begin(); it != nonManifoldList.end(); ++it) { - std::vector non_mf; + std::vector non_mf; non_mf.reserve(it->size()); - for (std::vector::const_iterator jt = it->begin(); jt != it->end(); ++jt) { + for (std::vector::const_iterator jt = it->begin(); jt != it->end(); ++jt) { // facet is only connected with one edge and there causes a non-manifold unsigned short numOpenEdges = rFaces[*jt].CountOpenEdges(); if (numOpenEdges == 2) @@ -474,10 +475,10 @@ bool MeshEvalPointManifolds::Evaluate () MeshCore::MeshRefPointToFacets vf_it(_rclMesh); unsigned long ctPoints = _rclMesh.CountPoints(); - for (unsigned long index=0; index < ctPoints; index++) { + for (PointIndex index=0; index < ctPoints; index++) { // get the local neighbourhood of the point - const std::set& nf = vf_it[index]; - const std::set& np = vv_it[index]; + const std::set& nf = vf_it[index]; + const std::set& np = vv_it[index]; std::set::size_type sp, sf; sp = np.size(); @@ -487,7 +488,7 @@ bool MeshEvalPointManifolds::Evaluate () // for a non-manifold point the number of adjacent points is higher by more than one than the number of shared faces if (sp > sf + 1) { nonManifoldPoints.push_back(index); - std::vector faces; + std::vector faces; faces.insert(faces.end(), nf.begin(), nf.end()); this->facetsOfNonManifoldPoints.push_back(faces); } @@ -496,9 +497,9 @@ bool MeshEvalPointManifolds::Evaluate () return this->nonManifoldPoints.empty(); } -void MeshEvalPointManifolds::GetFacetIndices (std::vector &facets) const +void MeshEvalPointManifolds::GetFacetIndices (std::vector &facets) const { - std::list >::const_iterator it; + std::list >::const_iterator it; for (it = facetsOfNonManifoldPoints.begin(); it != facetsOfNonManifoldPoints.end(); ++it) { facets.insert(facets.end(), it->begin(), it->end()); } @@ -576,11 +577,11 @@ bool MeshEvalSingleFacet::Evaluate () bool MeshFixSingleFacet::Fixup () { - std::vector aulInvalids; + std::vector aulInvalids; // MeshFacetArray& raFacets = _rclMesh._aclFacetArray; - for ( std::vector >::const_iterator it=_raclManifoldList.begin();it!=_raclManifoldList.end();++it ) + for ( std::vector >::const_iterator it=_raclManifoldList.begin();it!=_raclManifoldList.end();++it ) { - for ( std::list::const_iterator it2 = it->begin(); it2 != it->end(); ++it2 ) + for ( std::list::const_iterator it2 = it->begin(); it2 != it->end(); ++it2 ) { aulInvalids.push_back(*it2); // MeshFacet& rF = raFacets[*it2]; @@ -614,7 +615,7 @@ bool MeshEvalSelfIntersection::Evaluate () Base::SequencerLauncher seq("Checking for self-intersections...", ulGridX*ulGridY*ulGridZ); for (clGridIter.Init(); clGridIter.More(); clGridIter.Next()) { //Get the facet indices, belonging to the current grid unit - std::vector aulGridElements; + std::vector aulGridElements; clGridIter.GetElements(aulGridElements); seq.next(); @@ -623,12 +624,12 @@ bool MeshEvalSelfIntersection::Evaluate () MeshGeomFacet facet1, facet2; Base::Vector3f pt1, pt2; - for (std::vector::iterator it = aulGridElements.begin(); it != aulGridElements.end(); ++it) { + for (std::vector::iterator it = aulGridElements.begin(); it != aulGridElements.end(); ++it) { const Base::BoundBox3f& box1 = boxes[*it]; cMFI.Set(*it); facet1 = *cMFI; const MeshFacet& rface1 = rFaces[*it]; - for (std::vector::iterator jt = it; jt != aulGridElements.end(); ++jt) { + for (std::vector::iterator jt = it; jt != aulGridElements.end(); ++jt) { if (jt == it) // the identical facet continue; // If the facets share a common vertex we do not check for self-intersections because they @@ -665,7 +666,7 @@ bool MeshEvalSelfIntersection::Evaluate () return true; } -void MeshEvalSelfIntersection::GetIntersections(const std::vector >& indices, +void MeshEvalSelfIntersection::GetIntersections(const std::vector >& indices, std::vector >& intersection) const { intersection.reserve(indices.size()); @@ -673,7 +674,7 @@ void MeshEvalSelfIntersection::GetIntersections(const std::vector >::const_iterator it; + std::vector >::const_iterator it; for (it = indices.begin(); it != indices.end(); ++it) { cMF1.Set(it->first); cMF2.Set(it->second); @@ -689,7 +690,7 @@ void MeshEvalSelfIntersection::GetIntersections(const std::vector >& intersection) const +void MeshEvalSelfIntersection::GetIntersections(std::vector >& intersection) const { // Contains bounding boxes for every facet std::vector boxes; @@ -711,7 +712,7 @@ void MeshEvalSelfIntersection::GetIntersections(std::vector aulGridElements; + std::vector aulGridElements; clGridIter.GetElements(aulGridElements); seq.next(true); @@ -720,12 +721,12 @@ void MeshEvalSelfIntersection::GetIntersections(std::vector::iterator it = aulGridElements.begin(); it != aulGridElements.end(); ++it) { + for (std::vector::iterator it = aulGridElements.begin(); it != aulGridElements.end(); ++it) { const Base::BoundBox3f& box1 = boxes[*it]; cMFI.Set(*it); facet1 = *cMFI; const MeshFacet& rface1 = rFaces[*it]; - for (std::vector::iterator jt = it; jt != aulGridElements.end(); ++jt) { + for (std::vector::iterator jt = it; jt != aulGridElements.end(); ++jt) { if (jt == it) // the identical facet continue; // If the facets share a common vertex we do not check for self-intersections because they @@ -759,11 +760,11 @@ void MeshEvalSelfIntersection::GetIntersections(std::vector MeshFixSelfIntersection::GetFacets() const +std::vector MeshFixSelfIntersection::GetFacets() const { - std::vector indices; + std::vector indices; const MeshFacetArray& rFaces = _rclMesh.GetFacets(); - for (std::vector >::const_iterator + for (std::vector >::const_iterator it = selfIntersectons.begin(); it != selfIntersectons.end(); ++it) { unsigned short numOpenEdges1 = rFaces[it->first].CountOpenEdges(); unsigned short numOpenEdges2 = rFaces[it->second].CountOpenEdges(); @@ -819,8 +820,8 @@ bool MeshEvalNeighbourhood::Evaluate () for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) { for (int i = 0; i < 3; i++) { Edge_Index item; - item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); item.f = pI - rclFAry.begin(); edges.push_back(item); } @@ -831,8 +832,8 @@ bool MeshEvalNeighbourhood::Evaluate () // sort the edges std::sort(edges.begin(), edges.end(), Edge_Less()); - unsigned long p0 = ULONG_MAX, p1 = ULONG_MAX; - unsigned long f0 = ULONG_MAX, f1 = ULONG_MAX; + PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX; + PointIndex f0 = FACET_INDEX_MAX, f1 = FACET_INDEX_MAX; int count = 0; std::vector::iterator pE; for (pE = edges.begin(); pE != edges.end(); ++pE) { @@ -858,7 +859,7 @@ bool MeshEvalNeighbourhood::Evaluate () const MeshFacet& rFace = rclFAry[f0]; unsigned short side = rFace.Side(p0,p1); // should be "open edge" but isn't marked as such - if (rFace._aulNeighbours[side] != ULONG_MAX) + if (rFace._aulNeighbours[side] != FACET_INDEX_MAX) return false; } @@ -872,9 +873,9 @@ bool MeshEvalNeighbourhood::Evaluate () return true; } -std::vector MeshEvalNeighbourhood::GetIndices() const +std::vector MeshEvalNeighbourhood::GetIndices() const { - std::vector inds; + std::vector inds; const MeshFacetArray& rclFAry = _rclMesh.GetFacets(); std::vector edges; edges.reserve(3*rclFAry.size()); @@ -885,8 +886,8 @@ std::vector MeshEvalNeighbourhood::GetIndices() const for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) { for (int i = 0; i < 3; i++) { Edge_Index item; - item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); item.f = pI - rclFAry.begin(); edges.push_back(item); } @@ -897,8 +898,8 @@ std::vector MeshEvalNeighbourhood::GetIndices() const // sort the edges std::sort(edges.begin(), edges.end(), Edge_Less()); - unsigned long p0 = ULONG_MAX, p1 = ULONG_MAX; - unsigned long f0 = ULONG_MAX, f1 = ULONG_MAX; + PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX; + PointIndex f0 = FACET_INDEX_MAX, f1 = FACET_INDEX_MAX; int count = 0; std::vector::iterator pE; for (pE = edges.begin(); pE != edges.end(); ++pE) { @@ -926,7 +927,7 @@ std::vector MeshEvalNeighbourhood::GetIndices() const const MeshFacet& rFace = rclFAry[f0]; unsigned short side = rFace.Side(p0,p1); // should be "open edge" but isn't marked as such - if (rFace._aulNeighbours[side] != ULONG_MAX) + if (rFace._aulNeighbours[side] != FACET_INDEX_MAX) inds.push_back(f0); } @@ -950,7 +951,7 @@ bool MeshFixNeighbourhood::Fixup() return true; } -void MeshKernel::RebuildNeighbours (unsigned long index) +void MeshKernel::RebuildNeighbours (FacetIndex index) { std::vector edges; edges.reserve(3 * (this->_aclFacetArray.size() - index)); @@ -961,8 +962,8 @@ void MeshKernel::RebuildNeighbours (unsigned long index) for (pI = pB + index; pI != this->_aclFacetArray.end(); ++pI) { for (int i = 0; i < 3; i++) { Edge_Index item; - item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); item.f = pI - pB; edges.push_back(item); } @@ -973,8 +974,8 @@ void MeshKernel::RebuildNeighbours (unsigned long index) int threads = std::max(1, QThread::idealThreadCount()); MeshCore::parallel_sort(edges.begin(), edges.end(), Edge_Less(), threads); - unsigned long p0 = ULONG_MAX, p1 = ULONG_MAX; - unsigned long f0 = ULONG_MAX, f1 = ULONG_MAX; + PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX; + PointIndex f0 = FACET_INDEX_MAX, f1 = FACET_INDEX_MAX; int count = 0; std::vector::iterator pE; for (pE = edges.begin(); pE != edges.end(); ++pE) { @@ -996,7 +997,7 @@ void MeshKernel::RebuildNeighbours (unsigned long index) else if (count == 1) { MeshFacet& rFace = this->_aclFacetArray[f0]; unsigned short side = rFace.Side(p0,p1); - rFace._aulNeighbours[side] = ULONG_MAX; + rFace._aulNeighbours[side] = FACET_INDEX_MAX; } p0 = pE->p0; @@ -1019,11 +1020,11 @@ void MeshKernel::RebuildNeighbours (unsigned long index) else if (count == 1) { MeshFacet& rFace = this->_aclFacetArray[f0]; unsigned short side = rFace.Side(p0,p1); - rFace._aulNeighbours[side] = ULONG_MAX; + rFace._aulNeighbours[side] = FACET_INDEX_MAX; } } -void MeshKernel::RebuildNeighbours (void) +void MeshKernel::RebuildNeighbours () { // complete rebuild RebuildNeighbours(0); diff --git a/src/Mod/Mesh/App/Core/Evaluation.h b/src/Mod/Mesh/App/Core/Evaluation.h index 0f5573340e..cc9b34e5d7 100644 --- a/src/Mod/Mesh/App/Core/Evaluation.h +++ b/src/Mod/Mesh/App/Core/Evaluation.h @@ -95,7 +95,7 @@ public: MeshOrientationVisitor(); /** Returns false after the first inconsistence is found, true otherwise. */ - bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long ); + bool Visit (const MeshFacet &, const MeshFacet &, FacetIndex , unsigned long ); bool HasNonUnifomOrientedFacets() const; private: @@ -110,15 +110,15 @@ private: class MeshExport MeshOrientationCollector : public MeshOrientationVisitor { public: - MeshOrientationCollector(std::vector& aulIndices, - std::vector& aulComplement); + MeshOrientationCollector(std::vector& aulIndices, + std::vector& aulComplement); /** Returns always true and collects the indices with wrong orientation. */ - bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long); + bool Visit (const MeshFacet &, const MeshFacet &, FacetIndex , unsigned long); private: - std::vector& _aulIndices; - std::vector& _aulComplement; + std::vector& _aulIndices; + std::vector& _aulComplement; }; /** @@ -127,12 +127,12 @@ private: class MeshExport MeshSameOrientationCollector : public MeshOrientationVisitor { public: - MeshSameOrientationCollector(std::vector& aulIndices); + MeshSameOrientationCollector(std::vector& aulIndices); /** Returns always true and collects the indices with wrong orientation. */ - bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long); + bool Visit (const MeshFacet &, const MeshFacet &, FacetIndex , unsigned long); private: - std::vector& _aulIndices; + std::vector& _aulIndices; }; /** @@ -145,10 +145,10 @@ public: MeshEvalOrientation (const MeshKernel& rclM); ~MeshEvalOrientation(); bool Evaluate (); - std::vector GetIndices() const; + std::vector GetIndices() const; private: - unsigned long HasFalsePositives(const std::vector&) const; + unsigned long HasFalsePositives(const std::vector&) const; }; /** @@ -192,14 +192,14 @@ public: virtual ~MeshEvalTopology () {} virtual bool Evaluate (); - void GetFacetManifolds (std::vector &raclFacetIndList) const; + void GetFacetManifolds (std::vector &raclFacetIndList) const; unsigned long CountManifolds() const; - const std::vector >& GetIndices() const { return nonManifoldList; } - const std::list >& GetFacets() const { return nonManifoldFacets; } + const std::vector >& GetIndices() const { return nonManifoldList; } + const std::list >& GetFacets() const { return nonManifoldFacets; } protected: - std::vector > nonManifoldList; - std::list > nonManifoldFacets; + std::vector > nonManifoldList; + std::list > nonManifoldFacets; }; /** @@ -209,16 +209,16 @@ protected: class MeshExport MeshFixTopology : public MeshValidation { public: - MeshFixTopology (MeshKernel &rclB, const std::list >& mf) + MeshFixTopology (MeshKernel &rclB, const std::list >& mf) : MeshValidation(rclB), nonManifoldList(mf) {} virtual ~MeshFixTopology () {} bool Fixup(); - const std::vector& GetDeletedFaces() const { return deletedFaces; } + const std::vector& GetDeletedFaces() const { return deletedFaces; } protected: - std::vector deletedFaces; - const std::list >& nonManifoldList; + std::vector deletedFaces; + const std::list >& nonManifoldList; }; // ---------------------------------------------------- @@ -236,14 +236,14 @@ public: virtual ~MeshEvalPointManifolds () {} virtual bool Evaluate (); - void GetFacetIndices (std::vector &facets) const; - const std::list >& GetFacetIndices () const { return facetsOfNonManifoldPoints; } - const std::vector& GetIndices() const { return nonManifoldPoints; } + void GetFacetIndices (std::vector &facets) const; + const std::list >& GetFacetIndices () const { return facetsOfNonManifoldPoints; } + const std::vector& GetIndices() const { return nonManifoldPoints; } unsigned long CountManifolds() const { return static_cast(nonManifoldPoints.size()); } protected: - std::vector nonManifoldPoints; - std::list > facetsOfNonManifoldPoints; + std::vector nonManifoldPoints; + std::list > facetsOfNonManifoldPoints; }; // ---------------------------------------------------- @@ -270,13 +270,13 @@ public: class MeshExport MeshFixSingleFacet : public MeshValidation { public: - MeshFixSingleFacet (MeshKernel &rclB, const std::vector >& mf) + MeshFixSingleFacet (MeshKernel &rclB, const std::vector >& mf) : MeshValidation(rclB), _raclManifoldList(mf) {} virtual ~MeshFixSingleFacet () {} bool Fixup(); protected: - const std::vector >& _raclManifoldList; + const std::vector >& _raclManifoldList; }; // ---------------------------------------------------- @@ -293,10 +293,10 @@ public: /// Evaluate the mesh and return if true if there are self intersections bool Evaluate (); /// collect all intersection lines - void GetIntersections(const std::vector >&, + void GetIntersections(const std::vector >&, std::vector >&) const; /// collect the index of all facets with self intersections - void GetIntersections(std::vector >&) const; + void GetIntersections(std::vector >&) const; }; /** @@ -306,14 +306,14 @@ public: class MeshExport MeshFixSelfIntersection : public MeshValidation { public: - MeshFixSelfIntersection (MeshKernel &rclB, const std::vector >& si) + MeshFixSelfIntersection (MeshKernel &rclB, const std::vector >& si) : MeshValidation(rclB), selfIntersectons(si) {} virtual ~MeshFixSelfIntersection () {} - std::vector GetFacets() const; + std::vector GetFacets() const; bool Fixup(); private: - const std::vector >& selfIntersectons; + const std::vector >& selfIntersectons; }; // ---------------------------------------------------- @@ -329,7 +329,7 @@ public: MeshEvalNeighbourhood (const MeshKernel &rclB) : MeshEvaluation(rclB) {} ~MeshEvalNeighbourhood () {} bool Evaluate (); - std::vector GetIndices() const; + std::vector GetIndices() const; }; /** diff --git a/src/Mod/Mesh/App/Core/Grid.cpp b/src/Mod/Mesh/App/Core/Grid.cpp index 4bbc1ce337..cb4572421a 100644 --- a/src/Mod/Mesh/App/Core/Grid.cpp +++ b/src/Mod/Mesh/App/Core/Grid.cpp @@ -45,8 +45,8 @@ MeshGrid::MeshGrid (const MeshKernel &rclM) { } -MeshGrid::MeshGrid (void) -: _pclMesh(NULL), +MeshGrid::MeshGrid () +: _pclMesh(nullptr), _ulCtElements(0), _ulCtGridsX(MESH_CT_GRID), _ulCtGridsY(MESH_CT_GRID), _ulCtGridsZ(MESH_CT_GRID), _fGridLenX(0.0f), _fGridLenY(0.0f), _fGridLenZ(0.0f), @@ -60,10 +60,10 @@ void MeshGrid::Attach (const MeshKernel &rclM) RebuildGrid(); } -void MeshGrid::Clear (void) +void MeshGrid::Clear () { _aulGrid.clear(); - _pclMesh = NULL; + _pclMesh = nullptr; } void MeshGrid::Rebuild (unsigned long ulX, unsigned long ulY, unsigned long ulZ) @@ -89,9 +89,9 @@ void MeshGrid::Rebuild (int iCtGridPerAxis) RebuildGrid(); } -void MeshGrid::InitGrid (void) +void MeshGrid::InitGrid () { - assert(_pclMesh != NULL); + assert(_pclMesh != nullptr); unsigned long i, j; @@ -138,7 +138,7 @@ void MeshGrid::InitGrid (void) } } -unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements, +unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements, bool bDelDoubles) const { unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; @@ -170,7 +170,7 @@ unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements, +unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements, const Base::Vector3f &rclOrg, float fMaxDist, bool bDelDoubles) const { unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; @@ -205,7 +205,7 @@ unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements) const +unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::set &raulElements) const { unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; @@ -450,7 +450,7 @@ void MeshGrid::CalculateGridLength (int iCtGridPerAxis) } } -void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set &raclInd) const +void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set &raclInd) const { raclInd.clear(); Base::BoundBox3f clBB = GetBoundBox(); @@ -563,7 +563,7 @@ void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set &raclInd) const + unsigned long ulDistance, std::set &raclInd) const { int nX1 = std::max(0, int(ulX) - int(ulDistance)); int nY1 = std::max(0, int(ulY) - int(ulDistance)); @@ -643,9 +643,9 @@ void MeshGrid::GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, } unsigned long MeshGrid::GetElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ, - std::set &raclInd) const + std::set &raclInd) const { - const std::set &rclSet = _aulGrid[ulX][ulY][ulZ]; + const std::set &rclSet = _aulGrid[ulX][ulY][ulZ]; if (rclSet.size() > 0) { raclInd.insert(rclSet.begin(), rclSet.end()); @@ -655,7 +655,7 @@ unsigned long MeshGrid::GetElements (unsigned long ulX, unsigned long ulY, unsig return 0; } -unsigned long MeshGrid::GetElements(const Base::Vector3f &rclPoint, std::vector& aulFacets) const +unsigned long MeshGrid::GetElements(const Base::Vector3f &rclPoint, std::vector& aulFacets) const { unsigned long ulX, ulY, ulZ; if (!CheckPosition(rclPoint, ulX, ulY, ulZ)) @@ -728,9 +728,9 @@ void MeshFacetGrid::Validate (const MeshKernel &rclMesh) RebuildGrid(); } -void MeshFacetGrid::Validate (void) +void MeshFacetGrid::Validate () { - if (_pclMesh == NULL) + if (_pclMesh == nullptr) return; if (_pclMesh->CountFacets() != _ulCtElements) @@ -748,9 +748,9 @@ bool MeshFacetGrid::Verify() const MeshFacetIterator cF(*_pclMesh); for ( it.Init(); it.More(); it.Next() ) { - std::vector aulElements; + std::vector aulElements; it.GetElements( aulElements ); - for ( std::vector::iterator itF = aulElements.begin(); itF != aulElements.end(); ++itF ) + for ( std::vector::iterator itF = aulElements.begin(); itF != aulElements.end(); ++itF ) { cF.Set( *itF ); if ( cF->IntersectBoundingBox( it.GetBoundBox() ) == false ) @@ -761,7 +761,7 @@ bool MeshFacetGrid::Verify() const return true; } -void MeshFacetGrid::RebuildGrid (void) +void MeshFacetGrid::RebuildGrid () { _ulCtElements = _pclMesh->CountFacets(); @@ -781,7 +781,7 @@ void MeshFacetGrid::RebuildGrid (void) unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt) const { - unsigned long ulFacetInd = ULONG_MAX; + ElementIndex ulFacetInd = ELEMENT_INDEX_MAX; float fMinDist = FLOAT_MAX; Base::BoundBox3f clBB = GetBoundBox(); @@ -897,8 +897,8 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, float fMaxSearchArea) const { - std::vector aulFacets; - unsigned long ulFacetInd = ULONG_MAX; + std::vector aulFacets; + ElementIndex ulFacetInd = ELEMENT_INDEX_MAX; float fMinDist = fMaxSearchArea; MeshAlgorithm clFTool(*_pclMesh); @@ -908,7 +908,7 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt Inside(clBB, aulFacets, rclPt, fMaxSearchArea, true); - for (std::vector::const_iterator pI = aulFacets.begin(); pI != aulFacets.end(); ++pI) + for (std::vector::const_iterator pI = aulFacets.begin(); pI != aulFacets.end(); ++pI) { float fDist; @@ -924,7 +924,7 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt void MeshFacetGrid::SearchNearestFacetInHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance, const Base::Vector3f &rclPt, - unsigned long &rulFacetInd, float &rfMinDist) const + ElementIndex &rulFacetInd, float &rfMinDist) const { int nX1 = std::max(0, int(ulX) - int(ulDistance)); int nY1 = std::max(0, int(ulY) - int(ulDistance)); @@ -1005,10 +1005,10 @@ void MeshFacetGrid::SearchNearestFacetInHull (unsigned long ulX, unsigned long u void MeshFacetGrid::SearchNearestFacetInGrid(unsigned long ulX, unsigned long ulY, unsigned long ulZ, const Base::Vector3f &rclPt, float &rfMinDist, - unsigned long &rulFacetInd) const + ElementIndex &rulFacetInd) const { - const std::set &rclSet = _aulGrid[ulX][ulY][ulZ]; - for (std::set::const_iterator pI = rclSet.begin(); pI != rclSet.end(); ++pI) + const std::set &rclSet = _aulGrid[ulX][ulY][ulZ]; + for (std::set::const_iterator pI = rclSet.begin(); pI != rclSet.end(); ++pI) { float fDist = _pclMesh->GetFacet(*pI).DistanceToPoint(rclPt); if (fDist < rfMinDist) @@ -1027,7 +1027,7 @@ MeshPointGrid::MeshPointGrid (const MeshKernel &rclM) RebuildGrid(); } -MeshPointGrid::MeshPointGrid (void) +MeshPointGrid::MeshPointGrid () : MeshGrid() { } @@ -1053,7 +1053,7 @@ MeshPointGrid::MeshPointGrid (const MeshKernel &rclM, float fGridLen) std::max(static_cast(clBBMesh.LengthZ() / fGridLen), 1)); } -void MeshPointGrid::AddPoint (const MeshPoint &rclPt, unsigned long ulPtIndex, float fEpsilon) +void MeshPointGrid::AddPoint (const MeshPoint &rclPt, ElementIndex ulPtIndex, float fEpsilon) { (void)fEpsilon; unsigned long ulX, ulY, ulZ; @@ -1070,9 +1070,9 @@ void MeshPointGrid::Validate (const MeshKernel &rclMesh) RebuildGrid(); } -void MeshPointGrid::Validate (void) +void MeshPointGrid::Validate () { - if (_pclMesh == NULL) + if (_pclMesh == nullptr) return; if (_pclMesh->CountPoints() != _ulCtElements) @@ -1090,9 +1090,9 @@ bool MeshPointGrid::Verify() const MeshPointIterator cP(*_pclMesh); for ( it.Init(); it.More(); it.Next() ) { - std::vector aulElements; + std::vector aulElements; it.GetElements( aulElements ); - for ( std::vector::iterator itP = aulElements.begin(); itP != aulElements.end(); ++itP ) + for ( std::vector::iterator itP = aulElements.begin(); itP != aulElements.end(); ++itP ) { cP.Set( *itP ); if ( it.GetBoundBox().IsInBox( *cP ) == false ) @@ -1103,7 +1103,7 @@ bool MeshPointGrid::Verify() const return true; } -void MeshPointGrid::RebuildGrid (void) +void MeshPointGrid::RebuildGrid () { _ulCtElements = _pclMesh->CountPoints(); @@ -1127,7 +1127,7 @@ void MeshPointGrid::Pos (const Base::Vector3f &rclPoint, unsigned long &rulX, un rulZ = static_cast((rclPoint.z - _fMinZ) / _fGridLenZ); } -unsigned long MeshPointGrid::FindElements (const Base::Vector3f &rclPoint, std::set& aulElements) const +unsigned long MeshPointGrid::FindElements (const Base::Vector3f &rclPoint, std::set& aulElements) const { unsigned long ulX, ulY, ulZ; Pos(rclPoint, ulX, ulY, ulZ); @@ -1154,7 +1154,7 @@ MeshGridIterator::MeshGridIterator (const MeshGrid &rclG) } bool MeshGridIterator::InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea, - std::vector &raulElements) + std::vector &raulElements) { bool ret = InitOnRay (rclPt, rclDir, raulElements); _fMaxSearchArea = fMaxSearchArea; @@ -1162,7 +1162,7 @@ bool MeshGridIterator::InitOnRay (const Base::Vector3f &rclPt, const Base::Vecto } bool MeshGridIterator::InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, - std::vector &raulElements) + std::vector &raulElements) { // needed in NextOnRay() to avoid an infinite loop _cSearchPositions.clear(); @@ -1200,7 +1200,7 @@ bool MeshGridIterator::InitOnRay (const Base::Vector3f &rclPt, const Base::Vecto return _bValidRay; } -bool MeshGridIterator::NextOnRay (std::vector &raulElements) +bool MeshGridIterator::NextOnRay (std::vector &raulElements) { if (_bValidRay == false) return false; // nicht initialisiert oder Strahl ausgetreten diff --git a/src/Mod/Mesh/App/Core/Grid.h b/src/Mod/Mesh/App/Core/Grid.h index 29b34f1c4d..e368184bbb 100644 --- a/src/Mod/Mesh/App/Core/Grid.h +++ b/src/Mod/Mesh/App/Core/Grid.h @@ -60,12 +60,12 @@ protected: /// Construction MeshGrid (const MeshKernel &rclM); /// Construction - MeshGrid (void); + MeshGrid (); //@} public: /// Destruction - virtual ~MeshGrid (void) { } + virtual ~MeshGrid () { } public: /** Attaches the mesh kernel to this grid, an already attached mesh gets detached. The grid gets rebuilt @@ -81,21 +81,21 @@ public: /** @name Search */ //@{ /** Searches for elements lying in the intersection area of the grid and the bounding box. */ - virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements, bool bDelDoubles = true) const; + virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements, bool bDelDoubles = true) const; /** Searches for elements lying in the intersection area of the grid and the bounding box. */ - virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::set &raulElementss) const; + virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::set &raulElementss) const; /** Searches for elements lying in the intersection area of the grid and the bounding box. */ - virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements, + virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector &raulElements, const Base::Vector3f &rclOrg, float fMaxDist, bool bDelDoubles = true) const; /** Searches for the nearest grids that contain elements from a point, the result are grid indices. */ - void SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set &rclInd) const; + void SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set &rclInd) const; //@} /** @name Getters */ //@{ /** Returns the indices of the elements in the given grid. */ - unsigned long GetElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ, std::set &raclInd) const; - unsigned long GetElements (const Base::Vector3f &rclPoint, std::vector& aulFacets) const; + unsigned long GetElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ, std::set &raclInd) const; + unsigned long GetElements (const Base::Vector3f &rclPoint, std::vector& aulFacets) const; //@} /** Returns the lengths of the grid elements in x,y and z direction. */ @@ -110,9 +110,9 @@ public: /** Returns the bounding box of a given grid element. */ inline Base::BoundBox3f GetBoundBox (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const; /** Returns the bounding box of the whole. */ - inline Base::BoundBox3f GetBoundBox (void) const; + inline Base::BoundBox3f GetBoundBox () const; /** Returns an extended bounding box of the mesh object. */ - inline Base::BoundBox3f GetMeshBoundBox (void) const; + inline Base::BoundBox3f GetMeshBoundBox () const; //@} /** Returns an index for the given grid position. If the specified triple is not a valid grid position ULONG_MAX is returned. * If the index is valid than its value is between zero and the number of grid elements. For each different grid position @@ -140,24 +140,24 @@ public: /** Checks if this is a valid grid position. */ inline bool CheckPos (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const; /** Get the indices of all elements lying in the grids around a given grid with distance \a ulDistance. */ - void GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance, std::set &raclInd) const; + void GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance, std::set &raclInd) const; protected: /** Initializes the size of the internal structure. */ - virtual void InitGrid (void); + virtual void InitGrid (); /** Deletes the grid structure. */ - virtual void Clear (void); + virtual void Clear (); /** Calculates the grid length dependent on maximum number of grids. */ virtual void CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxGrids); /** Calculates the grid length dependent on the number of grids per axis. */ virtual void CalculateGridLength (int iCtGridPerAxis); /** Rebuilds the grid structure. Must be implemented in sub-classes. */ - virtual void RebuildGrid (void) = 0; + virtual void RebuildGrid () = 0; /** Returns the number of stored elements. Must be implemented in sub-classes. */ - virtual unsigned long HasElements (void) const = 0; + virtual unsigned long HasElements () const = 0; protected: - std::vector > > > _aulGrid; /**< Grid data structure. */ + std::vector > > > _aulGrid; /**< Grid data structure. */ const MeshKernel* _pclMesh; /**< The mesh kernel. */ unsigned long _ulCtElements;/**< Number of grid elements for validation issues. */ unsigned long _ulCtGridsX; /**< Number of grid elements in z. */ @@ -186,7 +186,7 @@ public: /// Construction MeshFacetGrid (const MeshKernel &rclM); /// Construction - MeshFacetGrid (void) : MeshGrid() { } + MeshFacetGrid () : MeshGrid() { } /// Construction MeshFacetGrid (const MeshKernel &rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ); /// Construction @@ -194,7 +194,7 @@ public: /// Construction MeshFacetGrid (const MeshKernel &rclM, float fGridLen); /// Destruction - virtual ~MeshFacetGrid (void) { } + virtual ~MeshFacetGrid () { } //@} /** @name Search */ @@ -205,17 +205,17 @@ public: unsigned long SearchNearestFromPoint (const Base::Vector3f &rclPt, float fMaxSearchArea) const; /** Searches for the nearest facet in a given grid element and returns the facet index and the actual distance. */ void SearchNearestFacetInGrid(unsigned long ulX, unsigned long ulY, unsigned long ulZ, const Base::Vector3f &rclPt, - float &rfMinDist, unsigned long &rulFacetInd) const; + float &rfMinDist, ElementIndex &rulFacetInd) const; /** Does basically the same as the method above unless that grid neighbours up to the order of \a ulDistance * are introduced into the search. */ void SearchNearestFacetInHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance, - const Base::Vector3f &rclPt, unsigned long &rulFacetInd, float &rfMinDist) const; + const Base::Vector3f &rclPt, ElementIndex &rulFacetInd, float &rfMinDist) const; //@} /** Validates the grid structure and rebuilds it if needed. */ virtual void Validate (const MeshKernel &rclM); /** Validates the grid structure and rebuilds it if needed. */ - virtual void Validate (void); + virtual void Validate (); /** Verifies the grid structure and returns false if inconsistencies are found. */ virtual bool Verify() const; @@ -227,12 +227,12 @@ protected: /** Adds a new facet element to the grid structure. \a rclFacet is the geometric facet and \a ulFacetIndex * the corresponding index in the mesh kernel. The facet is added to each grid element that intersects * the facet. */ - inline void AddFacet (const MeshGeomFacet &rclFacet, unsigned long ulFacetIndex, float fEpsilon = 0.0f); + inline void AddFacet (const MeshGeomFacet &rclFacet, ElementIndex ulFacetIndex, float fEpsilon = 0.0f); /** Returns the number of stored elements. */ - unsigned long HasElements (void) const + unsigned long HasElements () const { return _pclMesh->CountFacets(); } /** Rebuilds the grid structure. */ - virtual void RebuildGrid (void); + virtual void RebuildGrid (); }; /** @@ -245,7 +245,7 @@ public: /** @name Construction */ //@{ /// Construction - MeshPointGrid (void); + MeshPointGrid (); /// Construction MeshPointGrid (const MeshKernel &rclM); /// Construction @@ -255,29 +255,29 @@ public: /// Construction MeshPointGrid (const MeshKernel &rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ); /// Destruction - virtual ~MeshPointGrid (void) {} + virtual ~MeshPointGrid () {} //@} /** Finds all points that lie in the same grid as the point \a rclPoint. */ - unsigned long FindElements(const Base::Vector3f &rclPoint, std::set& aulElements) const; + unsigned long FindElements(const Base::Vector3f &rclPoint, std::set& aulElements) const; /** Validates the grid structure and rebuilds it if needed. */ virtual void Validate (const MeshKernel &rclM); /** Validates the grid structure and rebuilds it if needed. */ - virtual void Validate (void); + virtual void Validate (); /** Verifies the grid structure and returns false if inconsistencies are found. */ virtual bool Verify() const; protected: /** Adds a new point element to the grid structure. \a rclPt is the geometric point and \a ulPtIndex * the corresponding index in the mesh kernel. */ - void AddPoint (const MeshPoint &rclPt, unsigned long ulPtIndex, float fEpsilon = 0.0f); + void AddPoint (const MeshPoint &rclPt, ElementIndex ulPtIndex, float fEpsilon = 0.0f); /** Returns the grid numbers to the given point \a rclPoint. */ void Pos(const Base::Vector3f &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const; /** Returns the number of stored elements. */ - unsigned long HasElements (void) const + unsigned long HasElements () const { return _pclMesh->CountPoints(); } /** Rebuilds the grid structure. */ - virtual void RebuildGrid (void); + virtual void RebuildGrid (); }; /** @@ -290,10 +290,10 @@ public: /// Construction MeshGridIterator (const MeshGrid &rclG); /** Returns the bounding box of the current grid element. */ - Base::BoundBox3f GetBoundBox (void) const + Base::BoundBox3f GetBoundBox () const { return _rclGrid.GetBoundBox(_ulX, _ulY, _ulZ); } /** Returns indices of the elements in the current grid. */ - void GetElements (std::vector &raulElements) const + void GetElements (std::vector &raulElements) const { raulElements.insert(raulElements.end(), _rclGrid._aulGrid[_ulX][_ulY][_ulZ].begin(), _rclGrid._aulGrid[_ulX][_ulY][_ulZ].end()); } @@ -305,13 +305,13 @@ public: /** @name Iteration */ //@{ /** Sets the iterator to the first element*/ - void Init (void) + void Init () { _ulX = _ulY = _ulZ = 0; } /** Checks if the iterator has not yet reached the end position. */ - bool More (void) const + bool More () const { return (_ulZ < _rclGrid._ulCtGridsZ); } /** Go to the next grid. */ - void Next (void) + void Next () { if (++_ulX >= (_rclGrid._ulCtGridsX)) _ulX = 0; else return; if (++_ulY >= (_rclGrid._ulCtGridsY)) { _ulY = 0; _ulZ++; } else return; @@ -321,11 +321,11 @@ public: /** @name Tests with rays */ //@{ /** Searches for facets around the ray. */ - bool InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, std::vector &raulElements); + bool InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, std::vector &raulElements); /** Searches for facets around the ray. */ - bool InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea, std::vector &raulElements); + bool InitOnRay (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, float fMaxSearchArea, std::vector &raulElements); /** Searches for facets around the ray. */ - bool NextOnRay (std::vector &raulElements); + bool NextOnRay (std::vector &raulElements); //@} /** Returns the grid number of the current position. */ @@ -372,13 +372,13 @@ inline Base::BoundBox3f MeshGrid::GetBoundBox (unsigned long ulX, unsigned long return Base::BoundBox3f(fX, fY, fZ, fX + _fGridLenX, fY + _fGridLenY, fZ + _fGridLenZ); } -inline Base::BoundBox3f MeshGrid::GetBoundBox (void) const +inline Base::BoundBox3f MeshGrid::GetBoundBox () const { return Base::BoundBox3f(_fMinX, _fMinY, _fMinZ, _fMinX + (_fGridLenX * float(_ulCtGridsX)), _fMinY + (_fGridLenY * float(_ulCtGridsY)), _fMinZ + (_fGridLenZ * float(_ulCtGridsZ))); } -inline Base::BoundBox3f MeshGrid::GetMeshBoundBox (void) const +inline Base::BoundBox3f MeshGrid::GetMeshBoundBox () const { Base::BoundBox3f clBBenlarged = _pclMesh->GetBoundBox(); clBBenlarged.Enlarge(MESHGRID_BBOX_EXTENSION); @@ -434,38 +434,8 @@ inline void MeshFacetGrid::PosWithCheck (const Base::Vector3f &rclPoint, unsigne assert((rulX < _ulCtGridsX) && (rulY < _ulCtGridsY) && (rulZ < _ulCtGridsZ)); } -inline void MeshFacetGrid::AddFacet (const MeshGeomFacet &rclFacet, unsigned long ulFacetIndex, float /*fEpsilon*/) +inline void MeshFacetGrid::AddFacet (const MeshGeomFacet &rclFacet, ElementIndex ulFacetIndex, float /*fEpsilon*/) { -#if 0 - unsigned long i, ulX, ulY, ulZ, ulX1, ulY1, ulZ1, ulX2, ulY2, ulZ2; - - ulX1 = ulY1 = ulZ1 = ULONG_MAX; - ulX2 = ulY2 = ulZ2 = 0; - - for (i = 0; i < 3; i++) - { - Pos(rclFacet._aclPoints[i], ulX, ulY, ulZ); - _aulGrid[ulX][ulY][ulZ].insert(ulFacetIndex); - ulX1 = RSmin(ulX1, ulX); ulY1 = RSmin(ulY1, ulY); ulZ1 = RSmin(ulZ1, ulZ); - ulX2 = RSmax(ulX2, ulX); ulY2 = RSmax(ulY2, ulY); ulZ2 = RSmax(ulZ2, ulZ); - } - - // falls Facet ueber mehrere BB reicht - if ((ulX1 < ulX2) || (ulY1 < ulY2) || (ulZ1 < ulZ2)) - { - for (ulX = ulX1; ulX <= ulX2; ulX++) - { - for (ulY = ulY1; ulY <= ulY2; ulY++) - { - for (ulZ = ulZ1; ulZ <= ulZ2; ulZ++) - { - if (CMeshFacetFunc::BBoxContainFacet(GetBoundBox(ulX, ulY, ulZ), rclFacet) == true) - _aulGrid[ulX][ulY][ulZ].insert(ulFacetIndex); - } - } - } - } -#else unsigned long ulX, ulY, ulZ; unsigned long ulX1, ulY1, ulZ1, ulX2, ulY2, ulZ2; @@ -510,8 +480,6 @@ inline void MeshFacetGrid::AddFacet (const MeshGeomFacet &rclFacet, unsigned lon } else _aulGrid[ulX1][ulY1][ulZ1].insert(ulFacetIndex); - -#endif } } // namespace MeshCore diff --git a/src/Mod/Mesh/App/Core/Helpers.h b/src/Mod/Mesh/App/Core/Helpers.h index 7726fb2dca..a5c844e9c1 100644 --- a/src/Mod/Mesh/App/Core/Helpers.h +++ b/src/Mod/Mesh/App/Core/Helpers.h @@ -36,19 +36,19 @@ namespace MeshCore { */ struct MeshExport MeshHelpPoint { - inline void Set (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt); + inline void Set (FacetIndex ulCorner, FacetIndex ulFacet, const Base::Vector3f &rclPt); inline bool operator < (const MeshHelpPoint &rclObj) const; inline bool operator == (const MeshHelpPoint &rclObj) const; - unsigned long Index (void) const + FacetIndex Index () const { return _ulInd >> 2; } - unsigned long Corner (void) const + FacetIndex Corner () const { return _ulInd & 3; } - MeshPoint _clPt; - unsigned long _ulInd; + MeshPoint _clPt; + FacetIndex _ulInd; }; /** @@ -56,7 +56,7 @@ struct MeshExport MeshHelpPoint */ struct MeshPointBuilder: public std::vector { - inline void Add (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt); + inline void Add (FacetIndex ulCorner, FacetIndex ulFacet, const Base::Vector3f &rclPt); }; /** @@ -64,14 +64,14 @@ struct MeshPointBuilder: public std::vector */ struct MeshExport MeshHelpBuilderEdge { - unsigned long Side (void) const + FacetIndex Side () const { return _ulFIndex & 3; } - unsigned long Index (void) const + FacetIndex Index () const { return _ulFIndex >> 2; } - inline void Set (unsigned long ulInd1, unsigned long ulInd2, - unsigned long ulSide, unsigned long ulFInd); + inline void Set (PointIndex ulInd1, PointIndex ulInd2, + FacetIndex ulSide, FacetIndex ulFInd); inline bool operator < (const MeshHelpBuilderEdge &rclObj) const; @@ -80,8 +80,8 @@ struct MeshExport MeshHelpBuilderEdge inline bool operator != (const MeshHelpBuilderEdge &rclObj) const; - unsigned long _ulFIndex; // facet index - unsigned long _aulInd[2]; // point index + FacetIndex _ulFIndex; // facet index + PointIndex _aulInd[2]; // point index }; /** @@ -90,10 +90,10 @@ struct MeshExport MeshHelpBuilderEdge struct MeshEdgeBuilder: public std::vector { typedef std::vector::iterator _TIterator; - inline void Add (unsigned long ulInd1, unsigned long ulInd2, unsigned long ulSide, unsigned long ulFInd); + inline void Add (PointIndex ulInd1, PointIndex ulInd2, FacetIndex ulSide, FacetIndex ulFInd); }; -inline void MeshHelpPoint::Set (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt) +inline void MeshHelpPoint::Set (FacetIndex ulCorner, FacetIndex ulFacet, const Base::Vector3f &rclPt) { _ulInd = (ulFacet << 2) | ulCorner; _clPt = rclPt; @@ -101,21 +101,6 @@ inline void MeshHelpPoint::Set (unsigned long ulCorner, unsigned long ulFacet, c inline bool MeshHelpPoint::operator < (const MeshHelpPoint &rclObj) const { -// if (fabs(_clPt.x - rclObj._clPt.x) < MeshDefinitions::_fMinPointDistanceD1) -// { -// if (fabs(_clPt.y - rclObj._clPt.y) < MeshDefinitions::_fMinPointDistanceD1) -// { -// if (fabs(_clPt.z - rclObj._clPt.z) < MeshDefinitions::_fMinPointDistanceD1) -// return false; -// else -// return _clPt.z < rclObj._clPt.z; -// } -// else -// return _clPt.y < rclObj._clPt.y; -// } -// else -// return _clPt.x < rclObj._clPt.x; - if (_clPt.x == rclObj._clPt.x) { if (_clPt.y == rclObj._clPt.y) @@ -130,33 +115,17 @@ inline bool MeshHelpPoint::operator < (const MeshHelpPoint &rclObj) const inline bool MeshHelpPoint::operator == (const MeshHelpPoint &rclObj) const { return Base::DistanceP2(_clPt, rclObj._clPt) < MeshDefinitions::_fMinPointDistanceP2; -/* - if (fabs(_clPt.x - rclObj._clPt.x) < (MeshDefinitions::_fMinPointDistanceD1 + 1.0e-2f)) - { - if (fabs(_clPt.y - rclObj._clPt.y) < (MeshDefinitions::_fMinPointDistanceD1 + 1.0e-2f)) - { - if (fabs(_clPt.z - rclObj._clPt.z) < (MeshDefinitions::_fMinPointDistanceD1 + 1.0e-2f)) - return true; - else - return false; - } - else - return false; - } - else - return false; -*/ } -inline void MeshPointBuilder::Add (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt) +inline void MeshPointBuilder::Add (FacetIndex ulCorner, FacetIndex ulFacet, const Base::Vector3f &rclPt) { MeshHelpPoint clObj; clObj.Set(ulCorner, ulFacet, rclPt); push_back(clObj); } -inline void MeshHelpBuilderEdge::Set ( unsigned long ulInd1, unsigned long ulInd2, - unsigned long ulSide, unsigned long ulFInd) +inline void MeshHelpBuilderEdge::Set (PointIndex ulInd1, PointIndex ulInd2, + FacetIndex ulSide, FacetIndex ulFInd) { if (ulInd1 < ulInd2) { @@ -190,8 +159,8 @@ inline bool MeshHelpBuilderEdge::operator != (const MeshHelpBuilderEdge &rclObj) } -inline void MeshEdgeBuilder::Add (unsigned long ulInd1, unsigned long ulInd2, - unsigned long ulSide, unsigned long ulFInd) +inline void MeshEdgeBuilder::Add (PointIndex ulInd1, PointIndex ulInd2, + FacetIndex ulSide, FacetIndex ulFInd) { MeshHelpBuilderEdge clObj; clObj.Set(ulInd1, ulInd2, ulSide, ulFInd); diff --git a/src/Mod/Mesh/App/Core/Info.cpp b/src/Mod/Mesh/App/Core/Info.cpp index 5eb0783290..cf7b6164b7 100644 --- a/src/Mod/Mesh/App/Core/Info.cpp +++ b/src/Mod/Mesh/App/Core/Info.cpp @@ -52,10 +52,7 @@ std::ostream& MeshInfo::GeneralInformation (std::ostream &rclStream) const rclStream << "Mesh: [" << ulCtFc << " Faces, "; - if (ulCtEd!=ULONG_MAX) rclStream << ulCtEd << " Edges, "; - else - rclStream << "Cannot determine number of edges, "; rclStream << ulCtPt << " Points" << "]" << std::endl; @@ -65,12 +62,11 @@ std::ostream& MeshInfo::GeneralInformation (std::ostream &rclStream) const std::ostream& MeshInfo::DetailedPointInfo (std::ostream& rclStream) const { // print points - unsigned long i; rclStream << _rclMesh.CountPoints() << " Points:" << std::endl; MeshPointIterator pPIter(_rclMesh), pPEnd(_rclMesh); pPIter.Begin(); pPEnd.End(); - i = 0; + PointIndex i = 0; rclStream.precision(3); rclStream.setf(std::ios::fixed | std::ios::showpoint | std::ios::showpos); @@ -90,7 +86,7 @@ std::ostream& MeshInfo::DetailedEdgeInfo (std::ostream& rclStream) const { // print edges // get edges from facets - std::map, int > lEdges; + std::map, int > lEdges; const MeshFacetArray& rFacets = _rclMesh.GetFacets(); MeshFacetArray::_TConstIterator pFIter; @@ -100,9 +96,9 @@ std::ostream& MeshInfo::DetailedEdgeInfo (std::ostream& rclStream) const const MeshFacet& rFacet = *pFIter; for ( int j=0; j<3; j++ ) { - unsigned long ulPt0 = std::min(rFacet._aulPoints[j], rFacet._aulPoints[(j+1)%3]); - unsigned long ulPt1 = std::max(rFacet._aulPoints[j], rFacet._aulPoints[(j+1)%3]); - std::pair cEdge(ulPt0, ulPt1); + PointIndex ulPt0 = std::min(rFacet._aulPoints[j], rFacet._aulPoints[(j+1)%3]); + PointIndex ulPt1 = std::max(rFacet._aulPoints[j], rFacet._aulPoints[(j+1)%3]); + std::pair cEdge(ulPt0, ulPt1); lEdges[ cEdge ]++; } @@ -111,7 +107,7 @@ std::ostream& MeshInfo::DetailedEdgeInfo (std::ostream& rclStream) const // print edges rclStream << lEdges.size() << " Edges:" << std::endl; - std::map, int >::const_iterator pEIter; + std::map, int >::const_iterator pEIter; pEIter = lEdges.begin(); rclStream.precision(3); diff --git a/src/Mod/Mesh/App/Core/Info.h b/src/Mod/Mesh/App/Core/Info.h index 85828d5a1e..166d595ed7 100644 --- a/src/Mod/Mesh/App/Core/Info.h +++ b/src/Mod/Mesh/App/Core/Info.h @@ -37,7 +37,7 @@ class MeshExport MeshInfo { public: MeshInfo (const MeshKernel &rclM); - virtual ~MeshInfo (void) {} + virtual ~MeshInfo () {} /** * Writes general information about the mesh structure into the stream. */ @@ -82,7 +82,7 @@ protected: const MeshKernel &_rclMesh; // const reference to mesh data structure private: - MeshInfo(void); // not accessible default constructor + MeshInfo(); // not accessible default constructor }; diff --git a/src/Mod/Mesh/App/Core/Iterator.h b/src/Mod/Mesh/App/Core/Iterator.h index b0197ad9c3..07e74ed2f2 100644 --- a/src/Mod/Mesh/App/Core/Iterator.h +++ b/src/Mod/Mesh/App/Core/Iterator.h @@ -53,7 +53,7 @@ public: /// construction inline MeshFacetIterator (const MeshKernel &rclM); /// construction - inline MeshFacetIterator (const MeshKernel &rclM, unsigned long ulPos); + inline MeshFacetIterator (const MeshKernel &rclM, FacetIndex ulPos); /// construction inline MeshFacetIterator (const MeshFacetIterator &rclI); //@} @@ -67,18 +67,18 @@ public: /** @name Access methods */ //@{ /// Access to the element the iterator points to. - const MeshGeomFacet& operator*(void) + const MeshGeomFacet& operator*() { return Dereference(); } /// Access to the element the iterator points to. - const MeshGeomFacet* operator->(void) + const MeshGeomFacet* operator->() { return &Dereference(); } /// Increments the iterator. It points then to the next element if the /// end is not reached. - const MeshFacetIterator& operator ++ (void) + const MeshFacetIterator& operator ++ () { ++_clIter; return *this; } /// Decrements the iterator. It points then to the previous element if the beginning /// is not reached. - const MeshFacetIterator& operator -- (void) + const MeshFacetIterator& operator -- () { --_clIter; return *this; } /// Increments the iterator by \a k positions. const MeshFacetIterator& operator += (int k) @@ -98,42 +98,42 @@ public: bool operator == (const MeshFacetIterator &rclI) const { return _clIter == rclI._clIter; } /// Sets the iterator to the beginning of the array. - void Begin (void) + void Begin () { _clIter = _rclFAry.begin(); } /// Sets the iterator to the end of the array. - void End (void) + void End () { _clIter = _rclFAry.end(); } /// Returns the current position of the iterator in the array. - unsigned long Position (void) const + FacetIndex Position () const { return _clIter - _rclFAry.begin(); } /// Checks if the end is already reached. - bool EndReached (void) const + bool EndReached () const { return !(_clIter < _rclFAry.end()); } /// Sets the iterator to the beginning of the array. - void Init (void) + void Init () { Begin(); } /// Checks if the end is not yet reached. - bool More (void) const + bool More () const { return !EndReached(); } /// Increments the iterator. - void Next (void) + void Next () { operator++(); } /// Sets the iterator to a given position. - inline bool Set (unsigned long ulIndex); + inline bool Set (FacetIndex ulIndex); /// Returns the topologic facet. - inline MeshFacet GetIndices (void) const + inline MeshFacet GetIndices () const { return *_clIter; } /// Returns the topologic facet. - inline const MeshFacet& GetReference (void) const + inline const MeshFacet& GetReference () const { return *_clIter; } /// Returns iterators pointing to the current facet's neighbours. inline void GetNeighbours (MeshFacetIterator &rclN0, MeshFacetIterator &rclN1, MeshFacetIterator &rclN2) const; /// Sets the iterator to the current facet's neighbour of the side \a usN. inline void SetToNeighbour (unsigned short usN); /// Returns the property information to the current facet. - inline unsigned long GetProperty (void) const; + inline unsigned long GetProperty () const; /// Checks if the iterator points to a valid element inside the array. - inline bool IsValid (void) const + inline bool IsValid () const { return (_clIter >= _rclFAry.begin()) && (_clIter < _rclFAry.end()); } //@} /** @name Flag state @@ -150,7 +150,7 @@ public: //@} protected: - inline const MeshGeomFacet& Dereference (void); + inline const MeshGeomFacet& Dereference (); protected: const MeshKernel& _rclMesh; @@ -176,7 +176,7 @@ public: /** @name Construction */ //@{ inline MeshPointIterator (const MeshKernel &rclM); - inline MeshPointIterator (const MeshKernel &rclM, unsigned long ulPos); + inline MeshPointIterator (const MeshKernel &rclM, PointIndex ulPos); inline MeshPointIterator (const MeshPointIterator &rclI); //@} @@ -189,18 +189,18 @@ public: /** @name Access methods */ //@{ /// Access to the element the iterator points to. - const MeshPoint& operator*(void) const + const MeshPoint& operator*() const { return Dereference(); } /// Access to the element the iterator points to. - const MeshPoint* operator->(void) const + const MeshPoint* operator->() const { return &Dereference(); } /// Increments the iterator. It points then to the next element if the /// end is not reached. - const MeshPointIterator& operator ++ (void) + const MeshPointIterator& operator ++ () { ++_clIter; return *this; } /// Decrements the iterator. It points then to the previous element if the beginning /// is not reached. - const MeshPointIterator& operator -- (void) + const MeshPointIterator& operator -- () { --_clIter; return *this; } /// Assignment. inline MeshPointIterator& operator = (const MeshPointIterator &rpI); @@ -214,30 +214,30 @@ public: bool operator == (const MeshPointIterator &rclI) const { return _clIter == rclI._clIter; } /// Sets the iterator to the beginning of the array. - void Begin (void) + void Begin () { _clIter = _rclPAry.begin(); } /// Sets the iterator to the end of the array. - void End (void) + void End () { _clIter = _rclPAry.end(); } /// Returns the current position of the iterator in the array. - unsigned long Position (void) const + PointIndex Position () const { return _clIter - _rclPAry.begin(); } /// Checks if the end is already reached. - bool EndReached (void) const + bool EndReached () const { return !(_clIter < _rclPAry.end()); } /// Sets the iterator to the beginning of the array. - void Init (void) + void Init () { Begin(); } /// Checks if the end is not yet reached. - bool More (void) const + bool More () const { return !EndReached(); } /// Increments the iterator. - void Next (void) + void Next () { operator++(); } /// Sets the iterator to a given position. - inline bool Set (unsigned long ulIndex); + inline bool Set (PointIndex ulIndex); /// Checks if the iterator points to a valid element inside the array. - inline bool IsValid (void) const + inline bool IsValid () const { return (_clIter >= _rclPAry.begin()) && (_clIter < _rclPAry.end()); } //@} /** @name Flag state @@ -254,7 +254,7 @@ public: //@} protected: - inline const MeshPoint& Dereference (void) const; + inline const MeshPoint& Dereference () const; protected: const MeshKernel& _rclMesh; @@ -274,9 +274,9 @@ public: inline MeshFastFacetIterator (const MeshKernel &rclM); virtual ~MeshFastFacetIterator () {} - void Init (void) { _clIter = _rclFAry.begin(); } - inline void Next (void); - bool More (void) { return _clIter != _rclFAry.end(); } + void Init () { _clIter = _rclFAry.begin(); } + inline void Next (); + bool More () { return _clIter != _rclFAry.end(); } Base::Vector3f _afPoints[3]; @@ -299,9 +299,9 @@ inline MeshFastFacetIterator::MeshFastFacetIterator (const MeshKernel &rclM) { } -inline void MeshFastFacetIterator::Next (void) +inline void MeshFastFacetIterator::Next () { - const unsigned long *paulPt = _clIter->_aulPoints; + const PointIndex *paulPt = _clIter->_aulPoints; Base::Vector3f *pfPt = _afPoints; *(pfPt++) = _rclPAry[*(paulPt++)]; *(pfPt++) = _rclPAry[*(paulPt++)]; @@ -317,7 +317,7 @@ inline MeshFacetIterator::MeshFacetIterator (const MeshKernel &rclM) { } -inline MeshFacetIterator::MeshFacetIterator (const MeshKernel &rclM, unsigned long ulPos) +inline MeshFacetIterator::MeshFacetIterator (const MeshKernel &rclM, FacetIndex ulPos) : _rclMesh(rclM), _rclFAry(rclM._aclFacetArray), _rclPAry(rclM._aclPointArray), @@ -344,10 +344,10 @@ inline void MeshFacetIterator::Transform( const Base::Matrix4D& rclTrf ) _clTrf != tmp ? _bApply = true : _bApply = false; } -inline const MeshGeomFacet& MeshFacetIterator::Dereference (void) +inline const MeshGeomFacet& MeshFacetIterator::Dereference () { MeshFacet rclF = *_clIter; - const unsigned long *paulPt = &(_clIter->_aulPoints[0]); + const PointIndex *paulPt = &(_clIter->_aulPoints[0]); Base::Vector3f *pclPt = _clFacet._aclPoints; *(pclPt++) = _rclPAry[*(paulPt++)]; *(pclPt++) = _rclPAry[*(paulPt++)]; @@ -364,7 +364,7 @@ inline const MeshGeomFacet& MeshFacetIterator::Dereference (void) return _clFacet; } -inline bool MeshFacetIterator::Set (unsigned long ulIndex) +inline bool MeshFacetIterator::Set (FacetIndex ulIndex) { if (ulIndex < _rclFAry.size()) { @@ -386,24 +386,24 @@ inline MeshFacetIterator& MeshFacetIterator::operator = (const MeshFacetIterator return *this; } -inline unsigned long MeshFacetIterator::GetProperty (void) const +inline unsigned long MeshFacetIterator::GetProperty () const { return _clIter->_ulProp; } inline void MeshFacetIterator::GetNeighbours (MeshFacetIterator &rclN0, MeshFacetIterator &rclN1, MeshFacetIterator &rclN2) const { - if (_clIter->_aulNeighbours[0] != ULONG_MAX) + if (_clIter->_aulNeighbours[0] != FACET_INDEX_MAX) rclN0.Set(_clIter->_aulNeighbours[0]); else rclN0.End(); - if (_clIter->_aulNeighbours[1] != ULONG_MAX) + if (_clIter->_aulNeighbours[1] != FACET_INDEX_MAX) rclN1.Set(_clIter->_aulNeighbours[1]); else rclN1.End(); - if (_clIter->_aulNeighbours[2] != ULONG_MAX) + if (_clIter->_aulNeighbours[2] != FACET_INDEX_MAX) rclN2.Set(_clIter->_aulNeighbours[2]); else rclN2.End(); @@ -411,7 +411,7 @@ inline void MeshFacetIterator::GetNeighbours (MeshFacetIterator &rclN0, MeshFace inline void MeshFacetIterator::SetToNeighbour (unsigned short usN) { - if (_clIter->_aulNeighbours[usN] != ULONG_MAX) + if (_clIter->_aulNeighbours[usN] != FACET_INDEX_MAX) _clIter = _rclFAry.begin() + _clIter->_aulNeighbours[usN]; else End(); @@ -423,7 +423,7 @@ inline MeshPointIterator::MeshPointIterator (const MeshKernel &rclM) _clIter = _rclPAry.begin(); } -inline MeshPointIterator::MeshPointIterator (const MeshKernel &rclM, unsigned long ulPos) +inline MeshPointIterator::MeshPointIterator (const MeshKernel &rclM, PointIndex ulPos) : _rclMesh(rclM), _rclPAry(_rclMesh._aclPointArray), _bApply(false) { _clIter = _rclPAry.begin() + ulPos; @@ -442,7 +442,7 @@ inline void MeshPointIterator::Transform( const Base::Matrix4D& rclTrf ) _clTrf != tmp ? _bApply = true : _bApply = false; } -inline const MeshPoint& MeshPointIterator::Dereference (void) const +inline const MeshPoint& MeshPointIterator::Dereference () const { // We change only the value of the point but not the actual iterator const_cast(this)->_clPoint = *_clIter; if ( _bApply ) @@ -450,7 +450,7 @@ inline const MeshPoint& MeshPointIterator::Dereference (void) const return _clPoint; } -inline bool MeshPointIterator::Set (unsigned long ulIndex) +inline bool MeshPointIterator::Set (PointIndex ulIndex) { if (ulIndex < _rclPAry.size()) { diff --git a/src/Mod/Mesh/App/Core/KDTree.cpp b/src/Mod/Mesh/App/Core/KDTree.cpp index adf5b39dcd..2620f8565d 100644 --- a/src/Mod/Mesh/App/Core/KDTree.cpp +++ b/src/Mod/Mesh/App/Core/KDTree.cpp @@ -37,7 +37,7 @@ struct Point3d { typedef float value_type; - Point3d(const Base::Vector3f& f, unsigned long i) : p(f), i(i) + Point3d(const Base::Vector3f& f, PointIndex i) : p(f), i(i) { } @@ -71,7 +71,7 @@ struct Point3d } Base::Vector3f p; - unsigned long i; + PointIndex i; }; typedef KDTree::KDTree<3, Point3d> MyKDTree; @@ -88,7 +88,7 @@ MeshKDTree::MeshKDTree() : d(new Private) MeshKDTree::MeshKDTree(const std::vector& points) : d(new Private) { - unsigned long index=0; + PointIndex index=0; for (std::vector::const_iterator it = points.begin(); it != points.end(); ++it) { d->kd_tree.insert(Point3d(*it, index++)); } @@ -96,7 +96,7 @@ MeshKDTree::MeshKDTree(const std::vector& points) : d(new Privat MeshKDTree::MeshKDTree(const MeshPointArray& points) : d(new Private) { - unsigned long index=0; + PointIndex index=0; for (MeshPointArray::_TConstIterator it = points.begin(); it != points.end(); ++it) { d->kd_tree.insert(Point3d(*it, index++)); } @@ -109,13 +109,13 @@ MeshKDTree::~MeshKDTree() void MeshKDTree::AddPoint(Base::Vector3f& point) { - unsigned long index=d->kd_tree.size(); + PointIndex index=d->kd_tree.size(); d->kd_tree.insert(Point3d(point, index)); } void MeshKDTree::AddPoints(const std::vector& points) { - unsigned long index=d->kd_tree.size(); + PointIndex index=d->kd_tree.size(); for (std::vector::const_iterator it = points.begin(); it != points.end(); ++it) { d->kd_tree.insert(Point3d(*it, index++)); } @@ -123,7 +123,7 @@ void MeshKDTree::AddPoints(const std::vector& points) void MeshKDTree::AddPoints(const MeshPointArray& points) { - unsigned long index=d->kd_tree.size(); + PointIndex index=d->kd_tree.size(); for (MeshPointArray::_TConstIterator it = points.begin(); it != points.end(); ++it) { d->kd_tree.insert(Point3d(*it, index++)); } @@ -144,42 +144,42 @@ void MeshKDTree::Optimize() d->kd_tree.optimize(); } -unsigned long MeshKDTree::FindNearest(const Base::Vector3f& p, Base::Vector3f& n, float& dist) const +PointIndex MeshKDTree::FindNearest(const Base::Vector3f& p, Base::Vector3f& n, float& dist) const { std::pair it = d->kd_tree.find_nearest(Point3d(p,0)); if (it.first == d->kd_tree.end()) - return ULONG_MAX; - unsigned long index = it.first->i; + return POINT_INDEX_MAX; + PointIndex index = it.first->i; n = it.first->p; dist = it.second; return index; } -unsigned long MeshKDTree::FindNearest(const Base::Vector3f& p, float max_dist, - Base::Vector3f& n, float& dist) const +PointIndex MeshKDTree::FindNearest(const Base::Vector3f& p, float max_dist, + Base::Vector3f& n, float& dist) const { std::pair it = d->kd_tree.find_nearest(Point3d(p,0), max_dist); if (it.first == d->kd_tree.end()) - return ULONG_MAX; - unsigned long index = it.first->i; + return POINT_INDEX_MAX; + PointIndex index = it.first->i; n = it.first->p; dist = it.second; return index; } -unsigned long MeshKDTree::FindExact(const Base::Vector3f& p) const +PointIndex MeshKDTree::FindExact(const Base::Vector3f& p) const { MyKDTree::const_iterator it = d->kd_tree.find_exact(Point3d(p,0)); if (it == d->kd_tree.end()) - return ULONG_MAX; - unsigned long index = it->i; + return POINT_INDEX_MAX; + PointIndex index = it->i; return index; } -void MeshKDTree::FindInRange(const Base::Vector3f& p, float range, std::vector& indices) const +void MeshKDTree::FindInRange(const Base::Vector3f& p, float range, std::vector& indices) const { std::vector v; d->kd_tree.find_within_range(Point3d(p,0), range, std::back_inserter(v)); diff --git a/src/Mod/Mesh/App/Core/KDTree.h b/src/Mod/Mesh/App/Core/KDTree.h index 39e396368c..0ed64ae82e 100644 --- a/src/Mod/Mesh/App/Core/KDTree.h +++ b/src/Mod/Mesh/App/Core/KDTree.h @@ -45,11 +45,11 @@ public: void Clear(); void Optimize(); - unsigned long FindNearest(const Base::Vector3f& p, Base::Vector3f& n, float&) const; - unsigned long FindNearest(const Base::Vector3f& p, float max_dist, + PointIndex FindNearest(const Base::Vector3f& p, Base::Vector3f& n, float&) const; + PointIndex FindNearest(const Base::Vector3f& p, float max_dist, Base::Vector3f& n, float&) const; - unsigned long FindExact(const Base::Vector3f& p) const; - void FindInRange(const Base::Vector3f&, float, std::vector&) const; + PointIndex FindExact(const Base::Vector3f& p) const; + void FindInRange(const Base::Vector3f&, float, std::vector&) const; private: class Private; diff --git a/src/Mod/Mesh/App/Core/MeshIO.cpp b/src/Mod/Mesh/App/Core/MeshIO.cpp index 5184bff722..7a18de2d54 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.cpp +++ b/src/Mod/Mesh/App/Core/MeshIO.cpp @@ -58,7 +58,7 @@ char *upper(char * string) int i; int l; - if (string != NULL) { + if (string != nullptr) { l = std::strlen(string); for (i=0; ipubseekoff(0, std::ios::beg, std::ios::in); return LoadBinarySTL(rstrIn); @@ -1578,7 +1578,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn) } // read the point indices of the facets else if (points && line.find("INDEXEDFACESET {") != std::string::npos) { - unsigned long ulPoints[3]; + PointIndex ulPoints[3]; facets = true; unsigned long ulCt = 0; // Get the next line and check for the index field which might begin @@ -2062,7 +2062,6 @@ bool MeshOutput::SaveAsciiSTL (std::ostream &rstrOut) const MeshFacetIterator clIter(_rclMesh), clEnd(_rclMesh); clIter.Transform(this->_transform); const MeshGeomFacet *pclFacet; - unsigned long i; if (!rstrOut || rstrOut.bad() == true || _rclMesh.CountFacets() == 0) return false; @@ -2088,7 +2087,7 @@ bool MeshOutput::SaveAsciiSTL (std::ostream &rstrOut) const rstrOut << " outer loop\n"; // vertices - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { rstrOut << " vertex " << pclFacet->_aclPoints[i].x << " " << pclFacet->_aclPoints[i].y << " " << pclFacet->_aclPoints[i].z << '\n'; @@ -2305,7 +2304,7 @@ bool MeshOutput::SaveOBJ (std::ostream &out) const for (std::vector::const_iterator gt = _groups.begin(); gt != _groups.end(); ++gt) { out << "g " << Base::Tools::escapedUnicodeFromUtf8(gt->name.c_str()) << '\n'; - for (std::vector::const_iterator it = gt->indices.begin(); it != gt->indices.end(); ++it) { + for (std::vector::const_iterator it = gt->indices.begin(); it != gt->indices.end(); ++it) { const MeshFacet& f = rFacets[*it]; if (first || prev != Kd[*it]) { first = false; @@ -2326,7 +2325,7 @@ bool MeshOutput::SaveOBJ (std::ostream &out) const else { for (std::vector::const_iterator gt = _groups.begin(); gt != _groups.end(); ++gt) { out << "g " << Base::Tools::escapedUnicodeFromUtf8(gt->name.c_str()) << '\n'; - for (std::vector::const_iterator it = gt->indices.begin(); it != gt->indices.end(); ++it) { + for (std::vector::const_iterator it = gt->indices.begin(); it != gt->indices.end(); ++it) { const MeshFacet& f = rFacets[*it]; out << "f " << f._aulPoints[0]+1 << "//" << *it + 1 << " " << f._aulPoints[1]+1 << "//" << *it + 1 << " " @@ -3473,7 +3472,7 @@ bool MeshOutput::SaveVRML (std::ostream &rstrOut) const MeshCleanup::MeshCleanup(MeshPointArray& p, MeshFacetArray& f) : pointArray(p) , facetArray(f) - , materialArray(0) + , materialArray(nullptr) { } @@ -3553,12 +3552,12 @@ void MeshCleanup::RemoveInvalidPoints() [flag](const MeshPoint& p) { return flag(p, MeshPoint::INVALID); }); if (countInvalidPoints > 0) { // generate array of decrements - std::vector decrements; + std::vector decrements; decrements.resize(pointArray.size()); - unsigned long decr = 0; + PointIndex decr = 0; MeshPointArray::_TIterator p_end = pointArray.end(); - std::vector::iterator decr_it = decrements.begin(); + std::vector::iterator decr_it = decrements.begin(); for (MeshPointArray::_TIterator p_it = pointArray.begin(); p_it != p_end; ++p_it, ++decr_it) { *decr_it = decr; if (!p_it->IsValid()) @@ -3655,7 +3654,7 @@ void MeshPointFacetAdjacency::SetFacetNeighbourhood() } if (!success) { - facet1._aulNeighbours[i] = ULONG_MAX; + facet1._aulNeighbours[i] = FACET_INDEX_MAX; } } } diff --git a/src/Mod/Mesh/App/Core/MeshIO.h b/src/Mod/Mesh/App/Core/MeshIO.h index 8c89b90c70..fdb369c348 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.h +++ b/src/Mod/Mesh/App/Core/MeshIO.h @@ -79,7 +79,7 @@ struct MeshExport Material struct MeshExport Group { - std::vector indices; + std::vector indices; std::string name; }; diff --git a/src/Mod/Mesh/App/Core/MeshKernel.cpp b/src/Mod/Mesh/App/Core/MeshKernel.cpp index dbcc8570b8..cca4dd085f 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.cpp +++ b/src/Mod/Mesh/App/Core/MeshKernel.cpp @@ -47,7 +47,7 @@ using namespace MeshCore; -MeshKernel::MeshKernel (void) +MeshKernel::MeshKernel () : _bValid(true) { _clBoundBox.SetVoid(); @@ -115,11 +115,10 @@ MeshKernel& MeshKernel::operator += (const MeshGeomFacet &rclSFacet) void MeshKernel::AddFacet(const MeshGeomFacet &rclSFacet) { - unsigned long i; MeshFacet clFacet; // set corner points - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { _clBoundBox.Add(rclSFacet._aclPoints[i]); clFacet._aulPoints[i] = _aclPointArray.GetOrAddIndex(rclSFacet._aclPoints[i]); } @@ -127,17 +126,17 @@ void MeshKernel::AddFacet(const MeshGeomFacet &rclSFacet) // adjust orientation to normal AdjustNormal(clFacet, rclSFacet.GetNormal()); - unsigned long ulCt = _aclFacetArray.size(); + FacetIndex ulCt = _aclFacetArray.size(); // set neighbourhood - unsigned long ulP0 = clFacet._aulPoints[0]; - unsigned long ulP1 = clFacet._aulPoints[1]; - unsigned long ulP2 = clFacet._aulPoints[2]; - unsigned long ulCC = 0; + PointIndex ulP0 = clFacet._aulPoints[0]; + PointIndex ulP1 = clFacet._aulPoints[1]; + PointIndex ulP2 = clFacet._aulPoints[2]; + FacetIndex ulCC = 0; for (TMeshFacetArray::iterator pF = _aclFacetArray.begin(); pF != _aclFacetArray.end(); ++pF, ulCC++) { for (int i=0; i<3;i++) { - unsigned long ulP = pF->_aulPoints[i]; - unsigned long ulQ = pF->_aulPoints[(i+1)%3]; + PointIndex ulP = pF->_aulPoints[i]; + PointIndex ulQ = pF->_aulPoints[(i+1)%3]; if (ulQ == ulP0 && ulP == ulP1) { clFacet._aulNeighbours[0] = ulCC; pF->_aulNeighbours[i] = ulCt; @@ -183,8 +182,8 @@ unsigned long MeshKernel::AddFacets(const std::vector &rclFAry, // if the manifold check shouldn't be done then just add all faces if (!checkManifolds) { - unsigned long countFacets = CountFacets(); - unsigned long countValid = rclFAry.size(); + FacetIndex countFacets = CountFacets(); + FacetIndex countValid = rclFAry.size(); _aclFacetArray.reserve(countFacets + countValid); // just add all faces now @@ -197,8 +196,8 @@ unsigned long MeshKernel::AddFacets(const std::vector &rclFAry, } this->_aclPointArray.ResetInvalid(); - unsigned long k = CountFacets(); - std::map, std::list > edgeMap; + FacetIndex k = CountFacets(); + std::map, std::list > edgeMap; for (std::vector::const_iterator pF = rclFAry.begin(); pF != rclFAry.end(); ++pF, k++) { // reset INVALID flag for all candidates pF->ResetFlag(MeshFacet::INVALID); @@ -207,10 +206,10 @@ unsigned long MeshKernel::AddFacets(const std::vector &rclFAry, assert( pF->_aulPoints[i] < countPoints ); #endif this->_aclPointArray[pF->_aulPoints[i]].SetFlag(MeshPoint::INVALID); - unsigned long ulT0 = pF->_aulPoints[i]; - unsigned long ulT1 = pF->_aulPoints[(i+1)%3]; - unsigned long ulP0 = std::min(ulT0, ulT1); - unsigned long ulP1 = std::max(ulT0, ulT1); + PointIndex ulT0 = pF->_aulPoints[i]; + PointIndex ulT1 = pF->_aulPoints[(i+1)%3]; + PointIndex ulP0 = std::min(ulT0, ulT1); + PointIndex ulP1 = std::max(ulT0, ulT1); edgeMap[std::make_pair(ulP0, ulP1)].push_front(k); } } @@ -224,12 +223,12 @@ unsigned long MeshKernel::AddFacets(const std::vector &rclFAry, !this->_aclPointArray[pF->_aulPoints[2]].IsFlag(MeshPoint::INVALID)) continue; for (int i=0; i<3; i++) { - unsigned long ulT0 = pF->_aulPoints[i]; - unsigned long ulT1 = pF->_aulPoints[(i+1)%3]; - unsigned long ulP0 = std::min(ulT0, ulT1); - unsigned long ulP1 = std::max(ulT0, ulT1); - std::pair edge = std::make_pair(ulP0, ulP1); - std::map, std::list >::iterator pI = edgeMap.find(edge); + PointIndex ulT0 = pF->_aulPoints[i]; + PointIndex ulT1 = pF->_aulPoints[(i+1)%3]; + PointIndex ulP0 = std::min(ulT0, ulT1); + PointIndex ulP1 = std::max(ulT0, ulT1); + std::pair edge = std::make_pair(ulP0, ulP1); + std::map, std::list >::iterator pI = edgeMap.find(edge); // Does the current facet share the same edge? if (pI != edgeMap.end()) { pI->second.push_front(k); @@ -240,17 +239,17 @@ unsigned long MeshKernel::AddFacets(const std::vector &rclFAry, this->_aclPointArray.ResetInvalid(); // Now let's see for which edges we might get manifolds, if so we don't add the corresponding candidates - unsigned long countFacets = CountFacets(); - std::map, std::list >::iterator pE; + FacetIndex countFacets = CountFacets(); + std::map, std::list >::iterator pE; for (pE = edgeMap.begin(); pE != edgeMap.end(); ++pE) { if (pE->second.size() > 2) { - for (std::list::iterator it = pE->second.begin(); it != pE->second.end(); ++it) + for (std::list::iterator it = pE->second.begin(); it != pE->second.end(); ++it) { if (*it >= countFacets) { // this is a candidate - unsigned long index = *it - countFacets; + FacetIndex index = *it - countFacets; rclFAry[index].SetFlag(MeshFacet::INVALID); } } @@ -260,12 +259,12 @@ unsigned long MeshKernel::AddFacets(const std::vector &rclFAry, // Do not insert directly to the data structure because we should get the correct size of new // facets, otherwise std::vector reallocates too much memory which can't be freed so easily MeshIsNotFlag flag; - unsigned long countValid = std::count_if(rclFAry.begin(), rclFAry.end(), [flag](const MeshFacet& f) { + FacetIndex countValid = std::count_if(rclFAry.begin(), rclFAry.end(), [flag](const MeshFacet& f) { return flag(f, MeshFacet::INVALID); }); _aclFacetArray.reserve( _aclFacetArray.size() + countValid ); // now start inserting the facets to the data structure and set the correct neighbourhood as well - unsigned long startIndex = CountFacets(); + FacetIndex startIndex = CountFacets(); for (std::vector::const_iterator pF = rclFAry.begin(); pF != rclFAry.end(); ++pF) { if (!pF->IsFlag(MeshFacet::INVALID)) { _aclFacetArray.push_back(*pF); @@ -276,55 +275,55 @@ unsigned long MeshKernel::AddFacets(const std::vector &rclFAry, // resolve neighbours for (pE = edgeMap.begin(); pE != edgeMap.end(); ++pE) { - unsigned long ulP0 = pE->first.first; - unsigned long ulP1 = pE->first.second; + PointIndex ulP0 = pE->first.first; + PointIndex ulP1 = pE->first.second; if (pE->second.size() == 1) // border facet { - unsigned long ulF0 = pE->second.front(); + FacetIndex ulF0 = pE->second.front(); if (ulF0 >= countFacets) { ulF0 -= countFacets; std::vector::const_iterator pF = rclFAry.begin() + ulF0; if (!pF->IsFlag(MeshFacet::INVALID)) ulF0 = pF->_ulProp; else - ulF0 = ULONG_MAX; + ulF0 = FACET_INDEX_MAX; } - if (ulF0 != ULONG_MAX) { + if (ulF0 != FACET_INDEX_MAX) { unsigned short usSide = _aclFacetArray[ulF0].Side(ulP0, ulP1); assert(usSide != USHRT_MAX); - _aclFacetArray[ulF0]._aulNeighbours[usSide] = ULONG_MAX; + _aclFacetArray[ulF0]._aulNeighbours[usSide] = FACET_INDEX_MAX; } } else if (pE->second.size() == 2) // normal facet with neighbour { // we must check if both facets are part of the mesh now - unsigned long ulF0 = pE->second.front(); + FacetIndex ulF0 = pE->second.front(); if (ulF0 >= countFacets) { ulF0 -= countFacets; std::vector::const_iterator pF = rclFAry.begin() + ulF0; if (!pF->IsFlag(MeshFacet::INVALID)) ulF0 = pF->_ulProp; else - ulF0 = ULONG_MAX; + ulF0 = FACET_INDEX_MAX; } - unsigned long ulF1 = pE->second.back(); + FacetIndex ulF1 = pE->second.back(); if (ulF1 >= countFacets) { ulF1 -= countFacets; std::vector::const_iterator pF = rclFAry.begin() + ulF1; if (!pF->IsFlag(MeshFacet::INVALID)) ulF1 = pF->_ulProp; else - ulF1 = ULONG_MAX; + ulF1 = FACET_INDEX_MAX; } - if (ulF0 != ULONG_MAX) { + if (ulF0 != FACET_INDEX_MAX) { unsigned short usSide = _aclFacetArray[ulF0].Side(ulP0, ulP1); assert(usSide != USHRT_MAX); _aclFacetArray[ulF0]._aulNeighbours[usSide] = ulF1; } - if (ulF1 != ULONG_MAX) { + if (ulF1 != FACET_INDEX_MAX) { unsigned short usSide = _aclFacetArray[ulF1].Side(ulP0, ulP1); assert(usSide != USHRT_MAX); _aclFacetArray[ulF1]._aulNeighbours[usSide] = ulF0; @@ -360,7 +359,7 @@ void MeshKernel::Merge(const MeshPointArray& rPoints, const MeshFacetArray& rFac return; // nothing to do std::vector increments(rPoints.size()); - unsigned long countFacets = this->_aclFacetArray.size(); + FacetIndex countFacets = this->_aclFacetArray.size(); // Reserve the additional memory to append the new facets this->_aclFacetArray.reserve(this->_aclFacetArray.size() + rFaces.size()); @@ -380,7 +379,7 @@ void MeshKernel::Merge(const MeshPointArray& rPoints, const MeshFacetArray& rFac return v > 0; }); // Reserve the additional memory to append the new points - unsigned long index = this->_aclPointArray.size(); + PointIndex index = this->_aclPointArray.size(); this->_aclPointArray.reserve(this->_aclPointArray.size() + countNewPoints); // Now we can start inserting the points and adjust the point indices of the faces @@ -414,7 +413,7 @@ void MeshKernel::Cleanup() meshCleanup.RemoveInvalids(); } -void MeshKernel::Clear (void) +void MeshKernel::Clear () { _aclPointArray.clear(); _aclFacetArray.clear(); @@ -428,7 +427,7 @@ void MeshKernel::Clear (void) bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter) { - unsigned long i, j, ulNFacet, ulInd; + FacetIndex ulNFacet, ulInd; if (rclIter._clIter >= _aclFacetArray.end()) return false; @@ -437,12 +436,12 @@ bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter) ulInd = rclIter._clIter - _aclFacetArray.begin(); // invalidate neighbour indices of the neighbour facet to this facet - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { ulNFacet = rclIter._clIter->_aulNeighbours[i]; - if (ulNFacet != ULONG_MAX) { - for (j = 0; j < 3; j++) { + if (ulNFacet != FACET_INDEX_MAX) { + for (int j = 0; j < 3; j++) { if (_aclFacetArray[ulNFacet]._aulNeighbours[j] == ulInd) { - _aclFacetArray[ulNFacet]._aulNeighbours[j] = ULONG_MAX; + _aclFacetArray[ulNFacet]._aulNeighbours[j] = FACET_INDEX_MAX; break; } } @@ -450,9 +449,9 @@ bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter) } // erase corner point if needed - for (i = 0; i < 3; i++) { - if ((rclIter._clIter->_aulNeighbours[i] == ULONG_MAX) && - (rclIter._clIter->_aulNeighbours[(i+1)%3] == ULONG_MAX)) { + for (int i = 0; i < 3; i++) { + if ((rclIter._clIter->_aulNeighbours[i] == FACET_INDEX_MAX) && + (rclIter._clIter->_aulNeighbours[(i+1)%3] == FACET_INDEX_MAX)) { // no neighbours, possibly delete point ErasePoint(rclIter._clIter->_aulPoints[(i+1)%3], ulInd); } @@ -464,7 +463,7 @@ bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter) return true; } -bool MeshKernel::DeleteFacet (unsigned long ulInd) +bool MeshKernel::DeleteFacet (FacetIndex ulInd) { if (ulInd >= _aclFacetArray.size()) return false; @@ -475,7 +474,7 @@ bool MeshKernel::DeleteFacet (unsigned long ulInd) return DeleteFacet(clIter); } -void MeshKernel::DeleteFacets (const std::vector &raulFacets) +void MeshKernel::DeleteFacets (const std::vector &raulFacets) { _aclPointArray.SetProperty(0); @@ -488,7 +487,7 @@ void MeshKernel::DeleteFacets (const std::vector &raulFacets) // invalidate facet and adjust number of point references _aclFacetArray.ResetInvalid(); - for (std::vector::const_iterator pI = raulFacets.begin(); pI != raulFacets.end(); ++pI) { + for (std::vector::const_iterator pI = raulFacets.begin(); pI != raulFacets.end(); ++pI) { MeshFacet &rclFacet = _aclFacetArray[*pI]; rclFacet.SetInvalid(); _aclPointArray[rclFacet._aulPoints[0]]._ulProp--; @@ -507,7 +506,7 @@ void MeshKernel::DeleteFacets (const std::vector &raulFacets) RecalcBoundBox(); } -bool MeshKernel::DeletePoint (unsigned long ulInd) +bool MeshKernel::DeletePoint (PointIndex ulInd) { if (ulInd >= _aclPointArray.size()) return false; @@ -522,7 +521,7 @@ bool MeshKernel::DeletePoint (const MeshPointIterator &rclIter) { MeshFacetIterator pFIter(*this), pFEnd(*this); std::vector clToDel; - unsigned long ulInd; + PointIndex ulInd; // index of the point to delete ulInd = rclIter._clIter - _aclPointArray.begin(); @@ -549,10 +548,10 @@ bool MeshKernel::DeletePoint (const MeshPointIterator &rclIter) return true; } -void MeshKernel::DeletePoints (const std::vector &raulPoints) +void MeshKernel::DeletePoints (const std::vector &raulPoints) { _aclPointArray.ResetInvalid(); - for (std::vector::const_iterator pI = raulPoints.begin(); pI != raulPoints.end(); ++pI) + for (std::vector::const_iterator pI = raulPoints.begin(); pI != raulPoints.end(); ++pI) _aclPointArray[*pI].SetInvalid(); // delete facets if at least one corner point is invalid @@ -583,9 +582,8 @@ void MeshKernel::DeletePoints (const std::vector &raulPoints) RecalcBoundBox(); } -void MeshKernel::ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex, bool bOnlySetInvalid) +void MeshKernel::ErasePoint (PointIndex ulIndex, FacetIndex ulFacetIndex, bool bOnlySetInvalid) { - unsigned long i; std::vector::iterator pFIter, pFEnd, pFNot; pFIter = _aclFacetArray.begin(); @@ -594,7 +592,7 @@ void MeshKernel::ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex, // check all facets while (pFIter < pFNot) { - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { if (pFIter->_aulPoints[i] == ulIndex) return; // point still referenced ==> do not delete } @@ -603,7 +601,7 @@ void MeshKernel::ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex, ++pFIter; while (pFIter < pFEnd) { - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { if (pFIter->_aulPoints[i] == ulIndex) return; // point still referenced ==> do not delete } @@ -618,7 +616,7 @@ void MeshKernel::ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex, // correct point indices of the facets pFIter = _aclFacetArray.begin(); while (pFIter < pFEnd) { - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { if (pFIter->_aulPoints[i] > ulIndex) pFIter->_aulPoints[i]--; } @@ -633,7 +631,7 @@ void MeshKernel::RemoveInvalids () { std::vector aulDecrements; std::vector::iterator pDIter; - unsigned long ulDec, i, k; + unsigned long ulDec; MeshPointArray::_TIterator pPIter, pPEnd; MeshFacetArray::_TIterator pFIter, pFEnd; @@ -691,13 +689,13 @@ void MeshKernel::RemoveInvalids () pFEnd = _aclFacetArray.end(); for (pFIter = _aclFacetArray.begin(); pFIter != pFEnd; ++pFIter) { if (pFIter->IsValid() == true) { - for (i = 0; i < 3; i++) { - k = pFIter->_aulNeighbours[i]; - if (k != ULONG_MAX) { + for (int i = 0; i < 3; i++) { + FacetIndex k = pFIter->_aulNeighbours[i]; + if (k != FACET_INDEX_MAX) { if (_aclFacetArray[k].IsValid() == true) pFIter->_aulNeighbours[i] -= aulDecrements[k]; else - pFIter->_aulNeighbours[i] = ULONG_MAX; + pFIter->_aulNeighbours[i] = FACET_INDEX_MAX; } } } @@ -722,28 +720,28 @@ void MeshKernel::RemoveInvalids () void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly, bool bCutInner, std::vector &raclFacets) { - std::vector aulFacets; + std::vector aulFacets; MeshAlgorithm(*this).CheckFacets(rclGrid, pclProj, rclPoly, bCutInner, aulFacets ); - for (std::vector::iterator i = aulFacets.begin(); i != aulFacets.end(); ++i) + for (std::vector::iterator i = aulFacets.begin(); i != aulFacets.end(); ++i) raclFacets.push_back(GetFacet(*i)); DeleteFacets(aulFacets); } void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj, - const Base::Polygon2d& rclPoly, bool bInner, std::vector &raclCutted) + const Base::Polygon2d& rclPoly, bool bInner, std::vector &raclCutted) { MeshAlgorithm(*this).CheckFacets(rclGrid, pclProj, rclPoly, bInner, raclCutted); DeleteFacets(raclCutted); } -std::vector MeshKernel::GetFacetPoints(const std::vector& facets) const +std::vector MeshKernel::GetFacetPoints(const std::vector& facets) const { - std::vector points; - for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { - unsigned long p0, p1, p2; + std::vector points; + for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { + PointIndex p0, p1, p2; GetFacetPoints(*it, p0, p1, p2); points.push_back(p0); points.push_back(p1); @@ -755,11 +753,11 @@ std::vector MeshKernel::GetFacetPoints(const std::vector MeshKernel::GetPointFacets(const std::vector& points) const +std::vector MeshKernel::GetPointFacets(const std::vector& points) const { _aclPointArray.ResetFlag(MeshPoint::TMP0); _aclFacetArray.ResetFlag(MeshFacet::TMP0); - for (std::vector::const_iterator pI = points.begin(); pI != points.end(); ++pI) + for (std::vector::const_iterator pI = points.begin(); pI != points.end(); ++pI) _aclPointArray[*pI].SetFlag(MeshPoint::TMP0); // mark facets if at least one corner point is marked @@ -775,21 +773,21 @@ std::vector MeshKernel::GetPointFacets(const std::vector facets; + std::vector facets; MeshAlgorithm(*this).GetFacetsFlag(facets, MeshFacet::TMP0); return facets; } -std::vector MeshKernel::HasFacets (const MeshPointIterator &rclIter) const +std::vector MeshKernel::HasFacets (const MeshPointIterator &rclIter) const { - unsigned long i, ulPtInd = rclIter.Position(); + PointIndex ulPtInd = rclIter.Position(); std::vector::const_iterator pFIter = _aclFacetArray.begin(); std::vector::const_iterator pFBegin = _aclFacetArray.begin(); std::vector::const_iterator pFEnd = _aclFacetArray.end(); - std::vector aulBelongs; + std::vector aulBelongs; while (pFIter < pFEnd) { - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { if (pFIter->_aulPoints[i] == ulPtInd) { aulBelongs.push_back(pFIter - pFBegin); break; @@ -801,20 +799,20 @@ std::vector MeshKernel::HasFacets (const MeshPointIterator &rclIt return aulBelongs; } -MeshPointArray MeshKernel::GetPoints(const std::vector& indices) const +MeshPointArray MeshKernel::GetPoints(const std::vector& indices) const { MeshPointArray ary; ary.reserve(indices.size()); - for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) + for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) ary.push_back(this->_aclPointArray[*it]); return ary; } -MeshFacetArray MeshKernel::GetFacets(const std::vector& indices) const +MeshFacetArray MeshKernel::GetFacets(const std::vector& indices) const { MeshFacetArray ary; ary.reserve(indices.size()); - for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) + for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) ary.push_back(this->_aclFacetArray[*it]); return ary; } @@ -916,7 +914,7 @@ void MeshKernel::Read (std::istream &rclIn) it->_aulPoints[2] = v3; // On systems where an 'unsigned long' is a 64-bit value - // the empty neighbour must be explicitly set to 'ULONG_MAX' + // the empty neighbour must be explicitly set to 'FACET_INDEX_MAX' // because in algorithms this value is always used to check // for open edges. str >> v1 >> v2 >> v3; @@ -932,17 +930,17 @@ void MeshKernel::Read (std::istream &rclIn) if (v1 < open_edge) it->_aulNeighbours[0] = v1; else - it->_aulNeighbours[0] = ULONG_MAX; + it->_aulNeighbours[0] = FACET_INDEX_MAX; if (v2 < open_edge) it->_aulNeighbours[1] = v2; else - it->_aulNeighbours[1] = ULONG_MAX; + it->_aulNeighbours[1] = FACET_INDEX_MAX; if (v3 < open_edge) it->_aulNeighbours[2] = v3; else - it->_aulNeighbours[2] = ULONG_MAX; + it->_aulNeighbours[2] = FACET_INDEX_MAX; } str >> _clBoundBox.MinX >> _clBoundBox.MaxX; @@ -1021,7 +1019,7 @@ void MeshKernel::Read (std::istream &rclIn) for (int i=0; i<3; i++) { if (it->_aulPoints[i] >= uCtPts) throw Base::BadFormatError("Invalid data structure"); - if (it->_aulNeighbours[i] < ULONG_MAX && it->_aulNeighbours[i] >= uCtFts) + if (it->_aulNeighbours[i] < FACET_INDEX_MAX && it->_aulNeighbours[i] >= uCtFts) throw Base::BadFormatError("Invalid data structure"); } } @@ -1055,7 +1053,7 @@ void MeshKernel::Smooth(int iterations, float stepsize) LaplaceSmoothing(*this).Smooth(iterations); } -void MeshKernel::RecalcBoundBox (void) +void MeshKernel::RecalcBoundBox () { _clBoundBox.SetVoid(); for (MeshPointArray::_TConstIterator pI = _aclPointArray.begin(); pI != _aclPointArray.end(); pI++) @@ -1068,7 +1066,7 @@ std::vector MeshKernel::CalcVertexNormals() const normals.resize(CountPoints()); - unsigned long p1,p2,p3; + PointIndex p1,p2,p3; unsigned int ct = CountFacets(); for (unsigned int pFIter = 0;pFIter < ct; pFIter++) { GetFacetPoints(pFIter,p1,p2,p3); @@ -1082,12 +1080,12 @@ std::vector MeshKernel::CalcVertexNormals() const return normals; } -std::vector MeshKernel::GetFacetNormals(const std::vector& facets) const +std::vector MeshKernel::GetFacetNormals(const std::vector& facets) const { std::vector normals; normals.reserve(facets.size()); - for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { + for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { const MeshFacet& face = _aclFacetArray[*it]; const Base::Vector3f& p1 = _aclPointArray[face._aulPoints[0]]; @@ -1113,12 +1111,12 @@ float MeshKernel::GetSurface() const return fSurface; } -float MeshKernel::GetSurface( const std::vector& aSegment ) const +float MeshKernel::GetSurface( const std::vector& aSegment ) const { float fSurface = 0.0; MeshFacetIterator cIter(*this); - for (std::vector::const_iterator it = aSegment.begin(); it != aSegment.end(); ++it) { + for (std::vector::const_iterator it = aSegment.begin(); it != aSegment.end(); ++it) { cIter.Set(*it); fSurface += cIter->Area(); } @@ -1196,19 +1194,19 @@ void MeshKernel::GetEdges (std::vector& edges) const MeshGeomEdge edge; edge._aclPoints[0] = this->_aclPointArray[it2->pt1]; edge._aclPoints[1] = this->_aclPointArray[it2->pt2]; - edge._bBorder = it2->facetIdx == ULONG_MAX; + edge._bBorder = it2->facetIdx == FACET_INDEX_MAX; edges.push_back(edge); } } -unsigned long MeshKernel::CountEdges (void) const +unsigned long MeshKernel::CountEdges () const { unsigned long openEdges = 0, closedEdges = 0; for (MeshFacetArray::_TConstIterator it = _aclFacetArray.begin(); it != _aclFacetArray.end(); ++it) { for (int i = 0; i < 3; i++) { - if (it->_aulNeighbours[i] == ULONG_MAX) + if (it->_aulNeighbours[i] == FACET_INDEX_MAX) openEdges++; else closedEdges++; diff --git a/src/Mod/Mesh/App/Core/MeshKernel.h b/src/Mod/Mesh/App/Core/MeshKernel.h index b9e3ff399c..fc7b4abb32 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.h +++ b/src/Mod/Mesh/App/Core/MeshKernel.h @@ -24,7 +24,7 @@ #ifndef MESH_KERNEL_H #define MESH_KERNEL_H -#include +#include #include #include "Elements.h" @@ -65,11 +65,11 @@ class MeshExport MeshKernel { public: /// Construction - MeshKernel (void); + MeshKernel (); /// Construction MeshKernel (const MeshKernel &rclMesh); /// Destruction - ~MeshKernel (void) + ~MeshKernel () { Clear(); } /** @name I/O methods */ @@ -82,71 +82,71 @@ public: /** @name Querying */ //@{ /// Returns the number of facets - unsigned long CountFacets (void) const + unsigned long CountFacets () const { return static_cast(_aclFacetArray.size()); } /// Returns the number of edge - unsigned long CountEdges (void) const; + unsigned long CountEdges () const; // Returns the number of points - unsigned long CountPoints (void) const + unsigned long CountPoints () const { return static_cast(_aclPointArray.size()); } /// Returns the number of required memory in bytes - unsigned int GetMemSize (void) const + unsigned int GetMemSize () const { return static_cast(_aclPointArray.size() * sizeof(MeshPoint) + _aclFacetArray.size() * sizeof(MeshFacet)); } /// Determines the bounding box - const Base::BoundBox3f& GetBoundBox (void) const + const Base::BoundBox3f& GetBoundBox () const { return _clBoundBox; } /** Forces a recalculation of the bounding box. This method should be called after * the removal of points.or after a transformation of the data structure. */ - void RecalcBoundBox (void); + void RecalcBoundBox (); /** Returns the point at the given index. This method is rather slow and should be * called occasionally only. For fast access the MeshPointIterator interfsce should * be used. */ - inline MeshPoint GetPoint (unsigned long ulIndex) const; + inline MeshPoint GetPoint (PointIndex ulIndex) const; /** Returns an array of the vertex normals of the mesh. A vertex normal gets calculated * by summarizing the normals of the associated facets. */ std::vector CalcVertexNormals() const; - std::vector GetFacetNormals(const std::vector&) const; + std::vector GetFacetNormals(const std::vector&) const; /** Returns the facet at the given index. This method is rather slow and should be * called occasionally only. For fast access the MeshFacetIterator interface should * be used. */ - inline MeshGeomFacet GetFacet (unsigned long ulIndex) const; + inline MeshGeomFacet GetFacet (FacetIndex ulIndex) const; inline MeshGeomFacet GetFacet (const MeshFacet &rclFacet) const; /** Returns the point indices of the given facet index. */ - inline void GetFacetPoints (unsigned long ulFaIndex, unsigned long &rclP0, - unsigned long &rclP1, unsigned long &rclP2) const; + inline void GetFacetPoints (FacetIndex ulFaIndex, PointIndex &rclP0, + PointIndex &rclP1, PointIndex &rclP2) const; /** Returns the point indices of the given facet indices. */ - std::vector GetFacetPoints(const std::vector&) const; + std::vector GetFacetPoints(const std::vector&) const; /** Returns the facet indices that share the given point indices. */ - std::vector GetPointFacets(const std::vector&) const; + std::vector GetPointFacets(const std::vector&) const; /** Returns the indices of the neighbour facets of the given facet index. */ - inline void GetFacetNeighbours (unsigned long ulIndex, unsigned long &rulNIdx0, - unsigned long &rulNIdx1, unsigned long &rulNIdx2) const; + inline void GetFacetNeighbours (FacetIndex ulIndex, FacetIndex &rulNIdx0, + FacetIndex &rulNIdx1, FacetIndex &rulNIdx2) const; /** Determines all facets that are associated to this point. This method is very * slow and should be called occasionally only. */ - std::vector HasFacets (const MeshPointIterator &rclIter) const; + std::vector HasFacets (const MeshPointIterator &rclIter) const; /** Returns true if the data structure is valid. */ - bool IsValid (void) const + bool IsValid () const { return _bValid; } /** Returns the array of all data points. */ - const MeshPointArray& GetPoints (void) const { return _aclPointArray; } + const MeshPointArray& GetPoints () const { return _aclPointArray; } /** Returns an array of points to the given indices. The indices * must not be out of range. */ - MeshPointArray GetPoints(const std::vector&) const; + MeshPointArray GetPoints(const std::vector&) const; /** Returns a modifier for the point array */ MeshPointModifier ModifyPoints() @@ -155,11 +155,11 @@ public: } /** Returns the array of all facets */ - const MeshFacetArray& GetFacets (void) const { return _aclFacetArray; } + const MeshFacetArray& GetFacets () const { return _aclFacetArray; } /** Returns an array of facets to the given indices. The indices * must not be out of range. */ - MeshFacetArray GetFacets(const std::vector&) const; + MeshFacetArray GetFacets(const std::vector&) const; /** Returns a modifier for the facet array */ MeshFacetModifier ModifyFacets() @@ -179,7 +179,7 @@ public: /** Calculates the surface area of the mesh object. */ float GetSurface() const; /** Calculates the surface area of the segment defined by \a aSegment. */ - float GetSurface( const std::vector& aSegment ) const; + float GetSurface( const std::vector& aSegment ) const; /** Calculates the volume of the mesh object. Therefore the mesh must be a solid, if not 0 * is returned. */ @@ -216,12 +216,12 @@ public: * \note For the start facet \a ulStartFacet MeshFacetVisitor::Visit() does not get invoked though * the facet gets marked as VISIT. */ - unsigned long VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, unsigned long ulStartFacet) const; + unsigned long VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, FacetIndex ulStartFacet) const; /** * Does basically the same as the method above unless the facets that share just a common point * are regared as neighbours. */ - unsigned long VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rclFVisitor, unsigned long ulStartFacet) const; + unsigned long VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rclFVisitor, FacetIndex ulStartFacet) const; //@} /** @name Point visitors @@ -243,7 +243,7 @@ public: * \note For the start facet \a ulStartPoint MeshPointVisitor::Visit() does not get invoked though * the point gets marked as VISIT. */ - unsigned long VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, unsigned long ulStartPoint) const; + unsigned long VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, PointIndex ulStartPoint) const; //@} /** @name Iterators @@ -346,14 +346,14 @@ public: /** * Does basically the same as the method above unless that the index of the facet is given. */ - bool DeleteFacet (unsigned long ulInd); + bool DeleteFacet (FacetIndex ulInd); /** Removes several facets from the data structure. * @note This method overwrites the free usable property of each mesh point. * @note This method also removes points from the structure that are no longer * referenced by the facets. * @note This method is very slow and should only be called occasionally. */ - void DeleteFacets (const std::vector &raulFacets); + void DeleteFacets (const std::vector &raulFacets); /** Deletes the point the iterator points to. The deletion of a point requires the following step: * \li Find all associated facets to this point. * \li Delete these facets. @@ -366,19 +366,19 @@ public: /** * Does basically the same as the method above unless that the index of the facet is given. */ - bool DeletePoint (unsigned long ulInd); + bool DeletePoint (PointIndex ulInd); /** Removes several points from the data structure. * @note This method overwrites the free usable property of each mesh point. */ - void DeletePoints (const std::vector &raulPoints); + void DeletePoints (const std::vector &raulPoints); /** Removes all as INVALID marked points and facets from the structure. */ void RemoveInvalids (); /** Rebuilds the neighbour indices for all facets. */ - void RebuildNeighbours (void); + void RebuildNeighbours (); /** Removes unreferenced points or facets with invalid indices from the mesh. */ void Cleanup(); /** Clears the whole data structure. */ - void Clear (void); + void Clear (); /** Replaces the current data structure with the structure built up of the array * of triangles given in \a rclFAry. */ @@ -404,11 +404,11 @@ public: */ void Transform (const Base::Matrix4D &rclMat); /** Moves the point at the given index along the vector \a rclTrans. */ - inline void MovePoint (unsigned long ulPtIndex, const Base::Vector3f &rclTrans); + inline void MovePoint (PointIndex ulPtIndex, const Base::Vector3f &rclTrans); /** Sets the point at the given index to the new \a rPoint. */ - inline void SetPoint (unsigned long ulPtIndex, const Base::Vector3f &rPoint); + inline void SetPoint (PointIndex ulPtIndex, const Base::Vector3f &rPoint); /** Sets the point at the given index to the new \a rPoint. */ - inline void SetPoint (unsigned long ulPtIndex, float x, float y, float z); + inline void SetPoint (PointIndex ulPtIndex, float x, float y, float z); /** Smoothes the mesh kernel. */ void Smooth(int iterations, float d_max); /** @@ -423,19 +423,19 @@ public: * index number in the facet array of the mesh structure. */ void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclP, const Base::Polygon2d& rclPoly, - bool bCutInner, std::vector &raclCutted); + bool bCutInner, std::vector &raclCutted); //@} protected: /** Rebuilds the neighbour indices for subset of all facets from index \a index on. */ - void RebuildNeighbours (unsigned long); + void RebuildNeighbours (FacetIndex); /** Checks if this point is associated to no other facet and deletes if so. * The point indices of the facets get adjusted. * \a ulIndex is the index of the point to be deleted. \a ulFacetIndex is the index * of the quasi deleted facet and is ignored. If \a bOnlySetInvalid is true the point * doesn't get deleted but marked as invalid. */ - void ErasePoint (unsigned long ulIndex, unsigned long ulFacetIndex, bool bOnlySetInvalid = false); + void ErasePoint (PointIndex ulIndex, FacetIndex ulFacetIndex, bool bOnlySetInvalid = false); /** Adjusts the facet's orierntation to the given normal direction. */ inline void AdjustNormal (MeshFacet &rclFacet, const Base::Vector3f &rclNormal); @@ -460,13 +460,13 @@ protected: friend class MeshTrimming; }; -inline MeshPoint MeshKernel::GetPoint (unsigned long ulIndex) const +inline MeshPoint MeshKernel::GetPoint (PointIndex ulIndex) const { assert(ulIndex < _aclPointArray.size()); return _aclPointArray[ulIndex]; } -inline MeshGeomFacet MeshKernel::GetFacet (unsigned long ulIndex) const +inline MeshGeomFacet MeshKernel::GetFacet (FacetIndex ulIndex) const { assert(ulIndex < _aclFacetArray.size()); @@ -498,8 +498,8 @@ inline MeshGeomFacet MeshKernel::GetFacet (const MeshFacet &rclFacet) const return clFacet; } -inline void MeshKernel::GetFacetNeighbours (unsigned long ulIndex, unsigned long &rulNIdx0, - unsigned long &rulNIdx1, unsigned long &rulNIdx2) const +inline void MeshKernel::GetFacetNeighbours (FacetIndex ulIndex, FacetIndex &rulNIdx0, + FacetIndex &rulNIdx1, FacetIndex &rulNIdx2) const { assert(ulIndex < _aclFacetArray.size()); @@ -508,17 +508,17 @@ inline void MeshKernel::GetFacetNeighbours (unsigned long ulIndex, unsigned long rulNIdx2 = _aclFacetArray[ulIndex]._aulNeighbours[2]; } -inline void MeshKernel::MovePoint (unsigned long ulPtIndex, const Base::Vector3f &rclTrans) +inline void MeshKernel::MovePoint (PointIndex ulPtIndex, const Base::Vector3f &rclTrans) { _aclPointArray[ulPtIndex] += rclTrans; } -inline void MeshKernel::SetPoint (unsigned long ulPtIndex, const Base::Vector3f &rPoint) +inline void MeshKernel::SetPoint (PointIndex ulPtIndex, const Base::Vector3f &rPoint) { _aclPointArray[ulPtIndex] = rPoint; } -inline void MeshKernel::SetPoint (unsigned long ulPtIndex, float x, float y, float z) +inline void MeshKernel::SetPoint (PointIndex ulPtIndex, float x, float y, float z) { _aclPointArray[ulPtIndex].Set(x,y,z); } @@ -550,8 +550,8 @@ inline Base::Vector3f MeshKernel::GetGravityPoint (const MeshFacet &rclFacet) co (p0.z+p1.z+p2.z)/3.0f); } -inline void MeshKernel::GetFacetPoints (unsigned long ulFaIndex, unsigned long &rclP0, - unsigned long &rclP1, unsigned long &rclP2) const +inline void MeshKernel::GetFacetPoints (FacetIndex ulFaIndex, PointIndex &rclP0, + PointIndex &rclP1, PointIndex &rclP2) const { assert(ulFaIndex < _aclFacetArray.size()); const MeshFacet& rclFacet = _aclFacetArray[ulFaIndex]; diff --git a/src/Mod/Mesh/App/Core/Projection.cpp b/src/Mod/Mesh/App/Core/Projection.cpp index b7ff4d7578..a3a238c016 100644 --- a/src/Mod/Mesh/App/Core/Projection.cpp +++ b/src/Mod/Mesh/App/Core/Projection.cpp @@ -139,8 +139,8 @@ bool MeshProjection::connectLines(std::list< std::pair& polyline) { @@ -150,7 +150,7 @@ bool MeshProjection::projectLineOnMesh(const MeshFacetGrid& grid, dir.Normalize(); - std::vector facets; + std::vector facets; // special case: start and endpoint inside same facet if (f1 == f2) { @@ -172,8 +172,7 @@ bool MeshProjection::projectLineOnMesh(const MeshFacetGrid& grid, // cut all facets with plane std::list< std::pair > cutLine; - //unsigned long start = 0, end = 0; - for (std::vector::iterator it = facets.begin(); it != facets.end(); ++it) { + for (std::vector::iterator it = facets.begin(); it != facets.end(); ++it) { Base::Vector3f e1, e2; MeshGeomFacet tria = kernel.GetFacet(*it); if (bboxInsideRectangle(tria.GetBoundBox(), v1, v2, vd)) { diff --git a/src/Mod/Mesh/App/Core/Projection.h b/src/Mod/Mesh/App/Core/Projection.h index a09e68c04e..0ce76df03e 100644 --- a/src/Mod/Mesh/App/Core/Projection.h +++ b/src/Mod/Mesh/App/Core/Projection.h @@ -27,6 +27,7 @@ #include #include #include +#include using Base::Vector3f; @@ -48,8 +49,8 @@ public: MeshProjection(const MeshKernel&); ~MeshProjection(); - bool projectLineOnMesh(const MeshFacetGrid& grid, const Base::Vector3f& p1, unsigned long f1, - const Base::Vector3f& p2, unsigned long f2, const Base::Vector3f& view, + bool projectLineOnMesh(const MeshFacetGrid& grid, const Base::Vector3f& p1, FacetIndex f1, + const Base::Vector3f& p2, FacetIndex f2, const Base::Vector3f& view, std::vector& polyline); protected: bool bboxInsideRectangle (const Base::BoundBox3f& bbox, const Base::Vector3f& p1, const Base::Vector3f& p2, const Base::Vector3f& view) const; diff --git a/src/Mod/Mesh/App/Core/Segmentation.cpp b/src/Mod/Mesh/App/Core/Segmentation.cpp index 5e84f92ba4..3739af1e38 100644 --- a/src/Mod/Mesh/App/Core/Segmentation.cpp +++ b/src/Mod/Mesh/App/Core/Segmentation.cpp @@ -31,11 +31,11 @@ using namespace MeshCore; -void MeshSurfaceSegment::Initialize(unsigned long) +void MeshSurfaceSegment::Initialize(FacetIndex) { } -bool MeshSurfaceSegment::TestInitialFacet(unsigned long) const +bool MeshSurfaceSegment::TestInitialFacet(FacetIndex) const { return true; } @@ -44,14 +44,14 @@ void MeshSurfaceSegment::AddFacet(const MeshFacet&) { } -void MeshSurfaceSegment::AddSegment(const std::vector& segm) +void MeshSurfaceSegment::AddSegment(const std::vector& segm) { if (segm.size() >= minFacets) { segments.push_back(segm); } } -MeshSegment MeshSurfaceSegment::FindSegment(unsigned long index) const +MeshSegment MeshSurfaceSegment::FindSegment(FacetIndex index) const { for (std::vector::const_iterator it = segments.begin(); it != segments.end(); ++it) { if (std::find(it->begin(), it->end(), index) != it->end()) @@ -73,7 +73,7 @@ MeshDistancePlanarSegment::~MeshDistancePlanarSegment() delete fitter; } -void MeshDistancePlanarSegment::Initialize(unsigned long index) +void MeshDistancePlanarSegment::Initialize(FacetIndex index) { fitter->Clear(); @@ -312,7 +312,7 @@ SphereSurfaceFit::SphereSurfaceFit() SphereSurfaceFit::SphereSurfaceFit(const Base::Vector3f& c, float r) : center(c) , radius(r) - , fitter(0) + , fitter(nullptr) { } @@ -408,13 +408,13 @@ MeshDistanceGenericSurfaceFitSegment::~MeshDistanceGenericSurfaceFitSegment() delete fitter; } -void MeshDistanceGenericSurfaceFitSegment::Initialize(unsigned long index) +void MeshDistanceGenericSurfaceFitSegment::Initialize(FacetIndex index) { MeshGeomFacet triangle = kernel.GetFacet(index); fitter->Initialize(triangle); } -bool MeshDistanceGenericSurfaceFitSegment::TestInitialFacet(unsigned long index) const +bool MeshDistanceGenericSurfaceFitSegment::TestInitialFacet(FacetIndex index) const { MeshGeomFacet triangle = kernel.GetFacet(index); for (int i=0; i<3; i++) { @@ -511,7 +511,7 @@ bool MeshCurvatureFreeformSegment::TestFacet (const MeshFacet &rclFacet) const // -------------------------------------------------------- -MeshSurfaceVisitor::MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector &indices) +MeshSurfaceVisitor::MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector &indices) : indices(indices), segm(segm) { } @@ -521,13 +521,13 @@ MeshSurfaceVisitor::~MeshSurfaceVisitor () } bool MeshSurfaceVisitor::AllowVisit (const MeshFacet& face, const MeshFacet&, - unsigned long, unsigned long, unsigned short) + FacetIndex, unsigned long, unsigned short) { return segm.TestFacet(face); } bool MeshSurfaceVisitor::Visit (const MeshFacet & face, const MeshFacet &, - unsigned long ulFInd, unsigned long) + FacetIndex ulFInd, unsigned long) { indices.push_back(ulFInd); segm.AddFacet(face); @@ -539,7 +539,7 @@ bool MeshSurfaceVisitor::Visit (const MeshFacet & face, const MeshFacet &, void MeshSegmentAlgorithm::FindSegments(std::vector& segm) { // reset VISIT flags - unsigned long startFacet; + FacetIndex startFacet; MeshCore::MeshAlgorithm cAlgo(myKernel); cAlgo.ResetFacetFlag(MeshCore::MeshFacet::VISIT); @@ -550,7 +550,7 @@ void MeshSegmentAlgorithm::FindSegments(std::vector& segm // start from the first not visited facet cAlgo.CountFacetFlag(MeshCore::MeshFacet::VISIT); - std::vector resetVisited; + std::vector resetVisited; for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) { cAlgo.ResetFacetsFlag(resetVisited, MeshCore::MeshFacet::VISIT); @@ -563,10 +563,10 @@ void MeshSegmentAlgorithm::FindSegments(std::vector& segm if (iCur < iEnd) startFacet = iCur - iBeg; else - startFacet = ULONG_MAX; - while (startFacet != ULONG_MAX) { + startFacet = FACET_INDEX_MAX; + while (startFacet != FACET_INDEX_MAX) { // collect all facets of the same geometry - std::vector indices; + std::vector indices; (*it)->Initialize(startFacet); if ((*it)->TestInitialFacet(startFacet)) indices.push_back(startFacet); @@ -588,7 +588,7 @@ void MeshSegmentAlgorithm::FindSegments(std::vector& segm if (iCur < iEnd) startFacet = iCur - iBeg; else - startFacet = ULONG_MAX; + startFacet = FACET_INDEX_MAX; } } } diff --git a/src/Mod/Mesh/App/Core/Segmentation.h b/src/Mod/Mesh/App/Core/Segmentation.h index 0a90070f6f..f17593a35d 100644 --- a/src/Mod/Mesh/App/Core/Segmentation.h +++ b/src/Mod/Mesh/App/Core/Segmentation.h @@ -35,7 +35,7 @@ class PlaneFit; class CylinderFit; class SphereFit; class MeshFacet; -typedef std::vector MeshSegment; +typedef std::vector MeshSegment; class MeshExport MeshSurfaceSegment { @@ -45,12 +45,12 @@ public: virtual ~MeshSurfaceSegment() {} virtual bool TestFacet (const MeshFacet &rclFacet) const = 0; virtual const char* GetType() const = 0; - virtual void Initialize(unsigned long); - virtual bool TestInitialFacet(unsigned long) const; + virtual void Initialize(FacetIndex); + virtual bool TestInitialFacet(FacetIndex) const; virtual void AddFacet(const MeshFacet& rclFacet); - void AddSegment(const std::vector&); + void AddSegment(const std::vector&); const std::vector& GetSegments() const { return segments; } - MeshSegment FindSegment(unsigned long) const; + MeshSegment FindSegment(FacetIndex) const; protected: std::vector segments; @@ -78,7 +78,7 @@ public: virtual ~MeshDistancePlanarSegment(); bool TestFacet (const MeshFacet& rclFacet) const; const char* GetType() const { return "Plane"; } - void Initialize(unsigned long); + void Initialize(FacetIndex); void AddFacet(const MeshFacet& rclFacet); protected: @@ -174,8 +174,8 @@ public: virtual ~MeshDistanceGenericSurfaceFitSegment(); bool TestFacet (const MeshFacet& rclFacet) const; const char* GetType() const { return fitter->GetType(); } - void Initialize(unsigned long); - bool TestInitialFacet(unsigned long) const; + void Initialize(FacetIndex); + bool TestInitialFacet(FacetIndex) const; void AddFacet(const MeshFacet& rclFacet); std::vector Parameters() const; @@ -254,15 +254,15 @@ private: class MeshExport MeshSurfaceVisitor : public MeshFacetVisitor { public: - MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector &indices); + MeshSurfaceVisitor (MeshSurfaceSegment& segm, std::vector &indices); virtual ~MeshSurfaceVisitor (); bool AllowVisit (const MeshFacet& face, const MeshFacet&, - unsigned long, unsigned long, unsigned short neighbourIndex); + FacetIndex, unsigned long, unsigned short neighbourIndex); bool Visit (const MeshFacet & face, const MeshFacet &, - unsigned long ulFInd, unsigned long); + FacetIndex ulFInd, unsigned long); protected: - std::vector &indices; + std::vector &indices; MeshSurfaceSegment& segm; }; diff --git a/src/Mod/Mesh/App/Core/SetOperations.cpp b/src/Mod/Mesh/App/Core/SetOperations.cpp index ede6b0b084..244b424228 100644 --- a/src/Mod/Mesh/App/Core/SetOperations.cpp +++ b/src/Mod/Mesh/App/Core/SetOperations.cpp @@ -59,7 +59,7 @@ SetOperations::SetOperations (const MeshKernel &cutMesh1, const MeshKernel &cutM { } -SetOperations::~SetOperations (void) +SetOperations::~SetOperations () { } @@ -74,7 +74,7 @@ void SetOperations::Do () // _builder.clear(); //Base::Sequencer().next(); - std::set facetsCuttingEdge0, facetsCuttingEdge1; + std::set facetsCuttingEdge0, facetsCuttingEdge1; Cut(facetsCuttingEdge0, facetsCuttingEdge1); // no intersection curve of the meshes found @@ -170,7 +170,7 @@ void SetOperations::Do () MeshDefinitions::SetMinPointDistance(saveMinMeshDistance); } -void SetOperations::Cut (std::set& facetsCuttingEdge0, std::set& facetsCuttingEdge1) +void SetOperations::Cut (std::set& facetsCuttingEdge0, std::set& facetsCuttingEdge1) { MeshFacetGrid grid1(_cutMesh0, 20); MeshFacetGrid grid2(_cutMesh1, 20); @@ -189,24 +189,24 @@ void SetOperations::Cut (std::set& facetsCuttingEdge0, std::set 0) { - std::vector vecFacets2; + std::vector vecFacets2; grid2.Inside(grid1.GetBoundBox(gx1, gy1, gz1), vecFacets2); if (vecFacets2.size() > 0) { - std::set vecFacets1; + std::set vecFacets1; grid1.GetElements(gx1, gy1, gz1, vecFacets1); - std::set::iterator it1; + std::set::iterator it1; for (it1 = vecFacets1.begin(); it1 != vecFacets1.end(); ++it1) { - unsigned long fidx1 = *it1; + FacetIndex fidx1 = *it1; MeshGeomFacet f1 = _cutMesh0.GetFacet(*it1); - std::vector::iterator it2; + std::vector::iterator it2; for (it2 = vecFacets2.begin(); it2 != vecFacets2.end(); ++it2) { - unsigned long fidx2 = *it2; + FacetIndex fidx2 = *it2; MeshGeomFacet f2 = _cutMesh1.GetFacet(fidx2); MeshPoint p0, p1; @@ -304,13 +304,13 @@ void SetOperations::Cut (std::set& facetsCuttingEdge0, std::set::iterator> >::iterator it1; + std::map::iterator> >::iterator it1; for (it1 = _facet2points[side].begin(); it1 != _facet2points[side].end(); ++it1) { std::vector points; std::set pointsSet; - unsigned long fidx = it1->first; + FacetIndex fidx = it1->first; MeshGeomFacet f = cutMesh.GetFacet(fidx); //if (side == 1) @@ -468,7 +468,7 @@ void SetOperations::CollectFacets (int side, float mult) { if (!itf->IsFlag(MeshFacet::VISIT)) { // Facet found, visit neighbours - std::vector facets; + std::vector facets; facets.push_back(itf - rFacets.begin()); // add seed facet CollectFacetVisitor visitor(mesh, facets, _edges, side, mult, _builder); mesh.VisitNeighbourFacets(visitor, itf - rFacets.begin()); @@ -492,7 +492,7 @@ void SetOperations::CollectFacets (int side, float mult) // MeshDefinitions::SetMinPointDistance(distSave); } -SetOperations::CollectFacetVisitor::CollectFacetVisitor (const MeshKernel& mesh, std::vector& facets, +SetOperations::CollectFacetVisitor::CollectFacetVisitor (const MeshKernel& mesh, std::vector& facets, std::map& edges, int side, float mult, Base::Builder3D& builder) : _facets(facets) @@ -506,7 +506,7 @@ SetOperations::CollectFacetVisitor::CollectFacetVisitor (const MeshKernel& mesh, } bool SetOperations::CollectFacetVisitor::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, - unsigned long ulFInd, unsigned long ulLevel) + FacetIndex ulFInd, unsigned long ulLevel) { (void)rclFacet; (void)rclFrom; @@ -517,14 +517,14 @@ bool SetOperations::CollectFacetVisitor::Visit (const MeshFacet &rclFacet, const //static int matchCounter = 0; bool SetOperations::CollectFacetVisitor::AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom, - unsigned long ulFInd, unsigned long ulLevel, + FacetIndex ulFInd, unsigned long ulLevel, unsigned short neighbourIndex) { (void)ulFInd; (void)ulLevel; if (rclFacet.IsFlag(MeshFacet::MARKED) && rclFrom.IsFlag(MeshFacet::MARKED)) { // facet connected to an edge - unsigned long pt0 = rclFrom._aulPoints[neighbourIndex], pt1 = rclFrom._aulPoints[(neighbourIndex+1)%3]; + PointIndex pt0 = rclFrom._aulPoints[neighbourIndex], pt1 = rclFrom._aulPoints[(neighbourIndex+1)%3]; Edge edge(_mesh.GetPoint(pt0), _mesh.GetPoint(pt1)); std::map::iterator it = _edges.find(edge); diff --git a/src/Mod/Mesh/App/Core/SetOperations.h b/src/Mod/Mesh/App/Core/SetOperations.h index 9d68155607..6ec708f443 100644 --- a/src/Mod/Mesh/App/Core/SetOperations.h +++ b/src/Mod/Mesh/App/Core/SetOperations.h @@ -59,7 +59,7 @@ public: /// Construction SetOperations (const MeshKernel &cutMesh1, const MeshKernel &cutMesh2, MeshKernel &result, OperationType opType, float minDistanceToPoint = 1e-5f); /// Destruction - virtual ~SetOperations (void); + virtual ~SetOperations (); public: @@ -116,7 +116,7 @@ private: public: int fcounter[2]; // counter of facets attacted to the edge MeshGeomFacet facets[2][2]; // Geom-Facets attached to the edge - unsigned long facet[2]; // underlying Facet-Index + FacetIndex facet[2]; // underlying Facet-Index EdgeInfo () { @@ -146,7 +146,7 @@ private: class CollectFacetVisitor : public MeshFacetVisitor { public: - std::vector &_facets; + std::vector &_facets; const MeshKernel &_mesh; std::map &_edges; int _side; @@ -154,9 +154,9 @@ private: int _addFacets; // 0: add facets to the result 1: do not add facets to the result Base::Builder3D& _builder; - CollectFacetVisitor (const MeshKernel& mesh, std::vector& facets, std::map& edges, int side, float mult, Base::Builder3D& builder); - bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel); - bool AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom, unsigned long ulFInd, unsigned long ulLevel, unsigned short neighbourIndex); + CollectFacetVisitor (const MeshKernel& mesh, std::vector& facets, std::map& edges, int side, float mult, Base::Builder3D& builder); + bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, FacetIndex ulFInd, unsigned long ulLevel); + bool AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom, FacetIndex ulFInd, unsigned long ulLevel, unsigned short neighbourIndex); }; /** all points from cut */ @@ -164,14 +164,14 @@ private: /** all edges */ std::map _edges; /** map from facet index to its cut points (mesh 1 and mesh 2) Key: Facet-Index Value: List of iterators of set */ - std::map::iterator> > _facet2points[2]; + std::map::iterator> > _facet2points[2]; /** Facets collected from region growing */ std::vector _facetsOf[2]; std::vector _newMeshFacets[2]; /** Cut mesh 1 with mesh 2 */ - void Cut (std::set& facetsNotCuttingEdge0, std::set& facetsCuttingEdge1); + void Cut (std::set& facetsNotCuttingEdge0, std::set& facetsCuttingEdge1); /** Trianglute each facets cut with its cutting points */ void TriangulateMesh (const MeshKernel &cutMesh, int side); /** search facets for adding (with region growing) */ diff --git a/src/Mod/Mesh/App/Core/Smoothing.cpp b/src/Mod/Mesh/App/Core/Smoothing.cpp index 5dcc3f119e..e0345cd9f1 100644 --- a/src/Mod/Mesh/App/Core/Smoothing.cpp +++ b/src/Mod/Mesh/App/Core/Smoothing.cpp @@ -78,11 +78,11 @@ void PlaneFitSmoothing::Smooth(unsigned int iterations) MeshCore::PlaneFit pf; pf.AddPoint(*v_it); center = *v_it; - const std::set& cv = vv_it[v_it.Position()]; + const std::set& cv = vv_it[v_it.Position()]; if (cv.size() < 3) continue; - std::set::const_iterator cv_it; + std::set::const_iterator cv_it; for (cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) { pf.AddPoint(v_beg[*cv_it]); center += v_beg[*cv_it]; @@ -109,14 +109,14 @@ void PlaneFitSmoothing::Smooth(unsigned int iterations) } // assign values without affecting iterators - unsigned long count = kernel.CountPoints(); - for (unsigned long idx = 0; idx < count; idx++) { + PointIndex count = kernel.CountPoints(); + for (PointIndex idx = 0; idx < count; idx++) { kernel.SetPoint(idx, PointArray[idx]); } } } -void PlaneFitSmoothing::SmoothPoints(unsigned int iterations, const std::vector& point_indices) +void PlaneFitSmoothing::SmoothPoints(unsigned int iterations, const std::vector& point_indices) { MeshCore::MeshPoint center; MeshCore::MeshPointArray PointArray = kernel.GetPoints(); @@ -127,16 +127,16 @@ void PlaneFitSmoothing::SmoothPoints(unsigned int iterations, const std::vector< for (unsigned int i=0; i::const_iterator it = point_indices.begin(); it != point_indices.end(); ++it) { + for (std::vector::const_iterator it = point_indices.begin(); it != point_indices.end(); ++it) { v_it.Set(*it); MeshCore::PlaneFit pf; pf.AddPoint(*v_it); center = *v_it; - const std::set& cv = vv_it[v_it.Position()]; + const std::set& cv = vv_it[v_it.Position()]; if (cv.size() < 3) continue; - std::set::const_iterator cv_it; + std::set::const_iterator cv_it; for (cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) { pf.AddPoint(v_beg[*cv_it]); center += v_beg[*cv_it]; @@ -163,8 +163,8 @@ void PlaneFitSmoothing::SmoothPoints(unsigned int iterations, const std::vector< } // assign values without affecting iterators - unsigned long count = kernel.CountPoints(); - for (unsigned long idx = 0; idx < count; idx++) { + PointIndex count = kernel.CountPoints(); + for (PointIndex idx = 0; idx < count; idx++) { kernel.SetPoint(idx, PointArray[idx]); } } @@ -186,9 +186,9 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it, MeshCore::MeshPointArray::_TConstIterator v_it, v_beg = points.begin(), v_end = points.end(); - unsigned long pos = 0; + PointIndex pos = 0; for (v_it = points.begin(); v_it != v_end; ++v_it,++pos) { - const std::set& cv = vv_it[pos]; + const std::set& cv = vv_it[pos]; if (cv.size() < 3) continue; if (cv.size() != vf_it[pos].size()) { @@ -201,7 +201,7 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it, w=1.0/double(n_count); double delx=0.0,dely=0.0,delz=0.0; - std::set::const_iterator cv_it; + std::set::const_iterator cv_it; for (cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) { delx += w*static_cast((v_beg[*cv_it]).x-v_it->x); dely += w*static_cast((v_beg[*cv_it]).y-v_it->y); @@ -217,13 +217,13 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it, void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it, const MeshRefPointToFacets& vf_it, double stepsize, - const std::vector& point_indices) + const std::vector& point_indices) { const MeshCore::MeshPointArray& points = kernel.GetPoints(); MeshCore::MeshPointArray::_TConstIterator v_beg = points.begin(); - for (std::vector::const_iterator pos = point_indices.begin(); pos != point_indices.end(); ++pos) { - const std::set& cv = vv_it[*pos]; + for (std::vector::const_iterator pos = point_indices.begin(); pos != point_indices.end(); ++pos) { + const std::set& cv = vv_it[*pos]; if (cv.size() < 3) continue; if (cv.size() != vf_it[*pos].size()) { @@ -236,7 +236,7 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it, w=1.0/double(n_count); double delx=0.0,dely=0.0,delz=0.0; - std::set::const_iterator cv_it; + std::set::const_iterator cv_it; for (cv_it = cv.begin(); cv_it !=cv.end(); ++cv_it) { delx += w*static_cast((v_beg[*cv_it]).x-(v_beg[*pos]).x); dely += w*static_cast((v_beg[*cv_it]).y-(v_beg[*pos]).y); @@ -260,7 +260,7 @@ void LaplaceSmoothing::Smooth(unsigned int iterations) } } -void LaplaceSmoothing::SmoothPoints(unsigned int iterations, const std::vector& point_indices) +void LaplaceSmoothing::SmoothPoints(unsigned int iterations, const std::vector& point_indices) { MeshCore::MeshRefPointToPoints vv_it(kernel); MeshCore::MeshRefPointToFacets vf_it(kernel); @@ -292,7 +292,7 @@ void TaubinSmoothing::Smooth(unsigned int iterations) } } -void TaubinSmoothing::SmoothPoints(unsigned int iterations, const std::vector& point_indices) +void TaubinSmoothing::SmoothPoints(unsigned int iterations, const std::vector& point_indices) { MeshCore::MeshRefPointToPoints vv_it(kernel); MeshCore::MeshRefPointToFacets vf_it(kernel); diff --git a/src/Mod/Mesh/App/Core/Smoothing.h b/src/Mod/Mesh/App/Core/Smoothing.h index 7373984e13..300d97b1d5 100644 --- a/src/Mod/Mesh/App/Core/Smoothing.h +++ b/src/Mod/Mesh/App/Core/Smoothing.h @@ -25,6 +25,7 @@ #define MESH_SMOOTHING_H #include +#include "Definitions.h" namespace MeshCore { @@ -54,7 +55,7 @@ public: /** Smooth the triangle mesh. */ virtual void Smooth(unsigned int) = 0; - virtual void SmoothPoints(unsigned int, const std::vector&) = 0; + virtual void SmoothPoints(unsigned int, const std::vector&) = 0; protected: MeshKernel& kernel; @@ -70,7 +71,7 @@ public: PlaneFitSmoothing(MeshKernel&); virtual ~PlaneFitSmoothing(); void Smooth(unsigned int); - void SmoothPoints(unsigned int, const std::vector&); + void SmoothPoints(unsigned int, const std::vector&); }; class MeshExport LaplaceSmoothing : public AbstractSmoothing @@ -79,7 +80,7 @@ public: LaplaceSmoothing(MeshKernel&); virtual ~LaplaceSmoothing(); void Smooth(unsigned int); - void SmoothPoints(unsigned int, const std::vector&); + void SmoothPoints(unsigned int, const std::vector&); void SetLambda(double l) { lambda = l;} protected: @@ -87,7 +88,7 @@ protected: const MeshRefPointToFacets&, double); void Umbrella(const MeshRefPointToPoints&, const MeshRefPointToFacets&, double, - const std::vector&); + const std::vector&); protected: double lambda; @@ -99,7 +100,7 @@ public: TaubinSmoothing(MeshKernel&); virtual ~TaubinSmoothing(); void Smooth(unsigned int); - void SmoothPoints(unsigned int, const std::vector&); + void SmoothPoints(unsigned int, const std::vector&); void SetMicro(double m) { micro = m;} protected: diff --git a/src/Mod/Mesh/App/Core/Tools.cpp b/src/Mod/Mesh/App/Core/Tools.cpp index eb1d212434..d2de883957 100644 --- a/src/Mod/Mesh/App/Core/Tools.cpp +++ b/src/Mod/Mesh/App/Core/Tools.cpp @@ -53,7 +53,7 @@ void MeshSearchNeighbours::Reinit (float fSampleDistance) MeshAlgorithm(_rclMesh).ResetPointFlag(MeshPoint::MARKED); } -unsigned long MeshSearchNeighbours::NeighboursFromFacet (unsigned long ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector &raclResultPoints) +unsigned long MeshSearchNeighbours::NeighboursFromFacet (FacetIndex ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector &raclResultPoints) { bool bAddPoints = false; @@ -82,12 +82,12 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (unsigned long ulFacetId while ((bFound == true) && (nCtExpandRadius < 10)) { bFound = false; - std::set aclTmp; + std::set aclTmp; aclTmp.swap(_aclOuter); - for (std::set::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) { - const std::set &rclISet = _clPt2Fa[*pI]; + for (std::set::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) { + const std::set &rclISet = _clPt2Fa[*pI]; // search all facets hanging on this point - for (std::set::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) { + for (std::set::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) { const MeshFacet &rclF = f_beg[*pJ]; if (rclF.IsFlag(MeshFacet::MARKED) == false) { @@ -114,14 +114,14 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (unsigned long ulFacetId for (std::vector::iterator pF = aclTestedFacet.begin(); pF != aclTestedFacet.end(); ++pF) (*pF)->ResetFlag(MeshFacet::MARKED); - for (std::set::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR) + for (std::set::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR) _rclPAry[*pR].ResetFlag(MeshPoint::MARKED); // copy points in result container raclResultPoints.resize(_aclResult.size()); size_t i = 0; - for (std::set::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++) + for (std::set::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++) raclResultPoints[i] = _rclPAry[*pI]; if (bAddPoints == true) { @@ -133,7 +133,7 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (unsigned long ulFacetId return ulVisited; } -void MeshSearchNeighbours::SampleAllFacets (void) +void MeshSearchNeighbours::SampleAllFacets () { if (_aclSampledFacets.size() == _rclMesh.CountFacets()) return; // already sampled, do nothing @@ -149,7 +149,7 @@ void MeshSearchNeighbours::SampleAllFacets (void) } } -unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (unsigned long ulFacetIdx, float fDistance, std::vector &raclResultPoints) +unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (FacetIndex ulFacetIdx, float fDistance, std::vector &raclResultPoints) { SampleAllFacets(); @@ -175,12 +175,12 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (unsigned long u while (bFound == true) { bFound = false; - std::set aclTmp; + std::set aclTmp; aclTmp.swap(_aclOuter); - for (std::set::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) { - const std::set &rclISet = _clPt2Fa[*pI]; + for (std::set::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) { + const std::set &rclISet = _clPt2Fa[*pI]; // search all facets hanging on this point - for (std::set::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) { + for (std::set::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) { const MeshFacet &rclF = f_beg[*pJ]; if (rclF.IsFlag(MeshFacet::MARKED) == false) { @@ -203,7 +203,7 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (unsigned long u std::copy(_aclPointsResult.begin(), _aclPointsResult.end(), raclResultPoints.begin()); // facet points - for (std::set::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI) { + for (std::set::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI) { if (InnerPoint(_rclPAry[*pI]) == true) raclResultPoints.push_back(_rclPAry[*pI]); } @@ -211,12 +211,12 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (unsigned long u return ulVisited; } -bool MeshSearchNeighbours::AccumulateNeighbours (const MeshFacet &rclF, unsigned long ulFIdx) +bool MeshSearchNeighbours::AccumulateNeighbours (const MeshFacet &rclF, FacetIndex ulFIdx) { int k = 0; for (int i = 0; i < 3; i++) { - unsigned long ulPIdx = rclF._aulPoints[i]; + PointIndex ulPIdx = rclF._aulPoints[i]; _aclOuter.insert(ulPIdx); _aclResult.insert(ulPIdx); @@ -251,7 +251,7 @@ bool MeshSearchNeighbours::ExpandRadius (unsigned long ulMinPoints) { // add facets from current level _aclResult.insert(_aclOuter.begin(), _aclOuter.end()); - for (std::set::iterator pI = _aclOuter.begin(); pI != _aclOuter.end(); ++pI) + for (std::set::iterator pI = _aclOuter.begin(); pI != _aclOuter.end(); ++pI) _rclPAry[*pI].SetFlag(MeshPoint::MARKED); if (_aclResult.size() < ulMinPoints) { @@ -262,9 +262,9 @@ bool MeshSearchNeighbours::ExpandRadius (unsigned long ulMinPoints) return false; } -unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (unsigned long ulFacetIdx, float fDistance, std::vector &raclResultPoints, std::vector &raclResultFacets) +unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (FacetIndex ulFacetIdx, float fDistance, std::vector &raclResultPoints, std::vector &raclResultFacets) { - std::set aulFacetSet; + std::set aulFacetSet; _fMaxDistanceP2 = fDistance * fDistance; _clCenter = _rclMesh.GetFacet(ulFacetIdx).GetGravityPoint(); @@ -287,12 +287,12 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (unsigned long ulFa while (bFound == true) { bFound = false; - std::set aclTmp; + std::set aclTmp; aclTmp.swap(_aclOuter); - for (std::set::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) { - const std::set &rclISet = _clPt2Fa[*pI]; + for (std::set::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) { + const std::set &rclISet = _clPt2Fa[*pI]; // search all facets hanging on this point - for (std::set::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) { + for (std::set::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) { const MeshFacet &rclF = f_beg[*pJ]; for (int i = 0; i < 3; i++) { @@ -317,13 +317,13 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (unsigned long ulFa // reset marked facets, points for (std::vector::iterator pF = aclTestedFacet.begin(); pF != aclTestedFacet.end(); ++pF) (*pF)->ResetFlag(MeshFacet::MARKED); - for (std::set::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR) + for (std::set::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR) _rclPAry[*pR].ResetFlag(MeshPoint::MARKED); // copy points in result container raclResultPoints.resize(_aclResult.size()); size_t i = 0; - for (std::set::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++) + for (std::set::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++) raclResultPoints[i] = _rclPAry[*pI]; // copy facets in result container diff --git a/src/Mod/Mesh/App/Core/Tools.h b/src/Mod/Mesh/App/Core/Tools.h index 76269b4e9c..a6fc191850 100644 --- a/src/Mod/Mesh/App/Core/Tools.h +++ b/src/Mod/Mesh/App/Core/Tools.h @@ -51,18 +51,18 @@ public: * inside a sphere of radius \a fDistance, center \a center of the original facet. This method uses the * MARKED flags. */ - unsigned long NeighboursFromFacet (unsigned long ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector &raclResultPoints); + unsigned long NeighboursFromFacet (FacetIndex ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector &raclResultPoints); /** Searches for facets from the start facet, sample the neighbour facets and accumulates the points. */ - unsigned long NeighboursFromSampledFacets (unsigned long ulFacetIdx, float fDistance, std::vector &raclResultPoints); + unsigned long NeighboursFromSampledFacets (FacetIndex ulFacetIdx, float fDistance, std::vector &raclResultPoints); /** Searches for facets from the start facet. */ - unsigned long NeighboursFacetFromFacet (unsigned long ulFacetIdx, float fDistance, std::vector &raclResultPoints, - std::vector &raclResultFacets); + unsigned long NeighboursFacetFromFacet (FacetIndex ulFacetIdx, float fDistance, std::vector &raclResultPoints, + std::vector &raclResultFacets); protected: /** Subsamples the mesh. */ - void SampleAllFacets (void); + void SampleAllFacets (); inline bool CheckDistToFacet (const MeshFacet &rclF); // check distance to facet, add points inner radius - bool AccumulateNeighbours (const MeshFacet &rclF, unsigned long ulFIdx); // accumulate the sample neighbours facet + bool AccumulateNeighbours (const MeshFacet &rclF, FacetIndex ulFIdx); // accumulate the sample neighbours facet inline bool InnerPoint (const Base::Vector3f &rclPt) const; inline bool TriangleCutsSphere (const MeshFacet &rclF) const; bool ExpandRadius (unsigned long ulMinPoints); @@ -81,8 +81,8 @@ protected: MeshRefPointToFacets _clPt2Fa; float _fMaxDistanceP2; // square distance Base::Vector3f _clCenter; // center points of start facet - std::set _aclResult; // result container (point indices) - std::set _aclOuter; // next searching points + std::set _aclResult; // result container (point indices) + std::set _aclOuter; // next searching points std::vector _aclPointsResult; // result as vertex std::vector > _aclSampledFacets; // sample points from each facet float _fSampleDistance; // distance between two sampled points @@ -100,7 +100,7 @@ inline bool MeshSearchNeighbours::CheckDistToFacet (const MeshFacet &rclF) for (int i = 0; i < 3; i++) { - unsigned long ulPIdx = rclF._aulPoints[i]; + PointIndex ulPIdx = rclF._aulPoints[i]; if (_rclPAry[ulPIdx].IsFlag(MeshPoint::MARKED) == false) { if (Base::DistanceP2(_clCenter, _rclPAry[ulPIdx]) < _fMaxDistanceP2) @@ -146,7 +146,7 @@ class MeshFaceIterator public: MeshFaceIterator(const MeshKernel& mesh) : it(mesh) {} - Base::Vector3f operator() (unsigned long index) + Base::Vector3f operator() (FacetIndex index) { it.Set(index); return it->GetGravityPoint(); @@ -161,7 +161,7 @@ class MeshVertexIterator public: MeshVertexIterator(const MeshKernel& mesh) : it(mesh) {} - Base::Vector3f operator() (unsigned long index) + Base::Vector3f operator() (PointIndex index) { it.Set(index); return *it; @@ -175,9 +175,10 @@ template class MeshNearestIndexToPlane { public: + using Index = typename T::Index; MeshNearestIndexToPlane(const MeshKernel& mesh, const Base::Vector3f& b, const Base::Vector3f& n) - : nearest_index(ULONG_MAX),nearest_dist(FLOAT_MAX), it(mesh), base(b), normal(n) {} - void operator() (unsigned long index) + : nearest_index(-1),nearest_dist(FLOAT_MAX), it(mesh), base(b), normal(n) {} + void operator() (Index index) { float dist = (float)fabs(it(index).DistanceToPlane(base, normal)); if (dist < nearest_dist) { @@ -186,7 +187,7 @@ public: } } - unsigned long nearest_index; + Index nearest_index; float nearest_dist; private: diff --git a/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp b/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp index 76f13a68f1..bdd151e27c 100644 --- a/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp +++ b/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp @@ -44,26 +44,26 @@ using namespace MeshCore; MeshTopoAlgorithm::MeshTopoAlgorithm (MeshKernel &rclM) -: _rclMesh(rclM), _needsCleanup(false), _cache(0) +: _rclMesh(rclM), _needsCleanup(false), _cache(nullptr) { } -MeshTopoAlgorithm::~MeshTopoAlgorithm (void) +MeshTopoAlgorithm::~MeshTopoAlgorithm () { if ( _needsCleanup ) Cleanup(); EndCache(); } -bool MeshTopoAlgorithm::InsertVertex(unsigned long ulFacetPos, const Base::Vector3f& rclPoint) +bool MeshTopoAlgorithm::InsertVertex(FacetIndex ulFacetPos, const Base::Vector3f& rclPoint) { MeshFacet& rclF = _rclMesh._aclFacetArray[ulFacetPos]; MeshFacet clNewFacet1, clNewFacet2; // insert new point - unsigned long ulPtCnt = _rclMesh._aclPointArray.size(); - unsigned long ulPtInd = this->GetOrAddIndex(rclPoint); - unsigned long ulSize = _rclMesh._aclFacetArray.size(); + PointIndex ulPtCnt = _rclMesh._aclPointArray.size(); + PointIndex ulPtInd = this->GetOrAddIndex(rclPoint); + FacetIndex ulSize = _rclMesh._aclFacetArray.size(); if ( ulPtInd < ulPtCnt ) return false; // the given point is already part of the mesh => creating new facets would be an illegal operation @@ -85,9 +85,9 @@ bool MeshTopoAlgorithm::InsertVertex(unsigned long ulFacetPos, const Base::Vecto clNewFacet2._aulNeighbours[1] = ulFacetPos; clNewFacet2._aulNeighbours[2] = ulSize; // adjust the neighbour facet - if (rclF._aulNeighbours[1] != ULONG_MAX) + if (rclF._aulNeighbours[1] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclF._aulNeighbours[1]].ReplaceNeighbour(ulFacetPos, ulSize); - if (rclF._aulNeighbours[2] != ULONG_MAX) + if (rclF._aulNeighbours[2] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclF._aulNeighbours[2]].ReplaceNeighbour(ulFacetPos, ulSize+1); // original facet rclF._aulPoints[2] = ulPtInd; @@ -101,7 +101,7 @@ bool MeshTopoAlgorithm::InsertVertex(unsigned long ulFacetPos, const Base::Vecto return true; } -bool MeshTopoAlgorithm::SnapVertex(unsigned long ulFacetPos, const Base::Vector3f& rP) +bool MeshTopoAlgorithm::SnapVertex(FacetIndex ulFacetPos, const Base::Vector3f& rP) { MeshFacet& rFace = _rclMesh._aclFacetArray[ulFacetPos]; if (!rFace.HasOpenEdge()) @@ -109,7 +109,7 @@ bool MeshTopoAlgorithm::SnapVertex(unsigned long ulFacetPos, const Base::Vector3 Base::Vector3f cNo1 = _rclMesh.GetNormal(rFace); for (unsigned short i=0; i<3; i++) { - if (rFace._aulNeighbours[i]==ULONG_MAX) + if (rFace._aulNeighbours[i]==FACET_INDEX_MAX) { const Base::Vector3f& rPt1 = _rclMesh._aclPointArray[rFace._aulPoints[i]]; const Base::Vector3f& rPt2 = _rclMesh._aclPointArray[rFace._aulPoints[(i+1)%3]]; @@ -146,21 +146,21 @@ void MeshTopoAlgorithm::OptimizeTopology(float fMaxAngle) { // For each internal edge get the adjacent facets. When doing an edge swap we must update // this structure. - std::map, std::vector > aEdge2Face; + std::map, std::vector > aEdge2Face; for (MeshFacetArray::_TIterator pI = _rclMesh._aclFacetArray.begin(); pI != _rclMesh._aclFacetArray.end(); ++pI) { for (int i = 0; i < 3; i++) { // ignore open edges - if (pI->_aulNeighbours[i] != ULONG_MAX) { - unsigned long ulPt0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - unsigned long ulPt1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - aEdge2Face[std::pair(ulPt0, ulPt1)].push_back(pI - _rclMesh._aclFacetArray.begin()); + if (pI->_aulNeighbours[i] != FACET_INDEX_MAX) { + PointIndex ulPt0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + PointIndex ulPt1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + aEdge2Face[std::pair(ulPt0, ulPt1)].push_back(pI - _rclMesh._aclFacetArray.begin()); } } } // fill up this list with all internal edges and perform swap edges until this list is empty - std::list > aEdgeList; - std::map, std::vector >::iterator pE; + std::list > aEdgeList; + std::map, std::vector >::iterator pE; for (pE = aEdge2Face.begin(); pE != aEdge2Face.end(); ++pE) { if (pE->second.size() == 2) // make sure that we really have an internal edge aEdgeList.push_back(pE->first); @@ -172,7 +172,7 @@ void MeshTopoAlgorithm::OptimizeTopology(float fMaxAngle) // Perform a swap edge where needed while (!aEdgeList.empty() && uMaxIter > 0) { // get the first edge and remove it from the list - std::pair aEdge = aEdgeList.front(); + std::pair aEdge = aEdgeList.front(); aEdgeList.pop_front(); uMaxIter--; @@ -199,10 +199,10 @@ void MeshTopoAlgorithm::OptimizeTopology(float fMaxAngle) // adjust the edge list for (int i=0; i<3; i++) { - std::map, std::vector >::iterator it; + std::map, std::vector >::iterator it; // first facet - unsigned long ulPt0 = std::min(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]); - unsigned long ulPt1 = std::max(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]); + PointIndex ulPt0 = std::min(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]); + PointIndex ulPt1 = std::max(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]); it = aEdge2Face.find( std::make_pair(ulPt0, ulPt1) ); if (it != aEdge2Face.end()) { if (it->second[0] == pE->second[1]) @@ -213,8 +213,8 @@ void MeshTopoAlgorithm::OptimizeTopology(float fMaxAngle) } // second facet - ulPt0 = std::min(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]); - ulPt1 = std::max(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]); + ulPt0 = std::min(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]); + ulPt1 = std::max(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]); it = aEdge2Face.find( std::make_pair(ulPt0, ulPt1) ); if (it != aEdge2Face.end()) { if (it->second[0] == pE->second[0]) @@ -226,9 +226,9 @@ void MeshTopoAlgorithm::OptimizeTopology(float fMaxAngle) } // Now we must remove the edge and replace it through the new edge - unsigned long ulPt0 = std::min(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]); - unsigned long ulPt1 = std::max(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]); - std::pair aNewEdge = std::make_pair(ulPt0, ulPt1); + PointIndex ulPt0 = std::min(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]); + PointIndex ulPt1 = std::max(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]); + std::pair aNewEdge = std::make_pair(ulPt0, ulPt1); aEdge2Face[aNewEdge] = pE->second; aEdge2Face.erase(pE); } @@ -261,25 +261,25 @@ static float swap_benefit(const Base::Vector3f &v1, const Base::Vector3f &v2, std::max(-cos_maxangle(v1,v2,v4), -cos_maxangle(v2,v3,v4)); } -float MeshTopoAlgorithm::SwapEdgeBenefit(unsigned long f, int e) const +float MeshTopoAlgorithm::SwapEdgeBenefit(FacetIndex f, int e) const { const MeshFacetArray& faces = _rclMesh.GetFacets(); const MeshPointArray& vertices = _rclMesh.GetPoints(); - unsigned long n = faces[f]._aulNeighbours[e]; - if (n == ULONG_MAX) + FacetIndex n = faces[f]._aulNeighbours[e]; + if (n == FACET_INDEX_MAX) return 0.0f; // border edge - unsigned long v1 = faces[f]._aulPoints[e]; - unsigned long v2 = faces[f]._aulPoints[(e+1)%3]; - unsigned long v3 = faces[f]._aulPoints[(e+2)%3]; + PointIndex v1 = faces[f]._aulPoints[e]; + PointIndex v2 = faces[f]._aulPoints[(e+1)%3]; + PointIndex v3 = faces[f]._aulPoints[(e+2)%3]; unsigned short s = faces[n].Side(faces[f]); if (s == USHRT_MAX) { std::cerr << "MeshTopoAlgorithm::SwapEdgeBenefit: error in neighbourhood " << "of faces " << f << " and " << n << std::endl; return 0.0f; // topological error } - unsigned long v4 = faces[n]._aulPoints[(s+2)%3]; + PointIndex v4 = faces[n]._aulPoints[(s+2)%3]; if (v3 == v4) { std::cerr << "MeshTopoAlgorithm::SwapEdgeBenefit: duplicate faces " << f << " and " << n << std::endl; @@ -289,7 +289,7 @@ float MeshTopoAlgorithm::SwapEdgeBenefit(unsigned long f, int e) const vertices[v1], vertices[v4]); } -typedef std::pair FaceEdge; // (face, edge) pair +typedef std::pair FaceEdge; // (face, edge) pair typedef std::pair FaceEdgePriority; void MeshTopoAlgorithm::OptimizeTopology() @@ -297,9 +297,9 @@ void MeshTopoAlgorithm::OptimizeTopology() // Find all edges that can be swapped and insert them into a // priority queue const MeshFacetArray& faces = _rclMesh.GetFacets(); - unsigned long nf = _rclMesh.CountFacets(); + FacetIndex nf = _rclMesh.CountFacets(); std::priority_queue todo; - for (unsigned long i = 0; i < nf; i++) { + for (FacetIndex i = 0; i < nf; i++) { for (int j = 0; j < 3; j++) { float b = SwapEdgeBenefit(i, j); if (b > 0.0f) @@ -309,14 +309,14 @@ void MeshTopoAlgorithm::OptimizeTopology() // Edges are sorted in decreasing order with respect to their benefit while (!todo.empty()) { - unsigned long f = todo.top().second.first; + FacetIndex f = todo.top().second.first; int e = todo.top().second.second; todo.pop(); // Check again if the swap should still be done if (SwapEdgeBenefit(f, e) <= 0.0f) continue; // OK, swap the edge - unsigned long f2 = faces[f]._aulNeighbours[e]; + FacetIndex f2 = faces[f]._aulNeighbours[e]; SwapEdge(f, f2); // Insert new edges into queue, if necessary for (int j = 0; j < 3; j++) { @@ -335,23 +335,23 @@ void MeshTopoAlgorithm::OptimizeTopology() void MeshTopoAlgorithm::DelaunayFlip(float fMaxAngle) { // For each internal edge get the adjacent facets. - std::set > aEdge2Face; - unsigned long index = 0; + std::set > aEdge2Face; + FacetIndex index = 0; for (MeshFacetArray::_TIterator pI = _rclMesh._aclFacetArray.begin(); pI != _rclMesh._aclFacetArray.end(); ++pI, index++) { for (int i = 0; i < 3; i++) { // ignore open edges - if (pI->_aulNeighbours[i] != ULONG_MAX) { - unsigned long ulFt0 = std::min(index, pI->_aulNeighbours[i]); - unsigned long ulFt1 = std::max(index, pI->_aulNeighbours[i]); - aEdge2Face.insert(std::pair(ulFt0, ulFt1)); + if (pI->_aulNeighbours[i] != FACET_INDEX_MAX) { + FacetIndex ulFt0 = std::min(index, pI->_aulNeighbours[i]); + FacetIndex ulFt1 = std::max(index, pI->_aulNeighbours[i]); + aEdge2Face.insert(std::pair(ulFt0, ulFt1)); } } } Base::Vector3f center; while (!aEdge2Face.empty()) { - std::set >::iterator it = aEdge2Face.begin(); - std::pair edge = *it; + std::set >::iterator it = aEdge2Face.begin(); + std::pair edge = *it; aEdge2Face.erase(it); if (ShouldSwapEdge(edge.first, edge.second, fMaxAngle)) { float radius = _rclMesh.GetFacet(edge.first).CenterOfCircumCircle(center); @@ -363,15 +363,15 @@ void MeshTopoAlgorithm::DelaunayFlip(float fMaxAngle) if (Base::DistanceP2(center, vertex) < radius) { SwapEdge(edge.first, edge.second); for (int i=0; i<3; i++) { - if (face_1._aulNeighbours[i] != ULONG_MAX && face_1._aulNeighbours[i] != edge.second) { - unsigned long ulFt0 = std::min(edge.first, face_1._aulNeighbours[i]); - unsigned long ulFt1 = std::max(edge.first, face_1._aulNeighbours[i]); - aEdge2Face.insert(std::pair(ulFt0, ulFt1)); + if (face_1._aulNeighbours[i] != FACET_INDEX_MAX && face_1._aulNeighbours[i] != edge.second) { + FacetIndex ulFt0 = std::min(edge.first, face_1._aulNeighbours[i]); + FacetIndex ulFt1 = std::max(edge.first, face_1._aulNeighbours[i]); + aEdge2Face.insert(std::pair(ulFt0, ulFt1)); } - if (face_2._aulNeighbours[i] != ULONG_MAX && face_2._aulNeighbours[i] != edge.first) { - unsigned long ulFt0 = std::min(edge.second, face_2._aulNeighbours[i]); - unsigned long ulFt1 = std::max(edge.second, face_2._aulNeighbours[i]); - aEdge2Face.insert(std::pair(ulFt0, ulFt1)); + if (face_2._aulNeighbours[i] != FACET_INDEX_MAX && face_2._aulNeighbours[i] != edge.first) { + FacetIndex ulFt0 = std::min(edge.second, face_2._aulNeighbours[i]); + FacetIndex ulFt1 = std::max(edge.second, face_2._aulNeighbours[i]); + aEdge2Face.insert(std::pair(ulFt0, ulFt1)); } } } @@ -384,13 +384,13 @@ int MeshTopoAlgorithm::DelaunayFlip() int cnt_swap=0; _rclMesh._aclFacetArray.ResetFlag(MeshFacet::TMP0); size_t cnt_facets = _rclMesh._aclFacetArray.size(); - for (unsigned long i=0;i, std::list > aclEdgeMap; + FacetIndex k = 0; + std::map, std::list > aclEdgeMap; for ( std::vector::const_iterator jt = raFts.begin(); jt != raFts.end(); ++jt, k++ ) { for (int i=0; i<3; i++) { - unsigned long ulT0 = jt->_aulPoints[i]; - unsigned long ulT1 = jt->_aulPoints[(i+1)%3]; - unsigned long ulP0 = std::min(ulT0, ulT1); - unsigned long ulP1 = std::max(ulT0, ulT1); + PointIndex ulT0 = jt->_aulPoints[i]; + PointIndex ulT1 = jt->_aulPoints[(i+1)%3]; + PointIndex ulP0 = std::min(ulT0, ulT1); + PointIndex ulP1 = std::max(ulT0, ulT1); aclEdgeMap[std::make_pair(ulP0, ulP1)].push_front(k); aIdx.push_back( static_cast(jt->_aulPoints[i]) ); } @@ -460,20 +460,20 @@ void MeshTopoAlgorithm::AdjustEdgesToCurvatureDirection() raFts.ResetFlag(MeshFacet::VISIT); const MeshPointArray& raPts = _rclMesh.GetPoints(); - for ( std::map, std::list >::iterator kt = aclEdgeMap.begin(); kt != aclEdgeMap.end(); ++kt ) + for ( std::map, std::list >::iterator kt = aclEdgeMap.begin(); kt != aclEdgeMap.end(); ++kt ) { if ( kt->second.size() == 2 ) { - unsigned long uPt1 = kt->first.first; - unsigned long uPt2 = kt->first.second; - unsigned long uFt1 = kt->second.front(); - unsigned long uFt2 = kt->second.back(); + PointIndex uPt1 = kt->first.first; + PointIndex uPt2 = kt->first.second; + FacetIndex uFt1 = kt->second.front(); + FacetIndex uFt2 = kt->second.back(); const MeshFacet& rFace1 = raFts[uFt1]; const MeshFacet& rFace2 = raFts[uFt2]; if ( rFace1.IsFlag(MeshFacet::VISIT) || rFace2.IsFlag(MeshFacet::VISIT) ) continue; - unsigned long uPt3, uPt4; + PointIndex uPt3, uPt4; unsigned short side = rFace1.Side(uPt1, uPt2); uPt3 = rFace1._aulPoints[(side+2)%3]; side = rFace2.Side(uPt1, uPt2); @@ -513,24 +513,23 @@ void MeshTopoAlgorithm::AdjustEdgesToCurvatureDirection() } } -bool MeshTopoAlgorithm::InsertVertexAndSwapEdge(unsigned long ulFacetPos, const Base::Vector3f& rclPoint, float fMaxAngle) +bool MeshTopoAlgorithm::InsertVertexAndSwapEdge(FacetIndex ulFacetPos, const Base::Vector3f& rclPoint, float fMaxAngle) { if ( !InsertVertex(ulFacetPos, rclPoint) ) return false; // get the created elements - unsigned long ulF1Ind = _rclMesh._aclFacetArray.size()-2; - unsigned long ulF2Ind = _rclMesh._aclFacetArray.size()-1; + FacetIndex ulF1Ind = _rclMesh._aclFacetArray.size()-2; + FacetIndex ulF2Ind = _rclMesh._aclFacetArray.size()-1; MeshFacet& rclF1 = _rclMesh._aclFacetArray[ulFacetPos]; MeshFacet& rclF2 = _rclMesh._aclFacetArray[ulF1Ind]; MeshFacet& rclF3 = _rclMesh._aclFacetArray[ulF2Ind]; // first facet - int i; - for ( i=0; i<3; i++ ) + for (int i=0; i<3; i++ ) { - unsigned long uNeighbour = rclF1._aulNeighbours[i]; - if ( uNeighbour!=ULONG_MAX && uNeighbour!=ulF1Ind && uNeighbour!=ulF2Ind ) + FacetIndex uNeighbour = rclF1._aulNeighbours[i]; + if ( uNeighbour!=FACET_INDEX_MAX && uNeighbour!=ulF1Ind && uNeighbour!=ulF2Ind ) { if ( ShouldSwapEdge(ulFacetPos, uNeighbour, fMaxAngle) ) { SwapEdge(ulFacetPos, uNeighbour); @@ -538,11 +537,11 @@ bool MeshTopoAlgorithm::InsertVertexAndSwapEdge(unsigned long ulFacetPos, const } } } - for ( i=0; i<3; i++ ) + for (int i=0; i<3; i++ ) { // second facet - unsigned long uNeighbour = rclF2._aulNeighbours[i]; - if ( uNeighbour!=ULONG_MAX && uNeighbour!=ulFacetPos && uNeighbour!=ulF2Ind ) + FacetIndex uNeighbour = rclF2._aulNeighbours[i]; + if ( uNeighbour!=FACET_INDEX_MAX && uNeighbour!=ulFacetPos && uNeighbour!=ulF2Ind ) { if ( ShouldSwapEdge(ulF1Ind, uNeighbour, fMaxAngle) ) { SwapEdge(ulF1Ind, uNeighbour); @@ -552,10 +551,10 @@ bool MeshTopoAlgorithm::InsertVertexAndSwapEdge(unsigned long ulFacetPos, const } // third facet - for ( i=0; i<3; i++ ) + for (int i=0; i<3; i++ ) { - unsigned long uNeighbour = rclF3._aulNeighbours[i]; - if ( uNeighbour!=ULONG_MAX && uNeighbour!=ulFacetPos && uNeighbour!=ulF1Ind ) + FacetIndex uNeighbour = rclF3._aulNeighbours[i]; + if ( uNeighbour!=FACET_INDEX_MAX && uNeighbour!=ulFacetPos && uNeighbour!=ulF1Ind ) { if ( ShouldSwapEdge(ulF2Ind, uNeighbour, fMaxAngle) ) { SwapEdge(ulF2Ind, uNeighbour); @@ -567,7 +566,7 @@ bool MeshTopoAlgorithm::InsertVertexAndSwapEdge(unsigned long ulFacetPos, const return true; } -bool MeshTopoAlgorithm::IsSwapEdgeLegal(unsigned long ulFacetPos, unsigned long ulNeighbour) const +bool MeshTopoAlgorithm::IsSwapEdgeLegal(FacetIndex ulFacetPos, FacetIndex ulNeighbour) const { MeshFacet& rclF = _rclMesh._aclFacetArray[ulFacetPos]; MeshFacet& rclN = _rclMesh._aclFacetArray[ulNeighbour]; @@ -607,7 +606,7 @@ bool MeshTopoAlgorithm::IsSwapEdgeLegal(unsigned long ulFacetPos, unsigned long return true; } -bool MeshTopoAlgorithm::ShouldSwapEdge(unsigned long ulFacetPos, unsigned long ulNeighbour, float fMaxAngle) const +bool MeshTopoAlgorithm::ShouldSwapEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour, float fMaxAngle) const { if (!IsSwapEdgeLegal(ulFacetPos, ulNeighbour)) return false; @@ -640,7 +639,7 @@ bool MeshTopoAlgorithm::ShouldSwapEdge(unsigned long ulFacetPos, unsigned long u return fMax12 > fMax34; } -void MeshTopoAlgorithm::SwapEdge(unsigned long ulFacetPos, unsigned long ulNeighbour) +void MeshTopoAlgorithm::SwapEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour) { MeshFacet& rclF = _rclMesh._aclFacetArray[ulFacetPos]; MeshFacet& rclN = _rclMesh._aclFacetArray[ulNeighbour]; @@ -652,9 +651,9 @@ void MeshTopoAlgorithm::SwapEdge(unsigned long ulFacetPos, unsigned long ulNeigh return; // not neighbours // adjust the neighbourhood - if (rclF._aulNeighbours[(uFSide+1)%3] != ULONG_MAX) + if (rclF._aulNeighbours[(uFSide+1)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclF._aulNeighbours[(uFSide+1)%3]].ReplaceNeighbour(ulFacetPos, ulNeighbour); - if (rclN._aulNeighbours[(uNSide+1)%3] != ULONG_MAX) + if (rclN._aulNeighbours[(uNSide+1)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclN._aulNeighbours[(uNSide+1)%3]].ReplaceNeighbour(ulNeighbour, ulFacetPos); // swap the point and neighbour indices @@ -666,7 +665,7 @@ void MeshTopoAlgorithm::SwapEdge(unsigned long ulFacetPos, unsigned long ulNeigh rclN._aulNeighbours[(uNSide+1)%3] = ulFacetPos; } -bool MeshTopoAlgorithm::SplitEdge(unsigned long ulFacetPos, unsigned long ulNeighbour, const Base::Vector3f& rP) +bool MeshTopoAlgorithm::SplitEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour, const Base::Vector3f& rP) { MeshFacet& rclF = _rclMesh._aclFacetArray[ulFacetPos]; MeshFacet& rclN = _rclMesh._aclFacetArray[ulNeighbour]; @@ -677,9 +676,9 @@ bool MeshTopoAlgorithm::SplitEdge(unsigned long ulFacetPos, unsigned long ulNeig if (uFSide == USHRT_MAX || uNSide == USHRT_MAX) return false; // not neighbours - unsigned long uPtCnt = _rclMesh._aclPointArray.size(); - unsigned long uPtInd = this->GetOrAddIndex(rP); - unsigned long ulSize = _rclMesh._aclFacetArray.size(); + PointIndex uPtCnt = _rclMesh._aclPointArray.size(); + PointIndex uPtInd = this->GetOrAddIndex(rP); + FacetIndex ulSize = _rclMesh._aclFacetArray.size(); // the given point is already part of the mesh => creating new facets would // be an illegal operation @@ -687,9 +686,9 @@ bool MeshTopoAlgorithm::SplitEdge(unsigned long ulFacetPos, unsigned long ulNeig return false; // adjust the neighbourhood - if (rclF._aulNeighbours[(uFSide+1)%3] != ULONG_MAX) + if (rclF._aulNeighbours[(uFSide+1)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclF._aulNeighbours[(uFSide+1)%3]].ReplaceNeighbour(ulFacetPos, ulSize); - if (rclN._aulNeighbours[(uNSide+2)%3] != ULONG_MAX) + if (rclN._aulNeighbours[(uNSide+2)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclN._aulNeighbours[(uNSide+2)%3]].ReplaceNeighbour(ulNeighbour, ulSize+1); MeshFacet cNew1, cNew2; @@ -720,28 +719,28 @@ bool MeshTopoAlgorithm::SplitEdge(unsigned long ulFacetPos, unsigned long ulNeig return true; } -void MeshTopoAlgorithm::SplitOpenEdge(unsigned long ulFacetPos, unsigned short uSide, const Base::Vector3f& rP) +void MeshTopoAlgorithm::SplitOpenEdge(FacetIndex ulFacetPos, unsigned short uSide, const Base::Vector3f& rP) { MeshFacet& rclF = _rclMesh._aclFacetArray[ulFacetPos]; - if (rclF._aulNeighbours[uSide] != ULONG_MAX) + if (rclF._aulNeighbours[uSide] != FACET_INDEX_MAX) return; // not open - unsigned long uPtCnt = _rclMesh._aclPointArray.size(); - unsigned long uPtInd = this->GetOrAddIndex(rP); - unsigned long ulSize = _rclMesh._aclFacetArray.size(); + PointIndex uPtCnt = _rclMesh._aclPointArray.size(); + PointIndex uPtInd = this->GetOrAddIndex(rP); + FacetIndex ulSize = _rclMesh._aclFacetArray.size(); if (uPtInd < uPtCnt) return; // the given point is already part of the mesh => creating new facets would be an illegal operation // adjust the neighbourhood - if (rclF._aulNeighbours[(uSide+1)%3] != ULONG_MAX) + if (rclF._aulNeighbours[(uSide+1)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclF._aulNeighbours[(uSide+1)%3]].ReplaceNeighbour(ulFacetPos, ulSize); MeshFacet cNew; cNew._aulPoints[0] = uPtInd; cNew._aulPoints[1] = rclF._aulPoints[(uSide+1)%3]; cNew._aulPoints[2] = rclF._aulPoints[(uSide+2)%3]; - cNew._aulNeighbours[0] = ULONG_MAX; + cNew._aulNeighbours[0] = FACET_INDEX_MAX; cNew._aulNeighbours[1] = rclF._aulNeighbours[(uSide+1)%3]; cNew._aulNeighbours[2] = ulFacetPos; @@ -771,7 +770,7 @@ void MeshTopoAlgorithm::BeginCache() delete _cache; } _cache = new tCache(); - unsigned long nbPoints = _rclMesh._aclPointArray.size(); + PointIndex nbPoints = _rclMesh._aclPointArray.size(); for (unsigned int pntCpt = 0 ; pntCpt < nbPoints ; ++pntCpt) { _cache->insert(std::make_pair(_rclMesh._aclPointArray[pntCpt],pntCpt)); } @@ -782,11 +781,11 @@ void MeshTopoAlgorithm::EndCache() if (_cache) { _cache->clear(); delete _cache; - _cache = 0; + _cache = nullptr; } } -unsigned long MeshTopoAlgorithm::GetOrAddIndex (const MeshPoint &rclPoint) +PointIndex MeshTopoAlgorithm::GetOrAddIndex (const MeshPoint &rclPoint) { if (!_cache) return _rclMesh._aclPointArray.GetOrAddIndex(rclPoint); @@ -798,24 +797,24 @@ unsigned long MeshTopoAlgorithm::GetOrAddIndex (const MeshPoint &rclPoint) return retval.first->second; } -std::vector MeshTopoAlgorithm::GetFacetsToPoint(unsigned long uFacetPos, unsigned long uPointPos) const +std::vector MeshTopoAlgorithm::GetFacetsToPoint(FacetIndex uFacetPos, PointIndex uPointPos) const { // get all facets this point is referenced by - std::list aReference; + std::list aReference; aReference.push_back(uFacetPos); - std::set aRefFacet; + std::set aRefFacet; while (!aReference.empty()) { - unsigned long uIndex = aReference.front(); + FacetIndex uIndex = aReference.front(); aReference.pop_front(); aRefFacet.insert(uIndex); MeshFacet& rFace = _rclMesh._aclFacetArray[uIndex]; for (int i=0; i<3; i++) { if (rFace._aulPoints[i] == uPointPos) { - if (rFace._aulNeighbours[i] != ULONG_MAX) { + if (rFace._aulNeighbours[i] != FACET_INDEX_MAX) { if (aRefFacet.find(rFace._aulNeighbours[i]) == aRefFacet.end()) aReference.push_back( rFace._aulNeighbours[i] ); } - if (rFace._aulNeighbours[(i+2)%3] != ULONG_MAX) { + if (rFace._aulNeighbours[(i+2)%3] != FACET_INDEX_MAX) { if (aRefFacet.find(rFace._aulNeighbours[(i+2)%3]) == aRefFacet.end()) aReference.push_back( rFace._aulNeighbours[(i+2)%3] ); } @@ -825,7 +824,7 @@ std::vector MeshTopoAlgorithm::GetFacetsToPoint(unsigned long uFa } //copy the items - std::vector aRefs; + std::vector aRefs; aRefs.insert(aRefs.end(), aRefFacet.begin(), aRefFacet.end()); return aRefs; } @@ -852,8 +851,8 @@ bool MeshTopoAlgorithm::CollapseVertex(const VertexCollapse& vc) MeshFacet& rFace3 = _rclMesh._aclFacetArray[vc._circumFacets[2]]; // get the point that is not shared by rFace1 - unsigned long ptIndex = ULONG_MAX; - std::vector::const_iterator it; + PointIndex ptIndex = POINT_INDEX_MAX; + std::vector::const_iterator it; for (it = vc._circumPoints.begin(); it != vc._circumPoints.end(); ++it) { if (!rFace1.HasPoint(*it)) { ptIndex = *it; @@ -861,13 +860,13 @@ bool MeshTopoAlgorithm::CollapseVertex(const VertexCollapse& vc) } } - if (ptIndex == ULONG_MAX) + if (ptIndex == POINT_INDEX_MAX) return false; - unsigned long neighbour1 = ULONG_MAX; - unsigned long neighbour2 = ULONG_MAX; + FacetIndex neighbour1 = FACET_INDEX_MAX; + FacetIndex neighbour2 = FACET_INDEX_MAX; - const std::vector& faces = vc._circumFacets; + const std::vector& faces = vc._circumFacets; // get neighbours that are not part of the faces to be removed for (int i=0; i<3; i++) { if (std::find(faces.begin(), faces.end(), rFace2._aulNeighbours[i]) == faces.end()) { @@ -883,11 +882,11 @@ bool MeshTopoAlgorithm::CollapseVertex(const VertexCollapse& vc) rFace1.ReplaceNeighbour(vc._circumFacets[1], neighbour1); rFace1.ReplaceNeighbour(vc._circumFacets[2], neighbour2); - if (neighbour1 != ULONG_MAX) { + if (neighbour1 != FACET_INDEX_MAX) { MeshFacet& rFace4 = _rclMesh._aclFacetArray[neighbour1]; rFace4.ReplaceNeighbour(vc._circumFacets[1], vc._circumFacets[0]); } - if (neighbour2 != ULONG_MAX) { + if (neighbour2 != FACET_INDEX_MAX) { MeshFacet& rFace5 = _rclMesh._aclFacetArray[neighbour2]; rFace5.ReplaceNeighbour(vc._circumFacets[2], vc._circumFacets[0]); } @@ -902,7 +901,7 @@ bool MeshTopoAlgorithm::CollapseVertex(const VertexCollapse& vc) return true; } -bool MeshTopoAlgorithm::CollapseEdge(unsigned long ulFacetPos, unsigned long ulNeighbour) +bool MeshTopoAlgorithm::CollapseEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour) { MeshFacet& rclF = _rclMesh._aclFacetArray[ulFacetPos]; MeshFacet& rclN = _rclMesh._aclFacetArray[ulNeighbour]; @@ -917,35 +916,35 @@ bool MeshTopoAlgorithm::CollapseEdge(unsigned long ulFacetPos, unsigned long ulN return false; // the facets are marked invalid from a previous run // get the point index we want to remove - unsigned long ulPointPos = rclF._aulPoints[uFSide]; - unsigned long ulPointNew = rclN._aulPoints[uNSide]; + PointIndex ulPointPos = rclF._aulPoints[uFSide]; + PointIndex ulPointNew = rclN._aulPoints[uNSide]; // get all facets this point is referenced by - std::vector aRefs = GetFacetsToPoint(ulFacetPos, ulPointPos); - for ( std::vector::iterator it = aRefs.begin(); it != aRefs.end(); ++it ) + std::vector aRefs = GetFacetsToPoint(ulFacetPos, ulPointPos); + for ( std::vector::iterator it = aRefs.begin(); it != aRefs.end(); ++it ) { MeshFacet& rFace = _rclMesh._aclFacetArray[*it]; rFace.Transpose( ulPointPos, ulPointNew ); } // set the new neighbourhood - if (rclF._aulNeighbours[(uFSide+1)%3] != ULONG_MAX) + if (rclF._aulNeighbours[(uFSide+1)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclF._aulNeighbours[(uFSide+1)%3]].ReplaceNeighbour(ulFacetPos, rclF._aulNeighbours[(uFSide+2)%3]); - if (rclF._aulNeighbours[(uFSide+2)%3] != ULONG_MAX) + if (rclF._aulNeighbours[(uFSide+2)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclF._aulNeighbours[(uFSide+2)%3]].ReplaceNeighbour(ulFacetPos, rclF._aulNeighbours[(uFSide+1)%3]); - if (rclN._aulNeighbours[(uNSide+1)%3] != ULONG_MAX) + if (rclN._aulNeighbours[(uNSide+1)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclN._aulNeighbours[(uNSide+1)%3]].ReplaceNeighbour(ulNeighbour, rclN._aulNeighbours[(uNSide+2)%3]); - if (rclN._aulNeighbours[(uNSide+2)%3] != ULONG_MAX) + if (rclN._aulNeighbours[(uNSide+2)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclN._aulNeighbours[(uNSide+2)%3]].ReplaceNeighbour(ulNeighbour, rclN._aulNeighbours[(uNSide+1)%3]); // isolate the both facets and the point - rclF._aulNeighbours[0] = ULONG_MAX; - rclF._aulNeighbours[1] = ULONG_MAX; - rclF._aulNeighbours[2] = ULONG_MAX; + rclF._aulNeighbours[0] = FACET_INDEX_MAX; + rclF._aulNeighbours[1] = FACET_INDEX_MAX; + rclF._aulNeighbours[2] = FACET_INDEX_MAX; rclF.SetInvalid(); - rclN._aulNeighbours[0] = ULONG_MAX; - rclN._aulNeighbours[1] = ULONG_MAX; - rclN._aulNeighbours[2] = ULONG_MAX; + rclN._aulNeighbours[0] = FACET_INDEX_MAX; + rclN._aulNeighbours[1] = FACET_INDEX_MAX; + rclN._aulNeighbours[2] = FACET_INDEX_MAX; rclN.SetInvalid(); _rclMesh._aclPointArray[ulPointPos].SetInvalid(); @@ -959,16 +958,16 @@ bool MeshTopoAlgorithm::IsCollapseEdgeLegal(const EdgeCollapse& ec) const // http://stackoverflow.com/a/27049418/148668 // Check connectivity // - std::vector commonPoints; + std::vector commonPoints; std::set_intersection(ec._adjacentFrom.begin(), ec._adjacentFrom.end(), ec._adjacentTo.begin(), ec._adjacentTo.end(), - std::back_insert_iterator >(commonPoints)); + std::back_insert_iterator >(commonPoints)); if (commonPoints.size() > 2) { return false; } // Check geometry - std::vector::const_iterator it; + std::vector::const_iterator it; for (it = ec._changeFacets.begin(); it != ec._changeFacets.end(); ++it) { MeshFacet f = _rclMesh._aclFacetArray[*it]; if (!f.IsValid()) @@ -1005,16 +1004,16 @@ bool MeshTopoAlgorithm::IsCollapseEdgeLegal(const EdgeCollapse& ec) const bool MeshTopoAlgorithm::CollapseEdge(const EdgeCollapse& ec) { - std::vector::const_iterator it; + std::vector::const_iterator it; for (it = ec._removeFacets.begin(); it != ec._removeFacets.end(); ++it) { MeshFacet& f = _rclMesh._aclFacetArray[*it]; f.SetInvalid(); // adjust the neighbourhood - std::vector neighbours; + std::vector neighbours; for (int i=0; i<3; i++) { // get the neighbours of the facet that won't be invalidated - if (f._aulNeighbours[i] != ULONG_MAX) { + if (f._aulNeighbours[i] != FACET_INDEX_MAX) { if (std::find(ec._removeFacets.begin(), ec._removeFacets.end(), f._aulNeighbours[i]) == ec._removeFacets.end()) { neighbours.push_back(f._aulNeighbours[i]); @@ -1030,7 +1029,7 @@ bool MeshTopoAlgorithm::CollapseEdge(const EdgeCollapse& ec) } else if (neighbours.size() == 1) { MeshFacet& n1 = _rclMesh._aclFacetArray[neighbours[0]]; - n1.ReplaceNeighbour(*it, ULONG_MAX); + n1.ReplaceNeighbour(*it, FACET_INDEX_MAX); } } @@ -1045,61 +1044,61 @@ bool MeshTopoAlgorithm::CollapseEdge(const EdgeCollapse& ec) return true; } -bool MeshTopoAlgorithm::CollapseFacet(unsigned long ulFacetPos) +bool MeshTopoAlgorithm::CollapseFacet(FacetIndex ulFacetPos) { MeshFacet& rclF = _rclMesh._aclFacetArray[ulFacetPos]; if (!rclF.IsValid()) return false; // the facet is marked invalid from a previous run // get the point index we want to remove - unsigned long ulPointInd0 = rclF._aulPoints[0]; - unsigned long ulPointInd1 = rclF._aulPoints[1]; - unsigned long ulPointInd2 = rclF._aulPoints[2]; + PointIndex ulPointInd0 = rclF._aulPoints[0]; + PointIndex ulPointInd1 = rclF._aulPoints[1]; + PointIndex ulPointInd2 = rclF._aulPoints[2]; // move the vertex to the gravity center Base::Vector3f cCenter = _rclMesh.GetGravityPoint(rclF); _rclMesh._aclPointArray[ulPointInd0] = cCenter; // set the new point indices for all facets that share one of the points to be deleted - std::vector aRefs = GetFacetsToPoint(ulFacetPos, ulPointInd1); - for (std::vector::iterator it = aRefs.begin(); it != aRefs.end(); ++it) { + std::vector aRefs = GetFacetsToPoint(ulFacetPos, ulPointInd1); + for (std::vector::iterator it = aRefs.begin(); it != aRefs.end(); ++it) { MeshFacet& rFace = _rclMesh._aclFacetArray[*it]; rFace.Transpose(ulPointInd1, ulPointInd0); } aRefs = GetFacetsToPoint(ulFacetPos, ulPointInd2); - for (std::vector::iterator it = aRefs.begin(); it != aRefs.end(); ++it) { + for (std::vector::iterator it = aRefs.begin(); it != aRefs.end(); ++it) { MeshFacet& rFace = _rclMesh._aclFacetArray[*it]; rFace.Transpose(ulPointInd2, ulPointInd0); } // set the neighbourhood of the circumjacent facets for (int i=0; i<3; i++) { - if (rclF._aulNeighbours[i] == ULONG_MAX) + if (rclF._aulNeighbours[i] == FACET_INDEX_MAX) continue; MeshFacet& rclN = _rclMesh._aclFacetArray[rclF._aulNeighbours[i]]; unsigned short uNSide = rclN.Side(rclF); - if (rclN._aulNeighbours[(uNSide+1)%3] != ULONG_MAX) { + if (rclN._aulNeighbours[(uNSide+1)%3] != FACET_INDEX_MAX) { _rclMesh._aclFacetArray[rclN._aulNeighbours[(uNSide+1)%3]] .ReplaceNeighbour(rclF._aulNeighbours[i],rclN._aulNeighbours[(uNSide+2)%3]); } - if (rclN._aulNeighbours[(uNSide+2)%3] != ULONG_MAX) { + if (rclN._aulNeighbours[(uNSide+2)%3] != FACET_INDEX_MAX) { _rclMesh._aclFacetArray[rclN._aulNeighbours[(uNSide+2)%3]] .ReplaceNeighbour(rclF._aulNeighbours[i],rclN._aulNeighbours[(uNSide+1)%3]); } // Isolate the neighbours from the topology - rclN._aulNeighbours[0] = ULONG_MAX; - rclN._aulNeighbours[1] = ULONG_MAX; - rclN._aulNeighbours[2] = ULONG_MAX; + rclN._aulNeighbours[0] = FACET_INDEX_MAX; + rclN._aulNeighbours[1] = FACET_INDEX_MAX; + rclN._aulNeighbours[2] = FACET_INDEX_MAX; rclN.SetInvalid(); } // Isolate this facet and make two of its points invalid - rclF._aulNeighbours[0] = ULONG_MAX; - rclF._aulNeighbours[1] = ULONG_MAX; - rclF._aulNeighbours[2] = ULONG_MAX; + rclF._aulNeighbours[0] = FACET_INDEX_MAX; + rclF._aulNeighbours[1] = FACET_INDEX_MAX; + rclF._aulNeighbours[2] = FACET_INDEX_MAX; rclF.SetInvalid(); _rclMesh._aclPointArray[ulPointInd1].SetInvalid(); _rclMesh._aclPointArray[ulPointInd2].SetInvalid(); @@ -1109,7 +1108,7 @@ bool MeshTopoAlgorithm::CollapseFacet(unsigned long ulFacetPos) return true; } -void MeshTopoAlgorithm::SplitFacet(unsigned long ulFacetPos, const Base::Vector3f& rP1, const Base::Vector3f& rP2) +void MeshTopoAlgorithm::SplitFacet(FacetIndex ulFacetPos, const Base::Vector3f& rP1, const Base::Vector3f& rP2) { float fEps = MESH_MIN_EDGE_LEN; MeshFacet& rFace = _rclMesh._aclFacetArray[ulFacetPos]; @@ -1148,7 +1147,7 @@ void MeshTopoAlgorithm::SplitFacet(unsigned long ulFacetPos, const Base::Vector3 } } -void MeshTopoAlgorithm::SplitFacetOnOneEdge(unsigned long ulFacetPos, const Base::Vector3f& rP) +void MeshTopoAlgorithm::SplitFacetOnOneEdge(FacetIndex ulFacetPos, const Base::Vector3f& rP) { float fMinDist = FLOAT_MAX; unsigned short iEdgeNo = USHRT_MAX; @@ -1167,14 +1166,14 @@ void MeshTopoAlgorithm::SplitFacetOnOneEdge(unsigned long ulFacetPos, const Base } if (fMinDist < 0.05f) { - if (rFace._aulNeighbours[iEdgeNo] != ULONG_MAX) + if (rFace._aulNeighbours[iEdgeNo] != FACET_INDEX_MAX) SplitEdge(ulFacetPos, rFace._aulNeighbours[iEdgeNo], rP); else SplitOpenEdge(ulFacetPos, iEdgeNo, rP); } } -void MeshTopoAlgorithm::SplitFacetOnTwoEdges(unsigned long ulFacetPos, const Base::Vector3f& rP1, const Base::Vector3f& rP2) +void MeshTopoAlgorithm::SplitFacetOnTwoEdges(FacetIndex ulFacetPos, const Base::Vector3f& rP1, const Base::Vector3f& rP2) { // search for the matching edges unsigned short iEdgeNo1 = USHRT_MAX, iEdgeNo2 = USHRT_MAX; @@ -1210,21 +1209,21 @@ void MeshTopoAlgorithm::SplitFacetOnTwoEdges(unsigned long ulFacetPos, const Bas } // insert new points - unsigned long cntPts1 = this->GetOrAddIndex(cP1); - unsigned long cntPts2 = this->GetOrAddIndex(cP2); - unsigned long cntFts = _rclMesh.CountFacets(); + PointIndex cntPts1 = this->GetOrAddIndex(cP1); + PointIndex cntPts2 = this->GetOrAddIndex(cP2); + FacetIndex cntFts = _rclMesh.CountFacets(); unsigned short v0 = (iEdgeNo2 + 1) % 3; unsigned short v1 = iEdgeNo1; unsigned short v2 = iEdgeNo2; - unsigned long p0 = rFace._aulPoints[v0]; - unsigned long p1 = rFace._aulPoints[v1]; - unsigned long p2 = rFace._aulPoints[v2]; + PointIndex p0 = rFace._aulPoints[v0]; + PointIndex p1 = rFace._aulPoints[v1]; + PointIndex p2 = rFace._aulPoints[v2]; - unsigned long n0 = rFace._aulNeighbours[v0]; - unsigned long n1 = rFace._aulNeighbours[v1]; - unsigned long n2 = rFace._aulNeighbours[v2]; + FacetIndex n0 = rFace._aulNeighbours[v0]; + FacetIndex n1 = rFace._aulNeighbours[v1]; + FacetIndex n2 = rFace._aulNeighbours[v2]; // Modify and add facets // @@ -1244,15 +1243,15 @@ void MeshTopoAlgorithm::SplitFacetOnTwoEdges(unsigned long ulFacetPos, const Bas AddFacet(p0, cntPts1, cntPts2, cntFts, ulFacetPos, n2); } - std::vector fixIndices; + std::vector fixIndices; fixIndices.push_back(ulFacetPos); - if (n0 != ULONG_MAX) { + if (n0 != FACET_INDEX_MAX) { fixIndices.push_back(n0); } // split up the neighbour facets - if (n1 != ULONG_MAX) { + if (n1 != FACET_INDEX_MAX) { fixIndices.push_back(n1); MeshFacet& rN = _rclMesh._aclFacetArray[n1]; for (int i=0; i<3; i++) @@ -1260,7 +1259,7 @@ void MeshTopoAlgorithm::SplitFacetOnTwoEdges(unsigned long ulFacetPos, const Bas SplitFacet(n1, p1, p2, cntPts1); } - if (n2 != ULONG_MAX) { + if (n2 != FACET_INDEX_MAX) { fixIndices.push_back(n2); MeshFacet& rN = _rclMesh._aclFacetArray[n2]; for (int i=0; i<3; i++) @@ -1268,8 +1267,8 @@ void MeshTopoAlgorithm::SplitFacetOnTwoEdges(unsigned long ulFacetPos, const Bas SplitFacet(n2, p2, p0, cntPts2); } - unsigned long cntFts2 = _rclMesh.CountFacets(); - for (unsigned long i=cntFts; i& ulFacets) +void MeshTopoAlgorithm::HarmonizeNeighbours(const std::vector& ulFacets) { - for (unsigned long it : ulFacets) { - for (unsigned long jt : ulFacets) { + for (FacetIndex it : ulFacets) { + for (FacetIndex jt : ulFacets) { HarmonizeNeighbours(it, jt); } } } -void MeshTopoAlgorithm::HarmonizeNeighbours(unsigned long facet1, unsigned long facet2) +void MeshTopoAlgorithm::HarmonizeNeighbours(FacetIndex facet1, FacetIndex facet2) { if (facet1 == facet2) return; @@ -1350,21 +1349,20 @@ void MeshTopoAlgorithm::HarmonizeNeighbours(unsigned long facet1, unsigned long } } -void MeshTopoAlgorithm::SplitNeighbourFacet(unsigned long ulFacetPos, unsigned short uFSide, const Base::Vector3f rPoint) +void MeshTopoAlgorithm::SplitNeighbourFacet(FacetIndex ulFacetPos, unsigned short uFSide, const Base::Vector3f rPoint) { MeshFacet& rclF = _rclMesh._aclFacetArray[ulFacetPos]; - unsigned long ulNeighbour = rclF._aulNeighbours[uFSide]; + FacetIndex ulNeighbour = rclF._aulNeighbours[uFSide]; MeshFacet& rclN = _rclMesh._aclFacetArray[ulNeighbour]; unsigned short uNSide = rclN.Side(rclF); - //unsigned long uPtCnt = _rclMesh._aclPointArray.size(); - unsigned long uPtInd = this->GetOrAddIndex(rPoint); - unsigned long ulSize = _rclMesh._aclFacetArray.size(); + PointIndex uPtInd = this->GetOrAddIndex(rPoint); + FacetIndex ulSize = _rclMesh._aclFacetArray.size(); // adjust the neighbourhood - if (rclN._aulNeighbours[(uNSide+1)%3] != ULONG_MAX) + if (rclN._aulNeighbours[(uNSide+1)%3] != FACET_INDEX_MAX) _rclMesh._aclFacetArray[rclN._aulNeighbours[(uNSide+1)%3]].ReplaceNeighbour(ulNeighbour, ulSize); MeshFacet cNew; @@ -1407,9 +1405,9 @@ void MeshTopoAlgorithm::SplitNeighbourFacet(unsigned long ulFacetPos, unsigned s _aclNewFacets.push_back(clFacet); #endif -void MeshTopoAlgorithm::RemoveDegeneratedFacet(unsigned long index) +bool MeshTopoAlgorithm::RemoveDegeneratedFacet(FacetIndex index) { - if (index >= _rclMesh._aclFacetArray.size()) return; + if (index >= _rclMesh._aclFacetArray.size()) return false; MeshFacet& rFace = _rclMesh._aclFacetArray[index]; // coincident corners (either topological or geometrical) @@ -1417,19 +1415,19 @@ void MeshTopoAlgorithm::RemoveDegeneratedFacet(unsigned long index) const MeshPoint& rE0 = _rclMesh._aclPointArray[rFace._aulPoints[i]]; const MeshPoint& rE1 = _rclMesh._aclPointArray[rFace._aulPoints[(i+1)%3]]; if (rE0 == rE1) { - unsigned long uN1 = rFace._aulNeighbours[(i+1)%3]; - unsigned long uN2 = rFace._aulNeighbours[(i+2)%3]; - if (uN2 != ULONG_MAX) + FacetIndex uN1 = rFace._aulNeighbours[(i+1)%3]; + FacetIndex uN2 = rFace._aulNeighbours[(i+2)%3]; + if (uN2 != FACET_INDEX_MAX) _rclMesh._aclFacetArray[uN2].ReplaceNeighbour(index, uN1); - if (uN1 != ULONG_MAX) + if (uN1 != FACET_INDEX_MAX) _rclMesh._aclFacetArray[uN1].ReplaceNeighbour(index, uN2); // isolate the face and remove it - rFace._aulNeighbours[0] = ULONG_MAX; - rFace._aulNeighbours[1] = ULONG_MAX; - rFace._aulNeighbours[2] = ULONG_MAX; + rFace._aulNeighbours[0] = FACET_INDEX_MAX; + rFace._aulNeighbours[1] = FACET_INDEX_MAX; + rFace._aulNeighbours[2] = FACET_INDEX_MAX; _rclMesh.DeleteFacet(index); - return; + return true; } } @@ -1442,8 +1440,8 @@ void MeshTopoAlgorithm::RemoveDegeneratedFacet(unsigned long index) // adjust the neighbourhoods and point indices if (cVec1 * cVec2 < 0.0f) { - unsigned long uN1 = rFace._aulNeighbours[(j+1)%3]; - if (uN1 != ULONG_MAX) { + FacetIndex uN1 = rFace._aulNeighbours[(j+1)%3]; + if (uN1 != FACET_INDEX_MAX) { // get the neighbour and common edge side MeshFacet& rNb = _rclMesh._aclFacetArray[uN1]; unsigned short side = rNb.Side(index); @@ -1453,14 +1451,14 @@ void MeshTopoAlgorithm::RemoveDegeneratedFacet(unsigned long index) rNb._aulPoints[(side+1)%3] = rFace._aulPoints[j]; // set correct neighbourhood - unsigned long uN2 = rFace._aulNeighbours[(j+2)%3]; + FacetIndex uN2 = rFace._aulNeighbours[(j+2)%3]; rNb._aulNeighbours[side] = uN2; - if (uN2 != ULONG_MAX) { + if (uN2 != FACET_INDEX_MAX) { _rclMesh._aclFacetArray[uN2].ReplaceNeighbour(index, uN1); } - unsigned long uN3 = rNb._aulNeighbours[(side+1)%3]; + FacetIndex uN3 = rNb._aulNeighbours[(side+1)%3]; rFace._aulNeighbours[(j+1)%3] = uN3; - if (uN3 != ULONG_MAX) { + if (uN3 != FACET_INDEX_MAX) { _rclMesh._aclFacetArray[uN3].ReplaceNeighbour(uN1, index); } rNb._aulNeighbours[(side+1)%3] = index; @@ -1469,12 +1467,14 @@ void MeshTopoAlgorithm::RemoveDegeneratedFacet(unsigned long index) else _rclMesh.DeleteFacet(index); - return; + return true; } } + + return false; } -bool MeshTopoAlgorithm::RemoveCorruptedFacet(unsigned long index) +bool MeshTopoAlgorithm::RemoveCorruptedFacet(FacetIndex index) { if (index >= _rclMesh._aclFacetArray.size()) return false; MeshFacet& rFace = _rclMesh._aclFacetArray[index]; @@ -1482,17 +1482,17 @@ bool MeshTopoAlgorithm::RemoveCorruptedFacet(unsigned long index) // coincident corners (topological) for (int i=0; i<3; i++) { if (rFace._aulPoints[i] == rFace._aulPoints[(i+1)%3]) { - unsigned long uN1 = rFace._aulNeighbours[(i+1)%3]; - unsigned long uN2 = rFace._aulNeighbours[(i+2)%3]; - if (uN2 != ULONG_MAX) + FacetIndex uN1 = rFace._aulNeighbours[(i+1)%3]; + FacetIndex uN2 = rFace._aulNeighbours[(i+2)%3]; + if (uN2 != FACET_INDEX_MAX) _rclMesh._aclFacetArray[uN2].ReplaceNeighbour(index, uN1); - if (uN1 != ULONG_MAX) + if (uN1 != FACET_INDEX_MAX) _rclMesh._aclFacetArray[uN1].ReplaceNeighbour(index, uN2); // isolate the face and remove it - rFace._aulNeighbours[0] = ULONG_MAX; - rFace._aulNeighbours[1] = ULONG_MAX; - rFace._aulNeighbours[2] = ULONG_MAX; + rFace._aulNeighbours[0] = FACET_INDEX_MAX; + rFace._aulNeighbours[1] = FACET_INDEX_MAX; + rFace._aulNeighbours[2] = FACET_INDEX_MAX; _rclMesh.DeleteFacet(index); return true; } @@ -1503,17 +1503,17 @@ bool MeshTopoAlgorithm::RemoveCorruptedFacet(unsigned long index) void MeshTopoAlgorithm::FillupHoles(unsigned long length, int level, AbstractPolygonTriangulator& cTria, - std::list >& aFailed) + std::list >& aFailed) { // get the mesh boundaries as an array of point indices - std::list > aBorders, aFillBorders; + std::list > aBorders, aFillBorders; MeshAlgorithm cAlgo(_rclMesh); cAlgo.GetMeshBorders(aBorders); // split boundary loops if needed cAlgo.SplitBoundaryLoops(aBorders); - for (std::list >::iterator it = aBorders.begin(); it != aBorders.end(); ++it) { + for (std::list >::iterator it = aBorders.begin(); it != aBorders.end(); ++it) { if (it->size()-1 <= length) // ignore boundary with too many edges aFillBorders.push_back(*it); } @@ -1523,8 +1523,8 @@ void MeshTopoAlgorithm::FillupHoles(unsigned long length, int level, } void MeshTopoAlgorithm::FillupHoles(int level, AbstractPolygonTriangulator& cTria, - const std::list >& aBorders, - std::list >& aFailed) + const std::list >& aBorders, + std::list >& aFailed) { // get the facets to a point MeshRefPointToFacets cPt2Fac(_rclMesh); @@ -1533,10 +1533,10 @@ void MeshTopoAlgorithm::FillupHoles(int level, AbstractPolygonTriangulator& cTri MeshFacetArray newFacets; MeshPointArray newPoints; unsigned long numberOfOldPoints = _rclMesh._aclPointArray.size(); - for (std::list >::const_iterator it = aBorders.begin(); it != aBorders.end(); ++it) { + for (std::list >::const_iterator it = aBorders.begin(); it != aBorders.end(); ++it) { MeshFacetArray cFacets; MeshPointArray cPoints; - std::vector bound = *it; + std::vector bound = *it; if (cAlgo.FillupHole(bound, cTria, cFacets, cPoints, level, &cPt2Fac)) { if (bound.front() == bound.back()) bound.pop_back(); @@ -1594,24 +1594,24 @@ void MeshTopoAlgorithm::FillupHoles(int level, AbstractPolygonTriangulator& cTri } void MeshTopoAlgorithm::FindHoles(unsigned long length, - std::list >& aBorders) const + std::list >& aBorders) const { - std::list > border; + std::list > border; MeshAlgorithm cAlgo(_rclMesh); cAlgo.GetMeshBorders(border); - for (std::list >::iterator it = border.begin(); + for (std::list >::iterator it = border.begin(); it != border.end(); ++it) { if (it->size() <= length) aBorders.push_back(*it); } } -void MeshTopoAlgorithm::FindComponents(unsigned long count, std::vector& findIndices) +void MeshTopoAlgorithm::FindComponents(unsigned long count, std::vector& findIndices) { - std::vector > segments; + std::vector > segments; MeshComponents comp(_rclMesh); comp.SearchForComponents(MeshComponents::OverEdge,segments); - for (std::vector >::iterator it = segments.begin(); it != segments.end(); ++it) { + for (std::vector >::iterator it = segments.begin(); it != segments.end(); ++it) { if (it->size() <= count) findIndices.insert(findIndices.end(), it->begin(), it->end()); } @@ -1619,20 +1619,20 @@ void MeshTopoAlgorithm::FindComponents(unsigned long count, std::vector removeFacets; + std::vector removeFacets; FindComponents(count, removeFacets); if (!removeFacets.empty()) _rclMesh.DeleteFacets(removeFacets); } -void MeshTopoAlgorithm::HarmonizeNormals (void) +void MeshTopoAlgorithm::HarmonizeNormals () { - std::vector uIndices = MeshEvalOrientation(_rclMesh).GetIndices(); - for ( std::vector::iterator it = uIndices.begin(); it != uIndices.end(); ++it ) + std::vector uIndices = MeshEvalOrientation(_rclMesh).GetIndices(); + for ( std::vector::iterator it = uIndices.begin(); it != uIndices.end(); ++it ) _rclMesh._aclFacetArray[*it].FlipNormal(); } -void MeshTopoAlgorithm::FlipNormals (void) +void MeshTopoAlgorithm::FlipNormals () { for (MeshFacetArray::_TIterator i = _rclMesh._aclFacetArray.begin(); i < _rclMesh._aclFacetArray.end(); ++i) i->FlipNormal(); @@ -1672,20 +1672,20 @@ MeshComponents::~MeshComponents() { } -void MeshComponents::SearchForComponents(TMode tMode, std::vector >& aclT) const +void MeshComponents::SearchForComponents(TMode tMode, std::vector >& aclT) const { // all facets - std::vector aulAllFacets(_rclMesh.CountFacets()); - unsigned long k = 0; - for (std::vector::iterator pI = aulAllFacets.begin(); pI != aulAllFacets.end(); ++pI) + std::vector aulAllFacets(_rclMesh.CountFacets()); + FacetIndex k = 0; + for (std::vector::iterator pI = aulAllFacets.begin(); pI != aulAllFacets.end(); ++pI) *pI = k++; SearchForComponents( tMode, aulAllFacets, aclT ); } -void MeshComponents::SearchForComponents(TMode tMode, const std::vector& aSegment, std::vector >& aclT) const +void MeshComponents::SearchForComponents(TMode tMode, const std::vector& aSegment, std::vector >& aclT) const { - unsigned long ulStartFacet, ulVisited; + FacetIndex ulStartFacet; if (_rclMesh.CountFacets() == 0) return; @@ -1701,7 +1701,7 @@ void MeshComponents::SearchForComponents(TMode tMode, const std::vector flag; iTri = std::find_if(iTri, iEnd, [flag](const MeshFacet& f) { return flag(f, MeshFacet::VISIT); @@ -1709,11 +1709,11 @@ void MeshComponents::SearchForComponents(TMode tMode, const std::vector aclComponent; - std::vector > aclConnectComp; + std::vector aclComponent; + std::vector > aclConnectComp; MeshTopFacetVisitor clFVisitor( aclComponent ); - while ( ulStartFacet != ULONG_MAX ) + while ( ulStartFacet != FACET_INDEX_MAX ) { // collect all facets of a component aclComponent.clear(); @@ -1736,7 +1736,7 @@ void MeshComponents::SearchForComponents(TMode tMode, const std::vector >& aFailed); + std::list >& aFailed); /** * This is an overloaded method provided for convenience. It takes as first argument * the boundaries which must be filled up. */ void FillupHoles(int level, AbstractPolygonTriangulator&, - const std::list >& aBorders, - std::list >& aFailed); + const std::list >& aBorders, + std::list >& aFailed); /** * Find holes which consists of up to \a length edges. */ void FindHoles(unsigned long length, - std::list >& aBorders) const; + std::list >& aBorders) const; /** * Find topologic independent components with maximum \a count facets * and returns an array of the indices. */ - void FindComponents(unsigned long count, std::vector& aInds); + void FindComponents(unsigned long count, std::vector& aInds); /** * Removes topologic independent components with maximum \a count facets. */ @@ -273,11 +273,11 @@ public: /** * Harmonizes the normals. */ - void HarmonizeNormals (void); + void HarmonizeNormals (); /** * Flips the normals. */ - void FlipNormals (void); + void FlipNormals (); /** * Caching facility. */ @@ -288,28 +288,28 @@ private: /** * Splits the neighbour facet of \a ulFacetPos on side \a uSide. */ - void SplitNeighbourFacet(unsigned long ulFacetPos, unsigned short uSide, + void SplitNeighbourFacet(FacetIndex ulFacetPos, unsigned short uSide, const Base::Vector3f rPoint); - void SplitFacetOnOneEdge(unsigned long ulFacetPos, + void SplitFacetOnOneEdge(FacetIndex ulFacetPos, const Base::Vector3f& rP1); - void SplitFacetOnTwoEdges(unsigned long ulFacetPos, + void SplitFacetOnTwoEdges(FacetIndex ulFacetPos, const Base::Vector3f& rP1, const Base::Vector3f& rP2); - void SplitFacet(unsigned long ulFacetPos, unsigned long P1, - unsigned long P2, unsigned long Pn); - void AddFacet(unsigned long P1, unsigned long P2, unsigned long P3); - void AddFacet(unsigned long P1, unsigned long P2, unsigned long P3, - unsigned long N1, unsigned long N2, unsigned long N3); - void HarmonizeNeighbours(unsigned long facet1, unsigned long facet2); - void HarmonizeNeighbours(const std::vector& ulFacets); + void SplitFacet(FacetIndex ulFacetPos, PointIndex P1, + PointIndex P2, PointIndex Pn); + void AddFacet(PointIndex P1, PointIndex P2, PointIndex P3); + void AddFacet(PointIndex P1, PointIndex P2, PointIndex P3, + FacetIndex N1, FacetIndex N2, FacetIndex N3); + void HarmonizeNeighbours(FacetIndex facet1, FacetIndex facet2); + void HarmonizeNeighbours(const std::vector& ulFacets); /** * Returns all facets that references the point index \a uPointPos. \a uFacetPos * is a facet that must reference this point and is added to the list as well. */ - std::vector GetFacetsToPoint(unsigned long uFacetPos, - unsigned long uPointPos) const; + std::vector GetFacetsToPoint(FacetIndex uFacetPos, + PointIndex uPointPos) const; /** \internal */ - unsigned long GetOrAddIndex (const MeshPoint &rclPoint); + PointIndex GetOrAddIndex (const MeshPoint &rclPoint); private: MeshKernel& _rclMesh; @@ -321,7 +321,7 @@ private: }; // cache - typedef std::map tCache; + typedef std::map tCache; tCache* _cache; }; @@ -344,21 +344,21 @@ public: * sharing the same edge are regarded as connected, if \a tMode is \a OverPoint * then facets sharing a common point are regarded as connected. */ - void SearchForComponents(TMode tMode, std::vector >& aclT) const; + void SearchForComponents(TMode tMode, std::vector >& aclT) const; /** * Does basically the same as the method above escept that only the faces in * \a aSegment are regarded. */ - void SearchForComponents(TMode tMode, const std::vector& aSegment, - std::vector >& aclT) const; + void SearchForComponents(TMode tMode, const std::vector& aSegment, + std::vector >& aclT) const; protected: // for sorting of elements struct CNofFacetsCompare { - bool operator () (const std::vector &rclC1, - const std::vector &rclC2) + bool operator () (const std::vector &rclC1, + const std::vector &rclC2) { return rclC1.size() > rclC2.size(); } diff --git a/src/Mod/Mesh/App/Core/Triangulation.cpp b/src/Mod/Mesh/App/Core/Triangulation.cpp index 816d30a7b9..799e806e0e 100644 --- a/src/Mod/Mesh/App/Core/Triangulation.cpp +++ b/src/Mod/Mesh/App/Core/Triangulation.cpp @@ -253,7 +253,7 @@ bool AbstractPolygonTriangulator::TriangulatePolygon() } } -std::vector AbstractPolygonTriangulator::GetInfo() const +std::vector AbstractPolygonTriangulator::GetInfo() const { return _info; } @@ -292,7 +292,7 @@ bool EarClippingTriangulator::Triangulate() _triangles.clear(); std::vector pts = ProjectToFitPlane(); - std::vector result; + std::vector result; // Invoke the triangulator to triangulate this polygon. Triangulate::Process(pts,result); @@ -306,7 +306,7 @@ bool EarClippingTriangulator::Triangulate() MeshGeomFacet clFacet; MeshFacet clTopFacet; - for (unsigned long i=0; i &contour, - std::vector &result) + std::vector &result) { /* allocate and initialize list of Vertices in polygon */ @@ -483,30 +483,30 @@ bool QuasiDelaunayTriangulator::Triangulate() // For each internal edge get the adjacent facets. When doing an edge swap we must update // this structure. - std::map, std::vector > aEdge2Face; + std::map, std::vector > aEdge2Face; for (std::vector::iterator pI = _facets.begin(); pI != _facets.end(); ++pI) { for (int i = 0; i < 3; i++) { - unsigned long ulPt0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); - unsigned long ulPt1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + PointIndex ulPt0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); + PointIndex ulPt1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i+1)%3]); // ignore borderlines of the polygon if ((ulPt1-ulPt0)%(_points.size()-1) > 1) - aEdge2Face[std::pair(ulPt0, ulPt1)].push_back(pI - _facets.begin()); + aEdge2Face[std::pair(ulPt0, ulPt1)].push_back(pI - _facets.begin()); } } // fill up this list with all internal edges and perform swap edges until this list is empty - std::list > aEdgeList; - std::map, std::vector >::iterator pE; + std::list > aEdgeList; + std::map, std::vector >::iterator pE; for (pE = aEdge2Face.begin(); pE != aEdge2Face.end(); ++pE) aEdgeList.push_back(pE->first); // to be sure to avoid an endless loop - unsigned long uMaxIter = 5 * aEdge2Face.size(); + size_t uMaxIter = 5 * aEdge2Face.size(); // Perform a swap edge where needed while (!aEdgeList.empty() && uMaxIter > 0) { // get the first edge and remove it from the list - std::pair aEdge = aEdgeList.front(); + std::pair aEdge = aEdgeList.front(); aEdgeList.pop_front(); uMaxIter--; @@ -556,10 +556,10 @@ bool QuasiDelaunayTriangulator::Triangulate() // adjust the edge list for (int i=0; i<3; i++) { - std::map, std::vector >::iterator it; + std::map, std::vector >::iterator it; // first facet - unsigned long ulPt0 = std::min(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]); - unsigned long ulPt1 = std::max(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]); + PointIndex ulPt0 = std::min(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]); + PointIndex ulPt1 = std::max(rF1._aulPoints[i], rF1._aulPoints[(i+1)%3]); it = aEdge2Face.find( std::make_pair(ulPt0, ulPt1) ); if (it != aEdge2Face.end()) { if (it->second[0] == pE->second[1]) @@ -570,8 +570,8 @@ bool QuasiDelaunayTriangulator::Triangulate() } // second facet - ulPt0 = std::min(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]); - ulPt1 = std::max(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]); + ulPt0 = std::min(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]); + ulPt1 = std::max(rF2._aulPoints[i], rF2._aulPoints[(i+1)%3]); it = aEdge2Face.find( std::make_pair(ulPt0, ulPt1) ); if (it != aEdge2Face.end()) { if (it->second[0] == pE->second[0]) @@ -583,9 +583,9 @@ bool QuasiDelaunayTriangulator::Triangulate() } // Now we must remove the edge and replace it through the new edge - unsigned long ulPt0 = std::min(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]); - unsigned long ulPt1 = std::max(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]); - std::pair aNewEdge = std::make_pair(ulPt0, ulPt1); + PointIndex ulPt0 = std::min(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]); + PointIndex ulPt1 = std::max(rF1._aulPoints[(side1+1)%3], rF2._aulPoints[(side2+1)%3]); + std::pair aNewEdge = std::make_pair(ulPt0, ulPt1); aEdge2Face[aNewEdge] = pE->second; aEdge2Face.erase(pE); } @@ -664,7 +664,7 @@ bool DelaunayTriangulator::Triangulate() // then the triangulation must have 2*N-2-H triangles and 3*N-3-H // edges. int iEQuantity = 0; - int* aiIndex = 0; + int* aiIndex = nullptr; del.GetHull(iEQuantity,aiIndex); int iUniqueVQuantity = del.GetUniqueVertexQuantity(); int iTVerify = 2*iUniqueVQuantity - 2 - iEQuantity; @@ -680,7 +680,7 @@ bool DelaunayTriangulator::Triangulate() for (int i = 0; i < iTQuantity; i++) { for (int j=0; j<3; j++) { size_t index = static_cast(aiTVertex[static_cast(3*i+j)]); - facet._aulPoints[j] = static_cast(index); + facet._aulPoints[j] = static_cast(index); triangle._aclPoints[j].x = static_cast(akVertex[index].X()); triangle._aclPoints[j].y = static_cast(akVertex[index].Y()); } diff --git a/src/Mod/Mesh/App/Core/Triangulation.h b/src/Mod/Mesh/App/Core/Triangulation.h index 4899cc2dfe..805a835823 100644 --- a/src/Mod/Mesh/App/Core/Triangulation.h +++ b/src/Mod/Mesh/App/Core/Triangulation.h @@ -63,7 +63,7 @@ public: /** Sets the polygon to be triangulated. */ void SetPolygon(const std::vector& raclPoints); - void SetIndices(const std::vector& d) {_indices = d;} + void SetIndices(const std::vector& d) {_indices = d;} /** Set a verifier object that checks if the generated triangulation * can be accepted and added to the mesh kernel. * The triangulator takes ownership of the passed verifier. @@ -117,7 +117,7 @@ public: * It returns an array of the number of edges for each closed * polygon. */ - std::vector GetInfo() const; + std::vector GetInfo() const; virtual void Discard(); /** Resets some internals. The default implementation does nothing.*/ virtual void Reset(); @@ -132,12 +132,12 @@ protected: protected: bool _discard; Base::Matrix4D _inverse; - std::vector _indices; + std::vector _indices; std::vector _points; std::vector _newpoints; std::vector _triangles; std::vector _facets; - std::vector _info; + std::vector _info; TriangulationVerifier* _verifier; }; @@ -170,7 +170,7 @@ private: // triangulate a contour/polygon, places results in STL vector // as series of triangles.indicating the points static bool Process(const std::vector &contour, - std::vector &result); + std::vector &result); // compute area of a contour/polygon static float Area(const std::vector &contour); diff --git a/src/Mod/Mesh/App/Core/Trim.cpp b/src/Mod/Mesh/App/Core/Trim.cpp index e08fa463ad..0101f7d82b 100644 --- a/src/Mod/Mesh/App/Core/Trim.cpp +++ b/src/Mod/Mesh/App/Core/Trim.cpp @@ -53,16 +53,16 @@ void MeshTrimming::SetInnerOrOuter(TMode tMode) } } -void MeshTrimming::CheckFacets(const MeshFacetGrid& rclGrid, std::vector &raulFacets) const +void MeshTrimming::CheckFacets(const MeshFacetGrid& rclGrid, std::vector &raulFacets) const { - std::vector::iterator it; + std::vector::iterator it; MeshFacetIterator clIter(myMesh, 0); // cut inner: use grid to accelerate search if (myInner) { Base::BoundBox3f clBBox3d; Base::BoundBox2d clViewBBox, clPolyBBox; - std::vector aulAllElements; + std::vector aulAllElements; // BBox of polygon clPolyBBox = myPoly.CalcBoundBox(); @@ -103,13 +103,11 @@ void MeshTrimming::CheckFacets(const MeshFacetGrid& rclGrid, std::vectoroperator ()(rclFacet._aclPoints[i]); if (myPoly.Contains(Base::Vector2d(clPt2d.x, clPt2d.y)) == myInner) return true; @@ -118,17 +116,17 @@ bool MeshTrimming::HasIntersection(const MeshGeomFacet& rclFacet) const } // is corner of polygon inside the facet - for (j=0; j(A.x*B.y+A.y*C.x+B.x*C.y-(B.y*C.x+A.y*B.x+A.x*C.y)); - for (unsigned long j=0; j calculate the corresponding 3d-point if (clFacPoly.Contains(myPoly[j])) { P = myPoly[j]; @@ -195,7 +193,7 @@ bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f& return false; } -bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex, int& iSide, std::vector& raclPoints) const +bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(FacetIndex ulIndex, int& iSide, std::vector& raclPoints) const { MeshGeomFacet clFac(myMesh.GetFacet(ulIndex)); Base::Vector2d S; @@ -206,7 +204,7 @@ bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex, // Edge with no intersection iSide = -1; - for (unsigned long i=0; i& raclPoints, std::vector& aclNewFacets) +bool MeshTrimming::CreateFacets(FacetIndex ulFacetPos, int iSide, const std::vector& raclPoints, std::vector& aclNewFacets) { MeshGeomFacet clFac; @@ -603,7 +601,7 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std:: return true; } -bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::vector& raclPoints, Base::Vector3f& clP3, +bool MeshTrimming::CreateFacets(FacetIndex ulFacetPos, int iSide, const std::vector& raclPoints, Base::Vector3f& clP3, std::vector& aclNewFacets) { // no valid triangulation possible @@ -716,14 +714,14 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std:: return true; } -void MeshTrimming::TrimFacets(const std::vector& raulFacets, std::vector& aclNewFacets) +void MeshTrimming::TrimFacets(const std::vector& raulFacets, std::vector& aclNewFacets) { Base::Vector3f clP; std::vector clIntsct; int iSide; Base::SequencerLauncher seq("trimming facets...", raulFacets.size()); - for (std::vector::const_iterator it=raulFacets.begin(); it!=raulFacets.end(); ++it) { + for (std::vector::const_iterator it=raulFacets.begin(); it!=raulFacets.end(); ++it) { clIntsct.clear(); if (IsPolygonPointInFacet(*it, clP) == false) { // facet must be trimmed diff --git a/src/Mod/Mesh/App/Core/Trim.h b/src/Mod/Mesh/App/Core/Trim.h index 857c9ad55b..3482008750 100644 --- a/src/Mod/Mesh/App/Core/Trim.h +++ b/src/Mod/Mesh/App/Core/Trim.h @@ -46,12 +46,12 @@ public: /** * Checks all facets for intersection with the polygon and writes all touched facets into the vector */ - void CheckFacets(const MeshFacetGrid& rclGrid, std::vector& raulFacets) const; + void CheckFacets(const MeshFacetGrid& rclGrid, std::vector& raulFacets) const; /** * The facets from raulFacets will be trimmed or deleted and aclNewFacets gives the new generated facets */ - void TrimFacets(const std::vector& raulFacets, std::vector& aclNewFacets); + void TrimFacets(const std::vector& raulFacets, std::vector& aclNewFacets); /** * Setter: Trimm INNER or OUTER @@ -67,30 +67,30 @@ private: /** * Checks if a facet lies totally within a polygon */ - bool PolygonContainsCompleteFacet(bool bInner, unsigned long ulIndex) const; + bool PolygonContainsCompleteFacet(bool bInner, FacetIndex ulIndex) const; /** * Creates new facets from edge points of the facet */ - bool CreateFacets(unsigned long ulFacetPos, int iSide, const std::vector& raclPoints, + bool CreateFacets(FacetIndex ulFacetPos, int iSide, const std::vector& raclPoints, std::vector& aclNewFacets); /** * Creates new facets from edge points of the facet and a point inside the facet */ - bool CreateFacets(unsigned long ulFacetPos, int iSide, const std::vector& raclPoints, + bool CreateFacets(FacetIndex ulFacetPos, int iSide, const std::vector& raclPoints, Base::Vector3f& clP3, std::vector& aclNewFacets); /** * Checks if a polygon point lies within a facet */ - bool IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f& clPoint); + bool IsPolygonPointInFacet(FacetIndex ulIndex, Base::Vector3f& clPoint); /** * Calculates the two intersection points between polygonline and facet in 2D * and project the points back into 3D (not very exactly) */ - bool GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex, int& iSide, + bool GetIntersectionPointsOfPolygonAndFacet(FacetIndex ulIndex, int& iSide, std::vector& raclPoints) const; void AdjustFacet(MeshFacet& facet, int iInd); diff --git a/src/Mod/Mesh/App/Core/TrimByPlane.cpp b/src/Mod/Mesh/App/Core/TrimByPlane.cpp index 49b81d11b0..d785b5772b 100644 --- a/src/Mod/Mesh/App/Core/TrimByPlane.cpp +++ b/src/Mod/Mesh/App/Core/TrimByPlane.cpp @@ -39,12 +39,12 @@ MeshTrimByPlane::~MeshTrimByPlane() } void MeshTrimByPlane::CheckFacets(const MeshFacetGrid& rclGrid, const Base::Vector3f& base, const Base::Vector3f& normal, - std::vector &trimFacets, std::vector& removeFacets) const + std::vector &trimFacets, std::vector& removeFacets) const { // Go through the grid and check for each cell if its bounding box intersects the plane. // If the box is completely below the plane all facets will be kept, if it's above the // plane all triangles will be removed. - std::vector checkElements; + std::vector checkElements; MeshGridIterator clGridIter(rclGrid); for (clGridIter.Init(); clGridIter.More(); clGridIter.Next()) { Base::BoundBox3f clBBox3d = clGridIter.GetBoundBox(); @@ -134,7 +134,7 @@ void MeshTrimByPlane::CreateTwoFacet(const Base::Vector3f& base, const Base::Vec trimmedFacets.push_back(create); } -void MeshTrimByPlane::TrimFacets(const std::vector& trimFacets, const Base::Vector3f& base, +void MeshTrimByPlane::TrimFacets(const std::vector& trimFacets, const Base::Vector3f& base, const Base::Vector3f& normal, std::vector& trimmedFacets) { trimmedFacets.reserve(2 * trimFacets.size()); diff --git a/src/Mod/Mesh/App/Core/TrimByPlane.h b/src/Mod/Mesh/App/Core/TrimByPlane.h index 0da728355f..6192365e5a 100644 --- a/src/Mod/Mesh/App/Core/TrimByPlane.h +++ b/src/Mod/Mesh/App/Core/TrimByPlane.h @@ -43,12 +43,12 @@ public: * Checks all facets for intersection with the plane and writes all touched facets into the vector */ void CheckFacets(const MeshFacetGrid& rclGrid, const Base::Vector3f& base, const Base::Vector3f& normal, - std::vector& trimFacets, std::vector& removeFacets) const; + std::vector& trimFacets, std::vector& removeFacets) const; /** * The facets from \a trimFacets will be trimmed or deleted and \a trimmedFacets holds the newly generated facets */ - void TrimFacets(const std::vector& trimFacets, const Base::Vector3f& base, + void TrimFacets(const std::vector& trimFacets, const Base::Vector3f& base, const Base::Vector3f& normal, std::vector& trimmedFacets); private: diff --git a/src/Mod/Mesh/App/Core/Visitor.cpp b/src/Mod/Mesh/App/Core/Visitor.cpp index b532adbefe..ab0b17a4f7 100644 --- a/src/Mod/Mesh/App/Core/Visitor.cpp +++ b/src/Mod/Mesh/App/Core/Visitor.cpp @@ -31,12 +31,12 @@ using namespace MeshCore; -unsigned long MeshKernel::VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, unsigned long ulStartFacet) const +unsigned long MeshKernel::VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, FacetIndex ulStartFacet) const { unsigned long ulVisited = 0, j, ulLevel = 0; unsigned long ulCount = _aclFacetArray.size(); - std::vector clCurrentLevel, clNextLevel; - std::vector::iterator clCurrIter; + std::vector clCurrentLevel, clNextLevel; + std::vector::iterator clCurrIter; MeshFacetArray::_TConstIterator clCurrFacet, clNBFacet; // pick up start point @@ -52,7 +52,7 @@ unsigned long MeshKernel::VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, u // visit all neighbours of the current level if not yet done for (unsigned short i = 0; i < 3; i++) { j = clCurrFacet->_aulNeighbours[i]; // index to neighbour facet - if (j == ULONG_MAX) + if (j == FACET_INDEX_MAX) continue; // no neighbour facet if (j >= ulCount) @@ -83,28 +83,28 @@ unsigned long MeshKernel::VisitNeighbourFacets (MeshFacetVisitor &rclFVisitor, u return ulVisited; } -unsigned long MeshKernel::VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rclFVisitor, unsigned long ulStartFacet) const +unsigned long MeshKernel::VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rclFVisitor, FacetIndex ulStartFacet) const { unsigned long ulVisited = 0, ulLevel = 0; MeshRefPointToFacets clRPF(*this); const MeshFacetArray& raclFAry = _aclFacetArray; MeshFacetArray::_TConstIterator pFBegin = raclFAry.begin(); - std::vector aclCurrentLevel, aclNextLevel; + std::vector aclCurrentLevel, aclNextLevel; aclCurrentLevel.push_back(ulStartFacet); raclFAry[ulStartFacet].SetFlag(MeshFacet::VISIT); while (aclCurrentLevel.size() > 0) { // visit all neighbours of the current level - for (std::vector::iterator pCurrFacet = aclCurrentLevel.begin(); pCurrFacet < aclCurrentLevel.end(); ++pCurrFacet) { + for (std::vector::iterator pCurrFacet = aclCurrentLevel.begin(); pCurrFacet < aclCurrentLevel.end(); ++pCurrFacet) { for (int i = 0; i < 3; i++) { const MeshFacet &rclFacet = raclFAry[*pCurrFacet]; - const std::set& raclNB = clRPF[rclFacet._aulPoints[i]]; - for (std::set::const_iterator pINb = raclNB.begin(); pINb != raclNB.end(); ++pINb) { + const std::set& raclNB = clRPF[rclFacet._aulPoints[i]]; + for (std::set::const_iterator pINb = raclNB.begin(); pINb != raclNB.end(); ++pINb) { if (pFBegin[*pINb].IsFlag(MeshFacet::VISIT) == false) { // only visit if VISIT Flag not set ulVisited++; - unsigned long ulFInd = *pINb; + FacetIndex ulFInd = *pINb; aclNextLevel.push_back(ulFInd); pFBegin[*pINb].SetFlag(MeshFacet::VISIT); if (rclFVisitor.Visit(pFBegin[*pINb], raclFAry[*pCurrFacet], ulFInd, ulLevel) == false) @@ -121,11 +121,11 @@ unsigned long MeshKernel::VisitNeighbourFacetsOverCorners (MeshFacetVisitor &rcl return ulVisited; } -unsigned long MeshKernel::VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, unsigned long ulStartPoint) const +unsigned long MeshKernel::VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, PointIndex ulStartPoint) const { unsigned long ulVisited = 0, ulLevel = 0; - std::vector aclCurrentLevel, aclNextLevel; - std::vector::iterator clCurrIter; + std::vector aclCurrentLevel, aclNextLevel; + std::vector::iterator clCurrIter; MeshPointArray::_TConstIterator pPBegin = _aclPointArray.begin(); MeshRefPointToPoints clNPs(*this); @@ -135,12 +135,12 @@ unsigned long MeshKernel::VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, u while (aclCurrentLevel.size() > 0) { // visit all neighbours of the current level for (clCurrIter = aclCurrentLevel.begin(); clCurrIter < aclCurrentLevel.end(); ++clCurrIter) { - const std::set& raclNB = clNPs[*clCurrIter]; - for (std::set::const_iterator pINb = raclNB.begin(); pINb != raclNB.end(); ++pINb) { + const std::set& raclNB = clNPs[*clCurrIter]; + for (std::set::const_iterator pINb = raclNB.begin(); pINb != raclNB.end(); ++pINb) { if (pPBegin[*pINb].IsFlag(MeshPoint::VISIT) == false) { // only visit if VISIT Flag not set ulVisited++; - unsigned long ulPInd = *pINb; + PointIndex ulPInd = *pINb; aclNextLevel.push_back(ulPInd); pPBegin[*pINb].SetFlag(MeshPoint::VISIT); if (rclPVisitor.Visit(pPBegin[*pINb], *(pPBegin + (*clCurrIter)), ulPInd, ulLevel) == false) @@ -160,7 +160,7 @@ unsigned long MeshKernel::VisitNeighbourPoints (MeshPointVisitor &rclPVisitor, u MeshSearchNeighbourFacetsVisitor::MeshSearchNeighbourFacetsVisitor (const MeshKernel &rclMesh, float fRadius, - unsigned long ulStartFacetIdx) + FacetIndex ulStartFacetIdx) : _rclMeshBase(rclMesh), _clCenter(rclMesh.GetFacet(ulStartFacetIdx).GetGravityPoint()), _fRadius(fRadius), @@ -169,7 +169,7 @@ MeshSearchNeighbourFacetsVisitor::MeshSearchNeighbourFacetsVisitor (const MeshKe { } -std::vector MeshSearchNeighbourFacetsVisitor::GetAndReset (void) +std::vector MeshSearchNeighbourFacetsVisitor::GetAndReset () { MeshAlgorithm(_rclMeshBase).ResetFacetsFlag(_vecFacets, MeshFacet::VISIT); return _vecFacets; @@ -177,8 +177,8 @@ std::vector MeshSearchNeighbourFacetsVisitor::GetAndReset (void) // ------------------------------------------------------------------------- -MeshPlaneVisitor::MeshPlaneVisitor (const MeshKernel& mesh, unsigned long index, - float deviation, std::vector &indices) +MeshPlaneVisitor::MeshPlaneVisitor (const MeshKernel& mesh, FacetIndex index, + float deviation, std::vector &indices) : mesh(mesh), indices(indices), max_deviation(deviation), fitter(new PlaneFit) { MeshGeomFacet triangle = mesh.GetFacet(index); @@ -195,7 +195,7 @@ MeshPlaneVisitor::~MeshPlaneVisitor () } bool MeshPlaneVisitor::AllowVisit (const MeshFacet& face, const MeshFacet&, - unsigned long, unsigned long, unsigned short) + FacetIndex, unsigned long, unsigned short) { if (!fitter->Done()) fitter->Fit(); @@ -208,7 +208,7 @@ bool MeshPlaneVisitor::AllowVisit (const MeshFacet& face, const MeshFacet&, } bool MeshPlaneVisitor::Visit (const MeshFacet & face, const MeshFacet &, - unsigned long ulFInd, unsigned long) + FacetIndex ulFInd, unsigned long) { MeshGeomFacet triangle = mesh.GetFacet(face); indices.push_back(ulFInd); diff --git a/src/Mod/Mesh/App/Core/Visitor.h b/src/Mod/Mesh/App/Core/Visitor.h index bac568451e..6c31c298e5 100644 --- a/src/Mod/Mesh/App/Core/Visitor.h +++ b/src/Mod/Mesh/App/Core/Visitor.h @@ -24,9 +24,7 @@ #ifndef VISITOR_H #define VISITOR_H -#ifndef MESH_GLOBAL_H -#include -#endif +#include "Definitions.h" namespace MeshCore { @@ -53,14 +51,14 @@ public: * If \a true is returned the next iteration is done if there are still facets to visit. * If \a false is returned the calling method stops immediately visiting further facets. */ - virtual bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, unsigned long ulFInd, + virtual bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, FacetIndex ulFInd, unsigned long ulLevel) = 0; /** Test before a facet will be flagged as VISIT, return false means: go on with * visiting the facets but not this one and set not the VISIT flag */ virtual bool AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom, - unsigned long ulFInd, unsigned long ulLevel, + FacetIndex ulFInd, unsigned long ulLevel, unsigned short neighbourIndex) { (void)rclFacet; @@ -78,12 +76,12 @@ public: class MeshExport MeshSearchNeighbourFacetsVisitor : public MeshFacetVisitor { public: - MeshSearchNeighbourFacetsVisitor (const MeshKernel &rclMesh, float fRadius, unsigned long ulStartFacetIdx); + MeshSearchNeighbourFacetsVisitor (const MeshKernel &rclMesh, float fRadius, FacetIndex ulStartFacetIdx); virtual ~MeshSearchNeighbourFacetsVisitor () {} /** Checks the facet if it lies inside the search radius. */ - inline bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel); + inline bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, FacetIndex ulFInd, unsigned long ulLevel); /** Resets the VISIT flag of already visited facets. */ - inline std::vector GetAndReset (void); + inline std::vector GetAndReset (); protected: const MeshKernel& _rclMeshBase; /**< The mesh kernel. */ @@ -91,11 +89,11 @@ protected: float _fRadius; /**< Search radius. */ unsigned long _ulCurrentLevel; bool _bFacetsFoundInCurrentLevel; - std::vector _vecFacets; /**< Found facets. */ + std::vector _vecFacets; /**< Found facets. */ }; inline bool MeshSearchNeighbourFacetsVisitor::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, - unsigned long ulFInd, unsigned long ulLevel) + FacetIndex ulFInd, unsigned long ulLevel) { (void)rclFrom; if (ulLevel > _ulCurrentLevel) { @@ -122,11 +120,11 @@ inline bool MeshSearchNeighbourFacetsVisitor::Visit (const MeshFacet &rclFacet, class MeshExport MeshTopFacetVisitor : public MeshFacetVisitor { public: - MeshTopFacetVisitor (std::vector &raulNB) : _raulNeighbours(raulNB) {} + MeshTopFacetVisitor (std::vector &raulNB) : _raulNeighbours(raulNB) {} virtual ~MeshTopFacetVisitor () {} /** Collects the facet indices. */ virtual bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, - unsigned long ulFInd, unsigned long) + FacetIndex ulFInd, unsigned long) { (void)rclFacet; (void)rclFrom; @@ -135,7 +133,7 @@ public: } protected: - std::vector &_raulNeighbours; /**< Indices of all visited facets. */ + std::vector &_raulNeighbours; /**< Indices of all visited facets. */ }; // ------------------------------------------------------------------------- @@ -148,18 +146,18 @@ class MeshPlaneVisitor : public MeshFacetVisitor { public: MeshPlaneVisitor (const MeshKernel& mesh, - unsigned long index, + FacetIndex index, float deviation, - std::vector &indices); + std::vector &indices); virtual ~MeshPlaneVisitor (); bool AllowVisit (const MeshFacet& face, const MeshFacet&, - unsigned long, unsigned long, unsigned short neighbourIndex); + FacetIndex, unsigned long, unsigned short neighbourIndex); bool Visit (const MeshFacet & face, const MeshFacet &, - unsigned long ulFInd, unsigned long); + FacetIndex ulFInd, unsigned long); protected: const MeshKernel& mesh; - std::vector &indices; + std::vector &indices; Base::Vector3f basepoint; Base::Vector3f normal; float max_deviation; @@ -185,7 +183,7 @@ public: * \a false is returned the calling method stops immediately visiting further points. */ virtual bool Visit (const MeshPoint &rclPoint, const MeshPoint &rclFrom, - unsigned long ulPInd, unsigned long ulLevel) = 0; + FacetIndex ulPInd, unsigned long ulLevel) = 0; }; } // namespace MeshCore diff --git a/src/Mod/Mesh/App/Exporter.cpp b/src/Mod/Mesh/App/Exporter.cpp index bd21ff0106..5be6ba4ae5 100644 --- a/src/Mod/Mesh/App/Exporter.cpp +++ b/src/Mod/Mesh/App/Exporter.cpp @@ -180,9 +180,9 @@ bool MergeExporter::addMesh(const char *name, const MeshObject & mesh) for (unsigned long i=0; i indices = segm.getIndices(); + std::vector indices = segm.getIndices(); std::for_each( indices.begin(), indices.end(), - [countFacets] (unsigned long &v) { + [countFacets] (FacetIndex &v) { v += countFacets; } ); Segment new_segm(&mergingMesh, indices, true); @@ -192,9 +192,9 @@ bool MergeExporter::addMesh(const char *name, const MeshObject & mesh) } } else { // now create a segment for the added mesh - std::vector indices; + std::vector indices; indices.resize(mergingMesh.countFacets() - countFacets); - std::generate(indices.begin(), indices.end(), Base::iotaGen(countFacets)); + std::generate(indices.begin(), indices.end(), Base::iotaGen(countFacets)); Segment segm(&mergingMesh, indices, true); segm.setName(name); mergingMesh.addSegment(segm); diff --git a/src/Mod/Mesh/App/Facet.cpp b/src/Mod/Mesh/App/Facet.cpp index b8e1df0d28..73ff133527 100644 --- a/src/Mod/Mesh/App/Facet.cpp +++ b/src/Mod/Mesh/App/Facet.cpp @@ -31,14 +31,14 @@ using namespace Mesh; -Facet::Facet(const MeshCore::MeshFacet& face, MeshObject* obj, unsigned long index) +Facet::Facet(const MeshCore::MeshFacet& face, MeshObject* obj, MeshCore::FacetIndex index) : Index(index), Mesh(obj) { for (int i=0; i<3; i++) { PIndex[i] = face._aulPoints[i]; NIndex[i] = face._aulNeighbours[i]; } - if (Mesh.isValid() && index != ULONG_MAX) { + if (Mesh.isValid() && index != MeshCore::FACET_INDEX_MAX) { for (int i=0; i<3; i++) { Base::Vector3d vert = Mesh->getPoint(PIndex[i]); _aclPoints[i].Set((float)vert.x, (float)vert.y, (float)vert.z); diff --git a/src/Mod/Mesh/App/Facet.h b/src/Mod/Mesh/App/Facet.h index c2f8a9e3e9..9fb8224605 100644 --- a/src/Mod/Mesh/App/Facet.h +++ b/src/Mod/Mesh/App/Facet.h @@ -43,16 +43,16 @@ class MeshObject; class MeshExport Facet : public MeshCore::MeshGeomFacet { public: - Facet(const MeshCore::MeshFacet& face = MeshCore::MeshFacet(), MeshObject* obj = 0, unsigned long index = ULONG_MAX); + Facet(const MeshCore::MeshFacet& face = MeshCore::MeshFacet(), MeshObject* obj = nullptr, MeshCore::FacetIndex index = MeshCore::FACET_INDEX_MAX); Facet(const Facet& f); ~Facet(); - bool isBound(void) const {return Index != ULONG_MAX;} + bool isBound() const {return Index != MeshCore::FACET_INDEX_MAX;} void operator = (const Facet& f); - unsigned long Index; - unsigned long PIndex[3]; - unsigned long NIndex[3]; + MeshCore::FacetIndex Index; + MeshCore::PointIndex PIndex[3]; + MeshCore::FacetIndex NIndex[3]; Base::Reference Mesh; }; diff --git a/src/Mod/Mesh/App/FacetPyImp.cpp b/src/Mod/Mesh/App/FacetPyImp.cpp index dba93fb20e..4610b17e95 100644 --- a/src/Mod/Mesh/App/FacetPyImp.cpp +++ b/src/Mod/Mesh/App/FacetPyImp.cpp @@ -34,7 +34,7 @@ using namespace Mesh; // returns a string which represent the object e.g. when printed in python -std::string FacetPy::representation(void) const +std::string FacetPy::representation() const { FacetPy::PointerType ptr = getFacetPtr(); std::stringstream str; @@ -72,23 +72,23 @@ int FacetPy::PyInit(PyObject* args, PyObject* /*kwds*/) PyObject* FacetPy::unbound(PyObject *args) { if (!PyArg_ParseTuple(args, "")) - return NULL; - getFacetPtr()->Index = ULONG_MAX; - getFacetPtr()->Mesh = 0; + return nullptr; + getFacetPtr()->Index = MeshCore::FACET_INDEX_MAX; + getFacetPtr()->Mesh = nullptr; Py_Return; } -Py::Long FacetPy::getIndex(void) const +Py::Long FacetPy::getIndex() const { return Py::Long((long) getFacetPtr()->Index); } -Py::Boolean FacetPy::getBound(void) const +Py::Boolean FacetPy::getBound() const { return Py::Boolean(getFacetPtr()->Index != UINT_MAX); } -Py::Object FacetPy::getNormal(void) const +Py::Object FacetPy::getNormal() const { Base::VectorPy* normal = new Base::VectorPy(getFacetPtr()->GetNormal()); normal->setConst(); @@ -99,7 +99,7 @@ PyObject* FacetPy::intersect(PyObject *args) { PyObject* object; if (!PyArg_ParseTuple(args, "O!", &FacetPy::Type, &object)) - return NULL; + return nullptr; FacetPy *face = static_cast(object); FacetPy::PointerType face_ptr = face->getFacetPtr(); FacetPy::PointerType this_ptr = this->getFacetPtr(); @@ -127,7 +127,7 @@ PyObject* FacetPy::intersect(PyObject *args) return Py::new_reference_to(sct); } catch (const Py::Exception&) { - return 0; + return nullptr; } } @@ -135,7 +135,7 @@ PyObject* FacetPy::isDegenerated(PyObject *args) { float fEpsilon = MeshCore::MeshDefinitions::_fMinPointDistanceP2; if (!PyArg_ParseTuple(args, "|f", &fEpsilon)) - return NULL; + return nullptr; FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -152,7 +152,7 @@ PyObject* FacetPy::isDeformed(PyObject *args) float fMinAngle; float fMaxAngle; if (!PyArg_ParseTuple(args, "ff", &fMinAngle, &fMaxAngle)) - return NULL; + return nullptr; FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -166,7 +166,7 @@ PyObject* FacetPy::isDeformed(PyObject *args) return Py::new_reference_to(Py::Boolean(tria.IsDeformed(fCosOfMinAngle, fCosOfMaxAngle))); } -Py::List FacetPy::getPoints(void) const +Py::List FacetPy::getPoints() const { FacetPy::PointerType face = this->getFacetPtr(); @@ -182,7 +182,7 @@ Py::List FacetPy::getPoints(void) const return pts; } -Py::Tuple FacetPy::getPointIndices(void) const +Py::Tuple FacetPy::getPointIndices() const { FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) @@ -195,7 +195,7 @@ Py::Tuple FacetPy::getPointIndices(void) const return idxTuple; } -Py::Tuple FacetPy::getNeighbourIndices(void) const +Py::Tuple FacetPy::getNeighbourIndices() const { FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -209,7 +209,7 @@ Py::Tuple FacetPy::getNeighbourIndices(void) const return idxTuple; } -Py::Float FacetPy::getArea(void) const +Py::Float FacetPy::getArea() const { FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -221,7 +221,7 @@ Py::Float FacetPy::getArea(void) const return Py::Float(tria.Area()); } -Py::Float FacetPy::getAspectRatio(void) const +Py::Float FacetPy::getAspectRatio() const { FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -233,7 +233,7 @@ Py::Float FacetPy::getAspectRatio(void) const return Py::Float(tria.AspectRatio()); } -Py::Float FacetPy::getAspectRatio2(void) const +Py::Float FacetPy::getAspectRatio2() const { FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -245,7 +245,7 @@ Py::Float FacetPy::getAspectRatio2(void) const return Py::Float(tria.AspectRatio2()); } -Py::Float FacetPy::getRoundness(void) const +Py::Float FacetPy::getRoundness() const { FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -257,7 +257,7 @@ Py::Float FacetPy::getRoundness(void) const return Py::Float(tria.Roundness()); } -Py::Tuple FacetPy::getCircumCircle(void) const +Py::Tuple FacetPy::getCircumCircle() const { FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -274,7 +274,7 @@ Py::Tuple FacetPy::getCircumCircle(void) const return tuple; } -Py::Tuple FacetPy::getInCircle(void) const +Py::Tuple FacetPy::getInCircle() const { FacetPy::PointerType face = this->getFacetPtr(); if (!face->isBound()) { @@ -293,7 +293,7 @@ Py::Tuple FacetPy::getInCircle(void) const PyObject *FacetPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int FacetPy::setCustomAttributes(const char* /*attr*/, PyObject * /*obj*/) diff --git a/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp b/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp index 0988b699b3..4c6b51345b 100644 --- a/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp +++ b/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp @@ -44,10 +44,10 @@ using namespace MeshCore; PROPERTY_SOURCE(Mesh::SegmentByMesh, Mesh::Feature) -SegmentByMesh::SegmentByMesh(void) +SegmentByMesh::SegmentByMesh() { - ADD_PROPERTY(Source ,(0)); - ADD_PROPERTY(Tool ,(0)); + ADD_PROPERTY(Source ,(nullptr)); + ADD_PROPERTY(Tool ,(nullptr)); ADD_PROPERTY(Base ,(0.0,0.0,0.0)); ADD_PROPERTY(Normal ,(0.0,0.0,1.0)); } @@ -63,9 +63,9 @@ short SegmentByMesh::mustExecute() const return 0; } -App::DocumentObjectExecReturn *SegmentByMesh::execute(void) +App::DocumentObjectExecReturn *SegmentByMesh::execute() { - Mesh::PropertyMeshKernel *kernel=0; + Mesh::PropertyMeshKernel *kernel=nullptr; App::DocumentObject* mesh = Source.getValue(); if (mesh) { App::Property* prop = mesh->getPropertyByName("Mesh"); @@ -77,7 +77,7 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void) else if (mesh->isError()) return new App::DocumentObjectExecReturn("No valid mesh.\n"); - Mesh::PropertyMeshKernel *toolmesh=0; + Mesh::PropertyMeshKernel *toolmesh=nullptr; App::DocumentObject* tool = Tool.getValue(); if (tool) { App::Property* prop = tool->getPropertyByName("Mesh"); @@ -106,7 +106,7 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void) return new App::DocumentObjectExecReturn("Toolmesh is not solid.\n"); } - std::vector faces; + std::vector faces; std::vector aFaces; MeshAlgorithm cAlg(rMeshKernel); @@ -121,11 +121,11 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void) // so we need the nearest facet to the front clipping plane // float fDist = FLOAT_MAX; - unsigned long uIdx=ULONG_MAX; + MeshCore::FacetIndex uIdx = MeshCore::FACET_INDEX_MAX; MeshFacetIterator cFIt(rMeshKernel); // get the nearest facet to the user (front clipping plane) - for ( std::vector::iterator it = faces.begin(); it != faces.end(); ++it ) { + for ( std::vector::iterator it = faces.begin(); it != faces.end(); ++it ) { cFIt.Set(*it); float dist = (float)fabs(cFIt->GetGravityPoint().DistanceToPlane( cBase, cNormal )); if ( dist < fDist ) { @@ -135,7 +135,7 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void) } // succeeded - if ( uIdx != ULONG_MAX ) { + if ( uIdx != MeshCore::FACET_INDEX_MAX ) { // set VISIT-Flag to all outer facets cAlg.SetFacetFlag( MeshFacet::VISIT ); cAlg.ResetFacetsFlag(faces, MeshFacet::VISIT); @@ -149,7 +149,7 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void) } } - for ( std::vector::iterator it = faces.begin(); it != faces.end(); ++it ) + for ( std::vector::iterator it = faces.begin(); it != faces.end(); ++it ) aFaces.push_back( rMeshKernel.GetFacet(*it) ); std::unique_ptr pcKernel(new MeshObject); diff --git a/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.h b/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.h index 5cc9c7ead3..29295b9f8e 100644 --- a/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.h +++ b/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.h @@ -56,7 +56,7 @@ public: /** @name methods override Feature */ //@{ /// recalculate the Feature - App::DocumentObjectExecReturn *execute(void); + App::DocumentObjectExecReturn *execute(); short mustExecute() const; //@} }; diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index 2f727d90c6..5c45b0e641 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -90,7 +90,7 @@ MeshObject::~MeshObject() { } -std::vector MeshObject::getElementTypes(void) const +std::vector MeshObject::getElementTypes() const { std::vector temp; temp.push_back("Face"); // that's the mesh itself @@ -114,10 +114,10 @@ Data::Segment* MeshObject::getSubElement(const char* Type, unsigned long /*n*/) //TODO std::string element(Type); if (element == "Face") - return 0; + return nullptr; else if (element == "Segment") - return 0; - return 0; + return nullptr; + return nullptr; } void MeshObject::getFacesFromSubelement(const Data::Segment* /*segm*/, @@ -142,12 +142,12 @@ void MeshObject::setTransform(const Base::Matrix4D& rclTrf) _Mtrx = rclTrf; } -Base::Matrix4D MeshObject::getTransform(void) const +Base::Matrix4D MeshObject::getTransform() const { return _Mtrx; } -Base::BoundBox3d MeshObject::getBoundBox(void)const +Base::BoundBox3d MeshObject::getBoundBox()const { const_cast(_kernel).RecalcBoundBox(); Base::BoundBox3f Bnd = _kernel.GetBoundBox(); @@ -266,7 +266,7 @@ double MeshObject::getVolume() const return _kernel.GetVolume(); } -MeshPoint MeshObject::getPoint(unsigned long index) const +MeshPoint MeshObject::getPoint(PointIndex index) const { Base::Vector3f vertf = _kernel.GetPoint(index); Base::Vector3d vertd(vertf.x, vertf.y, vertf.z); @@ -304,7 +304,7 @@ void MeshObject::getPoints(std::vector &Points, } } -Mesh::Facet MeshObject::getFacet(unsigned long index) const +Mesh::Facet MeshObject::getFacet(FacetIndex index) const { Mesh::Facet face(_kernel.GetFacets()[index], const_cast(this), index); return face; @@ -331,7 +331,7 @@ void MeshObject::getFaces(std::vector &Points,std::vector } } -unsigned int MeshObject::getMemSize (void) const +unsigned int MeshObject::getMemSize () const { return _kernel.GetMemSize(); } @@ -470,7 +470,7 @@ void MeshObject::swapKernel(MeshCore::MeshKernel& kernel, this->_segments.clear(); const MeshCore::MeshFacetArray& faces = _kernel.GetFacets(); MeshCore::MeshFacetArray::_TConstIterator it; - std::vector segment; + std::vector segment; segment.reserve(faces.size()); unsigned long prop = 0; unsigned long index = 0; @@ -637,7 +637,7 @@ void MeshObject::addMesh(const MeshCore::MeshKernel& kernel) _kernel.Merge(kernel); } -void MeshObject::deleteFacets(const std::vector& removeIndices) +void MeshObject::deleteFacets(const std::vector& removeIndices) { if (removeIndices.empty()) return; @@ -645,7 +645,7 @@ void MeshObject::deleteFacets(const std::vector& removeIndices) deletedFacets(removeIndices); } -void MeshObject::deletePoints(const std::vector& removeIndices) +void MeshObject::deletePoints(const std::vector& removeIndices) { if (removeIndices.empty()) return; @@ -653,21 +653,21 @@ void MeshObject::deletePoints(const std::vector& removeIndices) this->_segments.clear(); } -void MeshObject::deletedFacets(const std::vector& remFacets) +void MeshObject::deletedFacets(const std::vector& remFacets) { if (remFacets.empty()) return; // nothing has changed if (this->_segments.empty()) return; // nothing to do - // set an array with the original indices and mark the removed as ULONG_MAX - std::vector f_indices(_kernel.CountFacets()+remFacets.size()); - for (std::vector::const_iterator it = remFacets.begin(); + // set an array with the original indices and mark the removed as MeshCore::FACET_INDEX_MAX + std::vector f_indices(_kernel.CountFacets()+remFacets.size()); + for (std::vector::const_iterator it = remFacets.begin(); it != remFacets.end(); ++it) { - f_indices[*it] = ULONG_MAX; + f_indices[*it] = MeshCore::FACET_INDEX_MAX; } - unsigned long index = 0; - for (std::vector::iterator it = f_indices.begin(); + FacetIndex index = 0; + for (std::vector::iterator it = f_indices.begin(); it != f_indices.end(); ++it) { if (*it == 0) *it = index++; @@ -676,17 +676,17 @@ void MeshObject::deletedFacets(const std::vector& remFacets) // the array serves now as LUT to set the new indices in the segments for (std::vector::iterator it = this->_segments.begin(); it != this->_segments.end(); ++it) { - std::vector segm = it->_indices; - for (std::vector::iterator jt = segm.begin(); + std::vector segm = it->_indices; + for (std::vector::iterator jt = segm.begin(); jt != segm.end(); ++jt) { *jt = f_indices[*jt]; } // remove the invalid indices std::sort(segm.begin(), segm.end()); - std::vector::iterator ft = std::find_if - (segm.begin(), segm.end(), [](unsigned long v) { - return v == ULONG_MAX; + std::vector::iterator ft = std::find_if + (segm.begin(), segm.end(), [](FacetIndex v) { + return v == MeshCore::FACET_INDEX_MAX; }); if (ft != segm.end()) segm.erase(ft, segm.end()); @@ -696,14 +696,14 @@ void MeshObject::deletedFacets(const std::vector& remFacets) void MeshObject::deleteSelectedFacets() { - std::vector facets; + std::vector facets; MeshCore::MeshAlgorithm(this->_kernel).GetFacetsFlag(facets, MeshCore::MeshFacet::SELECTED); deleteFacets(facets); } void MeshObject::deleteSelectedPoints() { - std::vector points; + std::vector points; MeshCore::MeshAlgorithm(this->_kernel).GetPointsFlag(points, MeshCore::MeshPoint::SELECTED); deletePoints(points); } @@ -718,32 +718,32 @@ void MeshObject::clearPointSelection() const MeshCore::MeshAlgorithm(this->_kernel).ResetPointFlag(MeshCore::MeshPoint::SELECTED); } -void MeshObject::addFacetsToSelection(const std::vector& inds) const +void MeshObject::addFacetsToSelection(const std::vector& inds) const { MeshCore::MeshAlgorithm(this->_kernel).SetFacetsFlag(inds, MeshCore::MeshFacet::SELECTED); } -void MeshObject::addPointsToSelection(const std::vector& inds) const +void MeshObject::addPointsToSelection(const std::vector& inds) const { MeshCore::MeshAlgorithm(this->_kernel).SetPointsFlag(inds, MeshCore::MeshPoint::SELECTED); } -void MeshObject::removeFacetsFromSelection(const std::vector& inds) const +void MeshObject::removeFacetsFromSelection(const std::vector& inds) const { MeshCore::MeshAlgorithm(this->_kernel).ResetFacetsFlag(inds, MeshCore::MeshFacet::SELECTED); } -void MeshObject::removePointsFromSelection(const std::vector& inds) const +void MeshObject::removePointsFromSelection(const std::vector& inds) const { MeshCore::MeshAlgorithm(this->_kernel).ResetPointsFlag(inds, MeshCore::MeshPoint::SELECTED); } -void MeshObject::getFacetsFromSelection(std::vector& inds) const +void MeshObject::getFacetsFromSelection(std::vector& inds) const { MeshCore::MeshAlgorithm(this->_kernel).GetFacetsFlag(inds, MeshCore::MeshFacet::SELECTED); } -void MeshObject::getPointsFromSelection(std::vector& inds) const +void MeshObject::getPointsFromSelection(std::vector& inds) const { MeshCore::MeshAlgorithm(this->_kernel).GetPointsFlag(inds, MeshCore::MeshPoint::SELECTED); } @@ -768,14 +768,14 @@ bool MeshObject::hasSelectedPoints() const return (countSelectedPoints() > 0); } -std::vector MeshObject::getPointsFromFacets(const std::vector& facets) const +std::vector MeshObject::getPointsFromFacets(const std::vector& facets) const { return _kernel.GetFacetPoints(facets); } -void MeshObject::updateMesh(const std::vector& facets) +void MeshObject::updateMesh(const std::vector& facets) { - std::vector points; + std::vector points; points = _kernel.GetFacetPoints(facets); MeshCore::MeshAlgorithm alg(_kernel); @@ -790,16 +790,16 @@ void MeshObject::updateMesh() alg.ResetPointFlag(MeshCore::MeshPoint::SEGMENT); for (std::vector::iterator it = this->_segments.begin(); it != this->_segments.end(); ++it) { - std::vector points; + std::vector points; points = _kernel.GetFacetPoints(it->getIndices()); alg.SetFacetsFlag(it->getIndices(), MeshCore::MeshFacet::SEGMENT); alg.SetPointsFlag(points, MeshCore::MeshPoint::SEGMENT); } } -std::vector > MeshObject::getComponents() const +std::vector > MeshObject::getComponents() const { - std::vector > segments; + std::vector > segments; MeshCore::MeshComponents comp(_kernel); comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segments); return segments; @@ -807,7 +807,7 @@ std::vector > MeshObject::getComponents() const unsigned long MeshObject::countComponents() const { - std::vector > segments; + std::vector > segments; MeshCore::MeshComponents comp(_kernel); comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segments); return segments.size(); @@ -815,17 +815,17 @@ unsigned long MeshObject::countComponents() const void MeshObject::removeComponents(unsigned long count) { - std::vector removeIndices; + std::vector removeIndices; MeshCore::MeshTopoAlgorithm(_kernel).FindComponents(count, removeIndices); _kernel.DeleteFacets(removeIndices); deletedFacets(removeIndices); } -unsigned long MeshObject::getPointDegree(const std::vector& indices, - std::vector& point_degree) const +unsigned long MeshObject::getPointDegree(const std::vector& indices, + std::vector& point_degree) const { const MeshCore::MeshFacetArray& faces = _kernel.GetFacets(); - std::vector pointDeg(_kernel.CountPoints()); + std::vector pointDeg(_kernel.CountPoints()); for (MeshCore::MeshFacetArray::_TConstIterator it = faces.begin(); it != faces.end(); ++it) { pointDeg[it->_aulPoints[0]]++; @@ -833,14 +833,14 @@ unsigned long MeshObject::getPointDegree(const std::vector& indic pointDeg[it->_aulPoints[2]]++; } - for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) { + for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) { const MeshCore::MeshFacet& face = faces[*it]; pointDeg[face._aulPoints[0]]--; pointDeg[face._aulPoints[1]]--; pointDeg[face._aulPoints[2]]--; } - unsigned long countInvalids = std::count_if(pointDeg.begin(), pointDeg.end(), [](unsigned long v) { + unsigned long countInvalids = std::count_if(pointDeg.begin(), pointDeg.end(), [](PointIndex v) { return v == 0; }); @@ -851,7 +851,7 @@ unsigned long MeshObject::getPointDegree(const std::vector& indic void MeshObject::fillupHoles(unsigned long length, int level, MeshCore::AbstractPolygonTriangulator& cTria) { - std::list > aFailed; + std::list > aFailed; MeshCore::MeshTopoAlgorithm topalg(_kernel); topalg.FillupHoles(length, level, cTria, aFailed); } @@ -873,7 +873,7 @@ void MeshObject::offsetSpecial2(float fSize) Base::Builder3D builder; std::vector PointNormals= _kernel.CalcVertexNormals(); std::vector FaceNormals; - std::set fliped; + std::set fliped; MeshCore::MeshFacetIterator it(_kernel); for (it.Init(); it.More(); it.Next()) @@ -908,7 +908,7 @@ void MeshObject::offsetSpecial2(float fSize) if (fliped.size() == 0) break; - for( std::set::iterator It= fliped.begin();It!=fliped.end();++It) + for( std::set::iterator It= fliped.begin();It!=fliped.end();++It) alg.CollapseFacet(*It); fliped.clear(); } @@ -917,7 +917,7 @@ void MeshObject::offsetSpecial2(float fSize) // search for intersected facets MeshCore::MeshEvalSelfIntersection eval(_kernel); - std::vector > faces; + std::vector > faces; eval.GetIntersections(faces); builder.saveToLog(); } @@ -941,7 +941,7 @@ void MeshObject::offsetSpecial(float fSize, float zmax, float zmin) } } -void MeshObject::clear(void) +void MeshObject::clear() { _kernel.Clear(); this->_segments.clear(); @@ -964,7 +964,7 @@ Base::Matrix4D MeshObject::getEigenSystem(Base::Vector3d& v) const return cMeshEval.Transform(); } -void MeshObject::movePoint(unsigned long index, const Base::Vector3d& v) +void MeshObject::movePoint(PointIndex index, const Base::Vector3d& v) { // v is a vector, hence we must not apply the translation part // of the transformation to the vector @@ -975,7 +975,7 @@ void MeshObject::movePoint(unsigned long index, const Base::Vector3d& v) _kernel.MovePoint(index,transformToInside(vec)); } -void MeshObject::setPoint(unsigned long index, const Base::Vector3d& p) +void MeshObject::setPoint(PointIndex index, const Base::Vector3d& p) { _kernel.SetPoint(index,transformToInside(p)); } @@ -997,7 +997,7 @@ void MeshObject::decimate(int targetSize) dm.simplify(targetSize); } -Base::Vector3d MeshObject::getPointNormal(unsigned long index) const +Base::Vector3d MeshObject::getPointNormal(PointIndex index) const { std::vector temp = _kernel.CalcVertexNormals(); Base::Vector3d normal = transformToOutside(temp[index]); @@ -1050,7 +1050,7 @@ void MeshObject::cut(const Base::Polygon2d& polygon2d, const Base::ViewProjMethod& proj, MeshObject::CutType type) { MeshCore::MeshAlgorithm meshAlg(this->_kernel); - std::vector check; + std::vector check; bool inner; switch (type) { @@ -1075,7 +1075,7 @@ void MeshObject::trim(const Base::Polygon2d& polygon2d, const Base::ViewProjMethod& proj, MeshObject::CutType type) { MeshCore::MeshTrimming trim(this->_kernel, &proj, polygon2d); - std::vector check; + std::vector check; std::vector triangle; switch (type) { @@ -1099,7 +1099,7 @@ void MeshObject::trim(const Base::Polygon2d& polygon2d, void MeshObject::trim(const Base::Vector3f& base, const Base::Vector3f& normal) { MeshCore::MeshTrimByPlane trim(this->_kernel); - std::vector trimFacets, removeFacets; + std::vector trimFacets, removeFacets; std::vector triangle; MeshCore::MeshFacetGrid meshGrid(this->_kernel); @@ -1230,13 +1230,13 @@ void MeshObject::optimizeEdges() void MeshObject::splitEdges() { - std::vector > adjacentFacet; + std::vector > adjacentFacet; MeshCore::MeshAlgorithm alg(_kernel); alg.ResetFacetFlag(MeshCore::MeshFacet::VISIT); const MeshCore::MeshFacetArray& rFacets = _kernel.GetFacets(); for (MeshCore::MeshFacetArray::_TConstIterator pF = rFacets.begin(); pF != rFacets.end(); ++pF) { int id=2; - if (pF->_aulNeighbours[id] != ULONG_MAX) { + if (pF->_aulNeighbours[id] != MeshCore::FACET_INDEX_MAX) { const MeshCore::MeshFacet& rFace = rFacets[pF->_aulNeighbours[id]]; if (!pF->IsFlag(MeshCore::MeshFacet::VISIT) && !rFace.IsFlag(MeshCore::MeshFacet::VISIT)) { pF->SetFlag(MeshCore::MeshFacet::VISIT); @@ -1248,7 +1248,7 @@ void MeshObject::splitEdges() MeshCore::MeshFacetIterator cIter(_kernel); MeshCore::MeshTopoAlgorithm topalg(_kernel); - for (std::vector >::iterator it = adjacentFacet.begin(); it != adjacentFacet.end(); ++it) { + for (std::vector >::iterator it = adjacentFacet.begin(); it != adjacentFacet.end(); ++it) { cIter.Set(it->first); Base::Vector3f mid = 0.5f*(cIter->_aclPoints[0]+cIter->_aclPoints[2]); topalg.SplitEdge(it->first, it->second, mid); @@ -1259,62 +1259,62 @@ void MeshObject::splitEdges() this->_segments.clear(); } -void MeshObject::splitEdge(unsigned long facet, unsigned long neighbour, const Base::Vector3f& v) +void MeshObject::splitEdge(FacetIndex facet, FacetIndex neighbour, const Base::Vector3f& v) { MeshCore::MeshTopoAlgorithm topalg(_kernel); topalg.SplitEdge(facet, neighbour, v); } -void MeshObject::splitFacet(unsigned long facet, const Base::Vector3f& v1, const Base::Vector3f& v2) +void MeshObject::splitFacet(FacetIndex facet, const Base::Vector3f& v1, const Base::Vector3f& v2) { MeshCore::MeshTopoAlgorithm topalg(_kernel); topalg.SplitFacet(facet, v1, v2); } -void MeshObject::swapEdge(unsigned long facet, unsigned long neighbour) +void MeshObject::swapEdge(FacetIndex facet, FacetIndex neighbour) { MeshCore::MeshTopoAlgorithm topalg(_kernel); topalg.SwapEdge(facet, neighbour); } -void MeshObject::collapseEdge(unsigned long facet, unsigned long neighbour) +void MeshObject::collapseEdge(FacetIndex facet, FacetIndex neighbour) { MeshCore::MeshTopoAlgorithm topalg(_kernel); topalg.CollapseEdge(facet, neighbour); - std::vector remFacets; + std::vector remFacets; remFacets.push_back(facet); remFacets.push_back(neighbour); deletedFacets(remFacets); } -void MeshObject::collapseFacet(unsigned long facet) +void MeshObject::collapseFacet(FacetIndex facet) { MeshCore::MeshTopoAlgorithm topalg(_kernel); topalg.CollapseFacet(facet); - std::vector remFacets; + std::vector remFacets; remFacets.push_back(facet); deletedFacets(remFacets); } -void MeshObject::collapseFacets(const std::vector& facets) +void MeshObject::collapseFacets(const std::vector& facets) { MeshCore::MeshTopoAlgorithm alg(_kernel); - for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { + for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { alg.CollapseFacet(*it); } deletedFacets(facets); } -void MeshObject::insertVertex(unsigned long facet, const Base::Vector3f& v) +void MeshObject::insertVertex(FacetIndex facet, const Base::Vector3f& v) { MeshCore::MeshTopoAlgorithm topalg(_kernel); topalg.InsertVertex(facet, v); } -void MeshObject::snapVertex(unsigned long facet, const Base::Vector3f& v) +void MeshObject::snapVertex(FacetIndex facet, const Base::Vector3f& v) { MeshCore::MeshTopoAlgorithm topalg(_kernel); topalg.SnapVertex(facet, v); @@ -1323,7 +1323,7 @@ void MeshObject::snapVertex(unsigned long facet, const Base::Vector3f& v) unsigned long MeshObject::countNonUniformOrientedFacets() const { MeshCore::MeshEvalOrientation cMeshEval(_kernel); - std::vector inds = cMeshEval.GetIndices(); + std::vector inds = cMeshEval.GetIndices(); return inds.size(); } @@ -1359,7 +1359,7 @@ void MeshObject::removeNonManifoldPoints() { MeshCore::MeshEvalPointManifolds p_eval(_kernel); if (!p_eval.Evaluate()) { - std::vector faces; + std::vector faces; p_eval.GetFacetIndices(faces); deleteFacets(faces); } @@ -1373,7 +1373,7 @@ bool MeshObject::hasSelfIntersections() const void MeshObject::removeSelfIntersections() { - std::vector > selfIntersections; + std::vector > selfIntersections; MeshCore::MeshEvalSelfIntersection cMeshEval(_kernel); cMeshEval.GetIntersections(selfIntersections); @@ -1383,19 +1383,19 @@ void MeshObject::removeSelfIntersections() } } -void MeshObject::removeSelfIntersections(const std::vector& indices) +void MeshObject::removeSelfIntersections(const std::vector& indices) { // make sure that the number of indices is even and are in range if (indices.size() % 2 != 0) return; unsigned long cntfacets = _kernel.CountFacets(); - if (std::find_if(indices.begin(), indices.end(), [cntfacets](unsigned long v) { return v >= cntfacets; }) < indices.end()) + if (std::find_if(indices.begin(), indices.end(), [cntfacets](FacetIndex v) { return v >= cntfacets; }) < indices.end()) return; - std::vector > selfIntersections; - std::vector::const_iterator it; + std::vector > selfIntersections; + std::vector::const_iterator it; for (it = indices.begin(); it != indices.end(); ) { - unsigned long id1 = *it; ++it; - unsigned long id2 = *it; ++it; + FacetIndex id1 = *it; ++it; + FacetIndex id2 = *it; ++it; selfIntersections.emplace_back(id1,id2); } @@ -1408,15 +1408,15 @@ void MeshObject::removeSelfIntersections(const std::vector& indic void MeshObject::removeFoldsOnSurface() { - std::vector indices; + std::vector indices; MeshCore::MeshEvalFoldsOnSurface s_eval(_kernel); MeshCore::MeshEvalFoldOversOnSurface f_eval(_kernel); f_eval.Evaluate(); - std::vector inds = f_eval.GetIndices(); + std::vector inds = f_eval.GetIndices(); s_eval.Evaluate(); - std::vector inds1 = s_eval.GetIndices(); + std::vector inds1 = s_eval.GetIndices(); // remove duplicates inds.insert(inds.end(), inds1.begin(), inds1.end()); @@ -1439,7 +1439,7 @@ void MeshObject::removeFoldsOnSurface() void MeshObject::removeFullBoundaryFacets() { - std::vector facets; + std::vector facets; if (!MeshCore::MeshEvalBorderFacet(_kernel, facets).Evaluate()) { deleteFacets(facets); } @@ -1592,7 +1592,7 @@ MeshObject* MeshObject::createSphere(float radius, int sampling) try { Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true); if (module.isNull()) - return 0; + return nullptr; Py::Dict dict = module.getDict(); Py::Callable call(dict.getItem("Sphere")); Py::Tuple args(2); @@ -1605,7 +1605,7 @@ MeshObject* MeshObject::createSphere(float radius, int sampling) e.clear(); } - return 0; + return nullptr; } MeshObject* MeshObject::createEllipsoid(float radius1, float radius2, int sampling) @@ -1615,7 +1615,7 @@ MeshObject* MeshObject::createEllipsoid(float radius1, float radius2, int sampli try { Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true); if (module.isNull()) - return 0; + return nullptr; Py::Dict dict = module.getDict(); Py::Callable call(dict.getItem("Ellipsoid")); Py::Tuple args(3); @@ -1629,7 +1629,7 @@ MeshObject* MeshObject::createEllipsoid(float radius1, float radius2, int sampli e.clear(); } - return 0; + return nullptr; } MeshObject* MeshObject::createCylinder(float radius, float length, int closed, float edgelen, int sampling) @@ -1639,7 +1639,7 @@ MeshObject* MeshObject::createCylinder(float radius, float length, int closed, f try { Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true); if (module.isNull()) - return 0; + return nullptr; Py::Dict dict = module.getDict(); Py::Callable call(dict.getItem("Cylinder")); Py::Tuple args(5); @@ -1655,7 +1655,7 @@ MeshObject* MeshObject::createCylinder(float radius, float length, int closed, f e.clear(); } - return 0; + return nullptr; } MeshObject* MeshObject::createCone(float radius1, float radius2, float len, int closed, float edgelen, int sampling) @@ -1665,7 +1665,7 @@ MeshObject* MeshObject::createCone(float radius1, float radius2, float len, int try { Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true); if (module.isNull()) - return 0; + return nullptr; Py::Dict dict = module.getDict(); Py::Callable call(dict.getItem("Cone")); Py::Tuple args(6); @@ -1682,7 +1682,7 @@ MeshObject* MeshObject::createCone(float radius1, float radius2, float len, int e.clear(); } - return 0; + return nullptr; } MeshObject* MeshObject::createTorus(float radius1, float radius2, int sampling) @@ -1692,7 +1692,7 @@ MeshObject* MeshObject::createTorus(float radius1, float radius2, int sampling) try { Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true); if (module.isNull()) - return 0; + return nullptr; Py::Dict dict = module.getDict(); Py::Callable call(dict.getItem("Toroid")); Py::Tuple args(3); @@ -1706,7 +1706,7 @@ MeshObject* MeshObject::createTorus(float radius1, float radius2, int sampling) e.clear(); } - return 0; + return nullptr; } MeshObject* MeshObject::createCube(float length, float width, float height) @@ -1716,7 +1716,7 @@ MeshObject* MeshObject::createCube(float length, float width, float height) try { Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true); if (module.isNull()) - return 0; + return nullptr; Py::Dict dict = module.getDict(); Py::Callable call(dict.getItem("Cube")); Py::Tuple args(3); @@ -1730,7 +1730,7 @@ MeshObject* MeshObject::createCube(float length, float width, float height) e.clear(); } - return 0; + return nullptr; } MeshObject* MeshObject::createCube(float length, float width, float height, float edgelen) @@ -1740,7 +1740,7 @@ MeshObject* MeshObject::createCube(float length, float width, float height, floa try { Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true); if (module.isNull()) - return 0; + return nullptr; Py::Dict dict = module.getDict(); Py::Callable call(dict.getItem("FineCube")); Py::Tuple args(4); @@ -1755,7 +1755,7 @@ MeshObject* MeshObject::createCube(float length, float width, float height, floa e.clear(); } - return 0; + return nullptr; } void MeshObject::addSegment(const Segment& s) @@ -1767,10 +1767,10 @@ void MeshObject::addSegment(const Segment& s) this->_segments.back()._modifykernel = s._modifykernel; } -void MeshObject::addSegment(const std::vector& inds) +void MeshObject::addSegment(const std::vector& inds) { unsigned long maxIndex = _kernel.CountFacets(); - for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { + for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { if (*it >= maxIndex) throw Base::IndexError("Index out of range"); } @@ -1788,13 +1788,13 @@ Segment& MeshObject::getSegment(unsigned long index) return this->_segments[index]; } -MeshObject* MeshObject::meshFromSegment(const std::vector& indices) const +MeshObject* MeshObject::meshFromSegment(const std::vector& indices) const { MeshCore::MeshFacetArray facets; facets.reserve(indices.size()); const MeshCore::MeshPointArray& kernel_p = _kernel.GetPoints(); const MeshCore::MeshFacetArray& kernel_f = _kernel.GetFacets(); - for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) { + for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) { facets.push_back(kernel_f[*it]); } @@ -1847,7 +1847,7 @@ std::vector MeshObject::getSegmentsOfType(MeshObject::GeometryType type // ---------------------------------------------------------------------------- -MeshObject::const_point_iterator::const_point_iterator(const MeshObject* mesh, unsigned long index) +MeshObject::const_point_iterator::const_point_iterator(const MeshObject* mesh, PointIndex index) : _mesh(mesh), _p_it(mesh->getKernel()) { this->_p_it.Set(index); @@ -1916,7 +1916,7 @@ MeshObject::const_point_iterator& MeshObject::const_point_iterator::operator--() // ---------------------------------------------------------------------------- -MeshObject::const_facet_iterator::const_facet_iterator(const MeshObject* mesh, unsigned long index) +MeshObject::const_facet_iterator::const_facet_iterator(const MeshObject* mesh, FacetIndex index) : _mesh(mesh), _f_it(mesh->getKernel()) { this->_f_it.Set(index); diff --git a/src/Mod/Mesh/App/Mesh.h b/src/Mod/Mesh/App/Mesh.h index 1086ee01a5..c8b73515d5 100644 --- a/src/Mod/Mesh/App/Mesh.h +++ b/src/Mod/Mesh/App/Mesh.h @@ -92,7 +92,7 @@ public: * List of different subelement types * its NOT a list of the subelements itself */ - virtual std::vector getElementTypes(void) const; + virtual std::vector getElementTypes() const; virtual unsigned long countSubElements(const char* Type) const; /// get the subelement by type and number virtual Data::Segment* getSubElement(const char* Type, unsigned long) const; @@ -105,7 +105,7 @@ public: //@} void setTransform(const Base::Matrix4D& rclTrf); - Base::Matrix4D getTransform(void) const; + Base::Matrix4D getTransform() const; void transformGeometry(const Base::Matrix4D &rclMat); /** @@ -123,8 +123,8 @@ public: unsigned long countEdges () const; unsigned long countSegments() const; bool isSolid() const; - MeshPoint getPoint(unsigned long) const; - Mesh::Facet getFacet(unsigned long) const; + MeshPoint getPoint(PointIndex) const; + Mesh::Facet getFacet(FacetIndex) const; double getSurface() const; double getVolume() const; /** Get points from object with given accuracy */ @@ -133,33 +133,33 @@ public: float Accuracy, uint16_t flags=0) const; virtual void getFaces(std::vector &Points,std::vector &Topo, float Accuracy, uint16_t flags=0) const; - std::vector getPointsFromFacets(const std::vector& facets) const; + std::vector getPointsFromFacets(const std::vector& facets) const; //@} void setKernel(const MeshCore::MeshKernel& m); - MeshCore::MeshKernel& getKernel(void) + MeshCore::MeshKernel& getKernel() { return _kernel; } - const MeshCore::MeshKernel& getKernel(void) const + const MeshCore::MeshKernel& getKernel() const { return _kernel; } - virtual Base::BoundBox3d getBoundBox(void)const; + virtual Base::BoundBox3d getBoundBox()const; /** @name I/O */ //@{ // Implemented from Persistence - unsigned int getMemSize (void) const; + unsigned int getMemSize () const; void Save (Base::Writer &writer) const; void SaveDocFile (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); void RestoreDocFile(Base::Reader &reader); void save(const char* file,MeshCore::MeshIO::Format f=MeshCore::MeshIO::Undefined, - const MeshCore::Material* mat = 0, - const char* objectname = 0) const; + const MeshCore::Material* mat = nullptr, + const char* objectname = nullptr) const; void save(std::ostream&,MeshCore::MeshIO::Format f, - const MeshCore::Material* mat = 0, - const char* objectname = 0) const; - bool load(const char* file, MeshCore::Material* mat = 0); - bool load(std::istream&, MeshCore::MeshIO::Format f, MeshCore::Material* mat = 0); + const MeshCore::Material* mat = nullptr, + const char* objectname = nullptr) const; + bool load(const char* file, MeshCore::Material* mat = nullptr); + bool load(std::istream&, MeshCore::MeshIO::Format f, MeshCore::Material* mat = nullptr); // Save and load in internal format void save(std::ostream&) const; void load(std::istream&); @@ -192,9 +192,9 @@ public: * this mesh object. */ void addMesh(const MeshCore::MeshKernel&); - void deleteFacets(const std::vector& removeIndices); - void deletePoints(const std::vector& removeIndices); - std::vector > getComponents() const; + void deleteFacets(const std::vector& removeIndices); + void deletePoints(const std::vector& removeIndices); + std::vector > getComponents() const; unsigned long countComponents() const; void removeComponents(unsigned long); /** @@ -203,22 +203,22 @@ public: * The point degree information is stored in \a point_degree. The return value * gives the number of points which will have a degree of zero. */ - unsigned long getPointDegree(const std::vector& facets, - std::vector& point_degree) const; + unsigned long getPointDegree(const std::vector& facets, + std::vector& point_degree) const; void fillupHoles(unsigned long, int, MeshCore::AbstractPolygonTriangulator&); void offset(float fSize); void offsetSpecial2(float fSize); void offsetSpecial(float fSize, float zmax, float zmin); /// clears the Mesh - void clear(void); + void clear(); void transformToEigenSystem(); Base::Matrix4D getEigenSystem(Base::Vector3d& v) const; - void movePoint(unsigned long, const Base::Vector3d& v); - void setPoint(unsigned long, const Base::Vector3d& v); + void movePoint(PointIndex, const Base::Vector3d& v); + void setPoint(PointIndex, const Base::Vector3d& v); void smooth(int iterations, float d_max); void decimate(float fTolerance, float fReduction); void decimate(int targetSize); - Base::Vector3d getPointNormal(unsigned long) const; + Base::Vector3d getPointNormal(PointIndex) const; std::vector getPointNormals() const; void crossSections(const std::vector&, std::vector §ions, float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const; @@ -231,16 +231,16 @@ public: //@{ void deleteSelectedFacets(); void deleteSelectedPoints(); - void addFacetsToSelection(const std::vector&) const; - void addPointsToSelection(const std::vector&) const; - void removeFacetsFromSelection(const std::vector&) const; - void removePointsFromSelection(const std::vector&) const; + void addFacetsToSelection(const std::vector&) const; + void addPointsToSelection(const std::vector&) const; + void removeFacetsFromSelection(const std::vector&) const; + void removePointsFromSelection(const std::vector&) const; unsigned long countSelectedFacets() const; bool hasSelectedFacets() const; unsigned long countSelectedPoints() const; bool hasSelectedPoints() const; - void getFacetsFromSelection(std::vector&) const; - void getPointsFromSelection(std::vector&) const; + void getFacetsFromSelection(std::vector&) const; + void getPointsFromSelection(std::vector&) const; void clearFacetSelection() const; void clearPointSelection() const; //@} @@ -261,14 +261,14 @@ public: void optimizeTopology(float); void optimizeEdges(); void splitEdges(); - void splitEdge(unsigned long, unsigned long, const Base::Vector3f&); - void splitFacet(unsigned long, const Base::Vector3f&, const Base::Vector3f&); - void swapEdge(unsigned long, unsigned long); - void collapseEdge(unsigned long, unsigned long); - void collapseFacet(unsigned long); - void collapseFacets(const std::vector&); - void insertVertex(unsigned long, const Base::Vector3f& v); - void snapVertex(unsigned long, const Base::Vector3f& v); + void splitEdge(FacetIndex, FacetIndex, const Base::Vector3f&); + void splitFacet(FacetIndex, const Base::Vector3f&, const Base::Vector3f&); + void swapEdge(FacetIndex, FacetIndex); + void collapseEdge(FacetIndex, FacetIndex); + void collapseFacet(FacetIndex); + void collapseFacets(const std::vector&); + void insertVertex(FacetIndex, const Base::Vector3f& v); + void snapVertex(FacetIndex, const Base::Vector3f& v); //@} /** @name Mesh validation */ @@ -291,7 +291,7 @@ public: void removeNonManifoldPoints(); bool hasSelfIntersections() const; void removeSelfIntersections(); - void removeSelfIntersections(const std::vector&); + void removeSelfIntersections(const std::vector&); void removeFoldsOnSurface(); void removeFullBoundaryFacets(); bool hasInvalidPoints() const; @@ -302,10 +302,10 @@ public: /** @name Mesh segments */ //@{ void addSegment(const Segment&); - void addSegment(const std::vector&); + void addSegment(const std::vector&); const Segment& getSegment(unsigned long) const; Segment& getSegment(unsigned long); - MeshObject* meshFromSegment(const std::vector&) const; + MeshObject* meshFromSegment(const std::vector&) const; std::vector getSegmentsOfType(GeometryType, float dev, unsigned long minFacets) const; //@} @@ -325,7 +325,7 @@ public: class MeshExport const_point_iterator { public: - const_point_iterator(const MeshObject*, unsigned long index); + const_point_iterator(const MeshObject*, PointIndex index); const_point_iterator(const const_point_iterator& pi); ~const_point_iterator(); @@ -346,7 +346,7 @@ public: class MeshExport const_facet_iterator { public: - const_facet_iterator(const MeshObject*, unsigned long index); + const_facet_iterator(const MeshObject*, FacetIndex index); const_facet_iterator(const const_facet_iterator& fi); ~const_facet_iterator(); @@ -387,8 +387,8 @@ public: friend class Segment; private: - void deletedFacets(const std::vector& remFacets); - void updateMesh(const std::vector&); + void deletedFacets(const std::vector& remFacets); + void updateMesh(const std::vector&); void updateMesh(); void swapKernel(MeshCore::MeshKernel& m, const std::vector& g); void copySegments(const MeshObject&); diff --git a/src/Mod/Mesh/App/MeshProperties.cpp b/src/Mod/Mesh/App/MeshProperties.cpp index 41139f3b03..224a37a1f9 100644 --- a/src/Mod/Mesh/App/MeshProperties.cpp +++ b/src/Mod/Mesh/App/MeshProperties.cpp @@ -529,11 +529,11 @@ void PropertyMeshKernel::transformGeometry(const Base::Matrix4D &rclMat) hasSetValue(); } -void PropertyMeshKernel::setPointIndices(const std::vector >& inds) +void PropertyMeshKernel::setPointIndices(const std::vector >& inds) { aboutToSetValue(); MeshCore::MeshKernel& kernel = _meshObject->getKernel(); - for (std::vector >::const_iterator it = inds.begin(); it != inds.end(); ++it) + for (std::vector >::const_iterator it = inds.begin(); it != inds.end(); ++it) kernel.SetPoint(it->first, it->second); hasSetValue(); } diff --git a/src/Mod/Mesh/App/MeshProperties.h b/src/Mod/Mesh/App/MeshProperties.h index 65607ca221..1b5fc3a473 100644 --- a/src/Mod/Mesh/App/MeshProperties.h +++ b/src/Mod/Mesh/App/MeshProperties.h @@ -215,7 +215,7 @@ public: void finishEditing(); /// Transform the real mesh data void transformGeometry(const Base::Matrix4D &rclMat); - void setPointIndices( const std::vector >& ); + void setPointIndices( const std::vector >& ); //@} /** @name Python interface */ diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index d4ca9b4d52..2df58c6e58 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -756,10 +756,10 @@ PyObject* MeshPy::getInternalFacets(PyObject *args) MeshCore::MeshEvalInternalFacets eval(kernel); eval.Evaluate(); - const std::vector& indices = eval.GetIndices(); + const std::vector& indices = eval.GetIndices(); Py::List ary(indices.size()); Py::List::size_type pos=0; - for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) { + for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) { ary[pos++] = Py::Long(*it); } @@ -841,8 +841,8 @@ PyObject* MeshPy::getSegment(PyObject *args) } Py::List ary; - const std::vector& segm = getMeshObjectPtr()->getSegment(index).getIndices(); - for (std::vector::const_iterator it = segm.begin(); it != segm.end(); ++it) { + const std::vector& segm = getMeshObjectPtr()->getSegment(index).getIndices(); + for (std::vector::const_iterator it = segm.begin(); it != segm.end(); ++it) { ary.append(Py::Long((int)*it)); } @@ -855,7 +855,7 @@ PyObject* MeshPy::getSeparateComponents(PyObject *args) return NULL; Py::List meshesList; - std::vector > segs; + std::vector > segs; segs = getMeshObjectPtr()->getComponents(); for (unsigned int i=0; imeshFromSegment(segs[i]); @@ -870,9 +870,9 @@ PyObject* MeshPy::getFacetSelection(PyObject *args) return 0; Py::List ary; - std::vector facets; + std::vector facets; getMeshObjectPtr()->getFacetsFromSelection(facets); - for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { + for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { ary.append(Py::Long((int)*it)); } @@ -885,9 +885,9 @@ PyObject* MeshPy::getPointSelection(PyObject *args) return 0; Py::List ary; - std::vector points; + std::vector points; getMeshObjectPtr()->getPointsFromSelection(points); - for (std::vector::const_iterator it = points.begin(); it != points.end(); ++it) { + for (std::vector::const_iterator it = points.begin(); it != points.end(); ++it) { ary.append(Py::Long((int)*it)); } @@ -900,7 +900,7 @@ PyObject* MeshPy::meshFromSegment(PyObject *args) if (!PyArg_ParseTuple(args, "O", &list)) return 0; - std::vector segment; + std::vector segment; Py::Sequence ary(list); for (Py::Sequence::iterator it = ary.begin(); it != ary.end(); ++it) { Py::Long f(*it); @@ -997,7 +997,7 @@ PyObject* MeshPy::getSelfIntersections(PyObject *args) if (!PyArg_ParseTuple(args, "")) return NULL; - std::vector > selfIndices; + std::vector > selfIndices; std::vector > selfPoints; MeshCore::MeshEvalSelfIntersection eval(getMeshObjectPtr()->getKernel()); eval.GetIntersections(selfIndices); @@ -1104,7 +1104,7 @@ PyObject* MeshPy::getNonUniformOrientedFacets(PyObject *args) const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel(); MeshCore::MeshEvalOrientation cMeshEval(kernel); - std::vector inds = cMeshEval.GetIndices(); + std::vector inds = cMeshEval.GetIndices(); Py::Tuple tuple(inds.size()); for (std::size_t i=0; i facets; + std::vector facets; for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { Py::Long idx(*it); unsigned long iIdx = static_cast(idx); @@ -1756,7 +1756,7 @@ PyObject* MeshPy::nearestFacetOnRay(PyObject *args) (float)Py::Float(dir_t.getItem(1)), (float)Py::Float(dir_t.getItem(2))); - unsigned long index = 0; + FacetIndex index = 0; Base::Vector3f res; MeshCore::MeshAlgorithm alg(getMeshObjectPtr()->getKernel()); @@ -1814,9 +1814,9 @@ PyObject* MeshPy::getPlanarSegments(PyObject *args) Py::List s; for (std::vector::iterator it = segments.begin(); it != segments.end(); ++it) { - const std::vector& segm = it->getIndices(); + const std::vector& segm = it->getIndices(); Py::List ary; - for (std::vector::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) { + for (std::vector::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) { ary.append(Py::Long((int)*jt)); } s.append(ary); @@ -1854,9 +1854,9 @@ PyObject* MeshPy::getSegmentsOfType(PyObject *args) Py::List s; for (std::vector::iterator it = segments.begin(); it != segments.end(); ++it) { - const std::vector& segm = it->getIndices(); + const std::vector& segm = it->getIndices(); Py::List ary; - for (std::vector::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) { + for (std::vector::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) { ary.append(Py::Long((int)*jt)); } s.append(ary); diff --git a/src/Mod/Mesh/App/MeshTexture.cpp b/src/Mod/Mesh/App/MeshTexture.cpp index 72b3a3fd2c..a8a1f98e43 100644 --- a/src/Mod/Mesh/App/MeshTexture.cpp +++ b/src/Mod/Mesh/App/MeshTexture.cpp @@ -85,7 +85,7 @@ void MeshTexture::apply(const Mesh::MeshObject& mesh, bool addDefaultColor, cons if (binding == MeshCore::MeshIO::PER_VERTEX) { diffuseColor.reserve(points.size()); for (size_t index=0; index pointMap; + std::vector pointMap; pointMap.reserve(points.size()); for (size_t index=0; index found = refPnt2Fac->GetIndices(index1, index2, index3); + for (const auto& it : facets) { + PointIndex index1 = pointMap[it._aulPoints[0]]; + PointIndex index2 = pointMap[it._aulPoints[1]]; + PointIndex index3 = pointMap[it._aulPoints[2]]; + if (index1 != MeshCore::POINT_INDEX_MAX && + index2 != MeshCore::POINT_INDEX_MAX && + index3 != MeshCore::POINT_INDEX_MAX) { + std::vector found = refPnt2Fac->GetIndices(index1, index2, index3); if (found.size() == 1) { diffuseColor.push_back(textureColor[found.front()]); } diff --git a/src/Mod/Mesh/App/MeshTexture.h b/src/Mod/Mesh/App/MeshTexture.h index 8f6b279a18..4222baf4ed 100644 --- a/src/Mod/Mesh/App/MeshTexture.h +++ b/src/Mod/Mesh/App/MeshTexture.h @@ -74,7 +74,7 @@ public: private: void apply(const Mesh::MeshObject& mesh, bool addDefaultColor, const App::Color& defaultColor, float max_dist, MeshCore::Material &material); - unsigned long findIndex(const Base::Vector3f& p, float max_dist) const { + PointIndex findIndex(const Base::Vector3f& p, float max_dist) const { if (max_dist < 0.0f) { return kdTree->FindExact(p); } diff --git a/src/Mod/Mesh/App/Segment.cpp b/src/Mod/Mesh/App/Segment.cpp index 726100f80c..cf7eb5c414 100644 --- a/src/Mod/Mesh/App/Segment.cpp +++ b/src/Mod/Mesh/App/Segment.cpp @@ -43,7 +43,7 @@ Segment::Segment(MeshObject* mesh, bool mod) { } -Segment::Segment(MeshObject* mesh, const std::vector& inds, bool mod) +Segment::Segment(MeshObject* mesh, const std::vector& inds, bool mod) : _mesh(mesh) , _indices(inds) , _save(false) @@ -53,7 +53,7 @@ Segment::Segment(MeshObject* mesh, const std::vector& inds, bool _mesh->updateMesh(inds); } -void Segment::addIndices(const std::vector& inds) +void Segment::addIndices(const std::vector& inds) { _indices.insert(_indices.end(), inds.begin(), inds.end()); std::sort(_indices.begin(), _indices.end()); @@ -62,21 +62,21 @@ void Segment::addIndices(const std::vector& inds) _mesh->updateMesh(inds); } -void Segment::removeIndices(const std::vector& inds) +void Segment::removeIndices(const std::vector& inds) { // make difference - std::vector result; - std::set s1(_indices.begin(), _indices.end()); - std::set s2(inds.begin(), inds.end()); + std::vector result; + std::set s1(_indices.begin(), _indices.end()); + std::set s2(inds.begin(), inds.end()); std::set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(), - std::back_insert_iterator >(result)); + std::back_insert_iterator >(result)); _indices = result; if (_modifykernel) _mesh->updateMesh(); } -const std::vector& Segment::getIndices() const +const std::vector& Segment::getIndices() const { return _indices; } @@ -109,7 +109,7 @@ bool Segment::operator == (const Segment& s) const // ---------------------------------------------------------------------------- -Segment::const_facet_iterator::const_facet_iterator(const Segment* segm, std::vector::const_iterator it) +Segment::const_facet_iterator::const_facet_iterator(const Segment* segm, std::vector::const_iterator it) : _segment(segm), _f_it(segm->_mesh->getKernel()), _it(it) { this->_f_it.Set(0); diff --git a/src/Mod/Mesh/App/Segment.h b/src/Mod/Mesh/App/Segment.h index c0233ce982..aea805c1b9 100644 --- a/src/Mod/Mesh/App/Segment.h +++ b/src/Mod/Mesh/App/Segment.h @@ -27,6 +27,7 @@ #include #include #include "Facet.h" +#include "Types.h" #include "Core/Iterator.h" namespace Mesh @@ -38,10 +39,10 @@ class MeshExport Segment { public: Segment(MeshObject*, bool mod); - Segment(MeshObject*, const std::vector& inds, bool mod); - void addIndices(const std::vector& inds); - void removeIndices(const std::vector& inds); - const std::vector& getIndices() const; + Segment(MeshObject*, const std::vector& inds, bool mod); + void addIndices(const std::vector& inds); + void removeIndices(const std::vector& inds); + const std::vector& getIndices() const; bool isEmpty() const { return _indices.empty(); } Segment(const Segment&); @@ -62,7 +63,7 @@ public: private: MeshObject* _mesh; - std::vector _indices; + std::vector _indices; std::string _name; std::string _color; bool _save; @@ -72,7 +73,7 @@ public: class MeshExport const_facet_iterator { public: - const_facet_iterator(const Segment*, std::vector::const_iterator); + const_facet_iterator(const Segment*, std::vector::const_iterator); const_facet_iterator(const const_facet_iterator& fi); ~const_facet_iterator(); @@ -88,7 +89,7 @@ public: const Segment* _segment; Facet _facet; MeshCore::MeshFacetIterator _f_it; - std::vector::const_iterator _it; + std::vector::const_iterator _it; }; const_facet_iterator facets_begin() const diff --git a/src/Mod/Mesh/App/Types.h b/src/Mod/Mesh/App/Types.h new file mode 100644 index 0000000000..061323ffb7 --- /dev/null +++ b/src/Mod/Mesh/App/Types.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (c) 2021 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef MESH_TYPES_H +#define MESH_TYPES_H + +#include "Core/Definitions.h" + + +namespace Mesh +{ + +// type definitions +using ElementIndex = MeshCore::ElementIndex; +using FacetIndex = MeshCore::FacetIndex; +using PointIndex = MeshCore::PointIndex; + +} // namespace Mesh + +#endif // MESH_TYPES_H diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index b02940792e..0110e54240 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -1845,7 +1845,7 @@ void CmdMeshSplitComponents::activated(int) std::vector objs = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId()); for (std::vector::const_iterator it = objs.begin(); it != objs.end(); ++it) { const MeshObject& mesh = static_cast(*it)->Mesh.getValue(); - std::vector > comps = mesh.getComponents(); + std::vector > comps = mesh.getComponents(); for (const auto& comp : comps) { std::unique_ptr kernel(mesh.meshFromSegment(comp)); diff --git a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp index cf4ef6631b..a14fc796e6 100644 --- a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp +++ b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp @@ -97,7 +97,7 @@ public: std::map vp; Mesh::Feature* meshFeature; QPointer view; - std::vector self_intersections; + std::vector self_intersections; bool enableFoldsCheck; bool checkNonManfoldPoints; bool strictlyDegenerated; @@ -276,7 +276,7 @@ void DlgEvaluateMeshImp::setMesh(Mesh::Feature* m) } } -void DlgEvaluateMeshImp::addViewProvider(const char* name, const std::vector& indices) +void DlgEvaluateMeshImp::addViewProvider(const char* name, const std::vector& indices) { removeViewProvider(name); @@ -440,7 +440,7 @@ void DlgEvaluateMeshImp::on_analyzeOrientationButton_clicked() const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel(); MeshEvalOrientation eval(rMesh); - std::vector inds = eval.GetIndices(); + std::vector inds = eval.GetIndices(); #if 0 if (inds.empty() && !eval.Evaluate()) { d->ui.checkOrientationButton->setText(tr("Flipped normals found")); @@ -532,7 +532,7 @@ void DlgEvaluateMeshImp::on_analyzeNonmanifoldsButton_clicked() MeshEvalTopology f_eval(rMesh); bool ok1 = f_eval.Evaluate(); bool ok2 = true; - std::vector point_indices; + std::vector point_indices; if (d->checkNonManfoldPoints) { MeshEvalPointManifolds p_eval(rMesh); @@ -555,10 +555,10 @@ void DlgEvaluateMeshImp::on_analyzeNonmanifoldsButton_clicked() d->ui.repairAllTogether->setEnabled(true); if (!ok1) { - const std::vector >& inds = f_eval.GetIndices(); - std::vector indices; + const std::vector >& inds = f_eval.GetIndices(); + std::vector indices; indices.reserve(2*inds.size()); - std::vector >::const_iterator it; + std::vector >::const_iterator it; for (it = inds.begin(); it != inds.end(); ++it) { indices.push_back(it->first); indices.push_back(it->second); @@ -721,7 +721,7 @@ void DlgEvaluateMeshImp::on_analyzeDegeneratedButton_clicked() const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel(); MeshEvalDegeneratedFacets eval(rMesh, d->epsilonDegenerated); - std::vector degen = eval.GetIndices(); + std::vector degen = eval.GetIndices(); if (degen.empty()) { d->ui.checkDegenerationButton->setText(tr("No degenerations")); @@ -787,7 +787,7 @@ void DlgEvaluateMeshImp::on_analyzeDuplicatedFacesButton_clicked() const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel(); MeshEvalDuplicateFacets eval(rMesh); - std::vector dupl = eval.GetIndices(); + std::vector dupl = eval.GetIndices(); if (dupl.empty()) { d->ui.checkDuplicatedFacesButton->setText(tr("No duplicated faces")); @@ -919,7 +919,7 @@ void DlgEvaluateMeshImp::on_analyzeSelfIntersectionButton_clicked() const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel(); MeshEvalSelfIntersection eval(rMesh); - std::vector > intersection; + std::vector > intersection; try { eval.GetIntersections(intersection); } @@ -939,9 +939,9 @@ void DlgEvaluateMeshImp::on_analyzeSelfIntersectionButton_clicked() d->ui.repairSelfIntersectionButton->setEnabled(true); d->ui.repairAllTogether->setEnabled(true); - std::vector indices; + std::vector indices; indices.reserve(2*intersection.size()); - std::vector >::iterator it; + std::vector >::iterator it; for (it = intersection.begin(); it != intersection.end(); ++it) { indices.push_back(it->first); indices.push_back(it->second); @@ -1022,9 +1022,9 @@ void DlgEvaluateMeshImp::on_analyzeFoldsButton_clicked() removeViewProvider("MeshGui::ViewProviderMeshFolds"); } else { - std::vector inds = f_eval.GetIndices(); - std::vector inds1 = s_eval.GetIndices(); - std::vector inds2 = b_eval.GetIndices(); + std::vector inds = f_eval.GetIndices(); + std::vector inds1 = s_eval.GetIndices(); + std::vector inds2 = b_eval.GetIndices(); inds.insert(inds.end(), inds1.begin(), inds1.end()); inds.insert(inds.end(), inds2.begin(), inds2.end()); diff --git a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h index e5cf94472f..e663e795ae 100644 --- a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h +++ b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h @@ -31,6 +31,7 @@ #include #include #include +#include class QAbstractButton; @@ -127,7 +128,7 @@ protected: void refreshList(); void showInformation(); void cleanInformation(); - void addViewProvider(const char* vp, const std::vector& indices); + void addViewProvider(const char* vp, const std::vector& indices); void removeViewProvider(const char* vp); void removeViewProviders(); void changeEvent(QEvent *e); diff --git a/src/Mod/Mesh/Gui/DlgSmoothing.cpp b/src/Mod/Mesh/Gui/DlgSmoothing.cpp index 726afb2d62..2241f93a39 100644 --- a/src/Mod/Mesh/Gui/DlgSmoothing.cpp +++ b/src/Mod/Mesh/Gui/DlgSmoothing.cpp @@ -121,7 +121,7 @@ SmoothingDialog::SmoothingDialog(QWidget* parent, Qt::WindowFlags fl) QVBoxLayout* hboxLayout = new QVBoxLayout(this); QDialogButtonBox* buttonBox = new QDialogButtonBox(this); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); - + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), @@ -138,7 +138,7 @@ SmoothingDialog::~SmoothingDialog() // --------------------------------------- /* TRANSLATOR MeshGui::TaskSmoothing */ - + TaskSmoothing::TaskSmoothing() { widget = new DlgSmoothing(); @@ -180,7 +180,7 @@ bool TaskSmoothing::accept() bool hasSelection = false; for (std::vector::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { Mesh::Feature* mesh = static_cast(*it); - std::vector selection; + std::vector selection; if (widget->smoothSelection()) { // clear the selection before editing the mesh to avoid // to have coloured triangles when doing an 'undo' diff --git a/src/Mod/Mesh/Gui/MeshEditor.cpp b/src/Mod/Mesh/Gui/MeshEditor.cpp index 1343450329..673b188464 100644 --- a/src/Mod/Mesh/Gui/MeshEditor.cpp +++ b/src/Mod/Mesh/Gui/MeshEditor.cpp @@ -65,7 +65,7 @@ namespace bp = boost::placeholders; PROPERTY_SOURCE(MeshGui::ViewProviderFace, Gui::ViewProviderDocumentObject) -ViewProviderFace::ViewProviderFace() : mesh(0), current_index(-1) +ViewProviderFace::ViewProviderFace() : mesh(nullptr), current_index(-1) { pcCoords = new SoCoordinate3(); pcCoords->ref(); @@ -150,7 +150,7 @@ const char* ViewProviderFace::getDefaultDisplayMode() const return "Marker"; } -std::vector ViewProviderFace::getDisplayModes(void) const +std::vector ViewProviderFace::getDisplayModes() const { std::vector modes; modes.push_back("Marker"); @@ -174,7 +174,7 @@ SoPickedPoint* ViewProviderFace::getPickedPoint(const SbVec2s& pos, const Gui::V // returns a copy of the point SoPickedPoint* pick = rp.getPickedPoint(); //return (pick ? pick->copy() : 0); // needs the same instance of CRT under MS Windows - return (pick ? new SoPickedPoint(*pick) : 0); + return (pick ? new SoPickedPoint(*pick) : nullptr); } // ---------------------------------------------------------------------- @@ -314,8 +314,8 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp) int index = (int)f._aulPoints[i]; if (std::find(faceView->index.begin(), faceView->index.end(), index) != faceView->index.end()) continue; // already inside - if (f._aulNeighbours[i] == ULONG_MAX || - f._aulNeighbours[(i+2)%3] == ULONG_MAX) { + if (f._aulNeighbours[i] == MeshCore::FACET_INDEX_MAX || + f._aulNeighbours[(i+2)%3] == MeshCore::FACET_INDEX_MAX) { pnt = points[index]; float len = Base::DistanceP2(pnt, Base::Vector3f(vec[0],vec[1],vec[2])); if (len < distance) { @@ -418,8 +418,8 @@ namespace MeshGui { // for sorting of elements struct NofFacetsCompare { - bool operator () (const std::vector &rclC1, - const std::vector &rclC2) + bool operator () (const std::vector &rclC1, + const std::vector &rclC2) { return rclC1.size() < rclC2.size(); } @@ -430,7 +430,7 @@ namespace MeshGui { MeshFillHole::MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent) : QObject(parent) - , myMesh(0) + , myMesh(nullptr) , myNumPoints(0) , myVertex1(0) , myVertex2(0) @@ -566,7 +566,7 @@ void MeshFillHole::createPolygons() const MeshCore::MeshKernel & rMesh = this->myMesh->Mesh.getValue().getKernel(); // get the mesh boundaries as an array of point indices - std::list > borders; + std::list > borders; MeshCore::MeshAlgorithm cAlgo(rMesh); MeshCore::MeshPointIterator p_iter(rMesh); cAlgo.GetMeshBorders(borders); @@ -576,7 +576,7 @@ void MeshFillHole::createPolygons() borders.sort(NofFacetsCompare()); int32_t count=0; - for (std::list >::iterator it = + for (std::list >::iterator it = borders.begin(); it != borders.end(); ++it) { if (it->front() == it->back()) it->pop_back(); @@ -589,14 +589,14 @@ void MeshFillHole::createPolygons() coords->point.setNum(count); int32_t index = 0; - for (std::list >::iterator it = + for (std::list >::iterator it = borders.begin(); it != borders.end(); ++it) { SoPolygon* polygon = new SoPolygon(); polygon->startIndex = index; polygon->numVertices = it->size(); myBoundariesGroup->addChild(polygon); myPolygons[polygon] = *it; - for (std::vector::iterator jt = it->begin(); + for (std::vector::iterator jt = it->begin(); jt != it->end(); ++jt) { p_iter.Set(*jt); coords->point.set1Value(index++,p_iter->x,p_iter->y,p_iter->z); @@ -606,7 +606,7 @@ void MeshFillHole::createPolygons() SoNode* MeshFillHole::getPickedPolygon(const SoRayPickAction& action/*SoNode* root, const SbVec2s& pos*/) const { - SoPolygon* poly = 0; + SoPolygon* poly = nullptr; const SoPickedPointList & points = action.getPickedPointList(); for (int i=0; i < points.getLength(); i++) { const SoPickedPoint * point = points[i]; @@ -627,11 +627,11 @@ SoNode* MeshFillHole::getPickedPolygon(const SoRayPickAction& action/*SoNode* ro } float MeshFillHole::findClosestPoint(const SbLine& ray, const TBoundary& polygon, - unsigned long& vertex_index, SbVec3f& closestPoint) const + Mesh::PointIndex& vertex_index, SbVec3f& closestPoint) const { // now check which vertex of the polygon is closest to the ray float minDist = FLT_MAX; - vertex_index = ULONG_MAX; + vertex_index = MeshCore::POINT_INDEX_MAX; const MeshCore::MeshKernel & rMesh = myMesh->Mesh.getValue().getKernel(); const MeshCore::MeshPointArray& pts = rMesh.GetPoints(); @@ -671,7 +671,7 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n) std::map::iterator it = self->myPolygons.find(node); if (it != self->myPolygons.end()) { // now check which vertex of the polygon is closest to the ray - unsigned long vertex_index; + Mesh::PointIndex vertex_index; SbVec3f closestPoint; float minDist = self->findClosestPoint(rp.getLine(), it->second, vertex_index, closestPoint); if (minDist < 1.0f) { @@ -701,7 +701,7 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n) std::map::iterator it = self->myPolygons.find(node); if (it != self->myPolygons.end()) { // now check which vertex of the polygon is closest to the ray - unsigned long vertex_index; + Mesh::PointIndex vertex_index; SbVec3f closestPoint; float minDist = self->findClosestPoint(rp.getLine(), it->second, vertex_index, closestPoint); if (minDist < 1.0f) { diff --git a/src/Mod/Mesh/Gui/MeshEditor.h b/src/Mod/Mesh/Gui/MeshEditor.h index 6675d73620..225c40ab9a 100644 --- a/src/Mod/Mesh/Gui/MeshEditor.h +++ b/src/Mod/Mesh/Gui/MeshEditor.h @@ -58,7 +58,7 @@ public: void attach(App::DocumentObject* obj); void setDisplayMode(const char* ModeName); const char* getDefaultDisplayMode() const; - std::vector getDisplayModes(void) const; + std::vector getDisplayModes() const; SoPickedPoint* getPickedPoint(const SbVec2s& pos, const Gui::View3DInventorViewer* viewer) const; ViewProviderMesh* mesh; @@ -110,8 +110,8 @@ public: virtual ~MeshHoleFiller() { } - virtual bool fillHoles(Mesh::MeshObject&, const std::list >&, - unsigned long, unsigned long) + virtual bool fillHoles(Mesh::MeshObject&, const std::list >&, + Mesh::PointIndex, Mesh::PointIndex) { return false; } @@ -138,14 +138,14 @@ private Q_SLOTS: void closeBridge(); private: - typedef std::vector TBoundary; + typedef std::vector TBoundary; typedef boost::signals2::connection Connection; static void fileHoleCallback(void * ud, SoEventCallback * n); void createPolygons(); SoNode* getPickedPolygon(const SoRayPickAction& action) const; float findClosestPoint(const SbLine& ray, const TBoundary& polygon, - unsigned long&, SbVec3f&) const; + Mesh::PointIndex&, SbVec3f&) const; void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop); private: @@ -157,8 +157,8 @@ private: std::map myPolygons; Mesh::Feature* myMesh; int myNumPoints; - unsigned long myVertex1; - unsigned long myVertex2; + Mesh::PointIndex myVertex1; + Mesh::PointIndex myVertex2; TBoundary myPolygon; MeshHoleFiller& myHoleFiller; Connection myConnection; diff --git a/src/Mod/Mesh/Gui/MeshSelection.cpp b/src/Mod/Mesh/Gui/MeshSelection.cpp index 65fdde88f8..6f47b0dd86 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.cpp +++ b/src/Mod/Mesh/Gui/MeshSelection.cpp @@ -254,8 +254,8 @@ void MeshSelection::fullSelection() for (std::list::iterator it = views.begin(); it != views.end(); ++it) { Mesh::Feature* mf = static_cast((*it)->getObject()); const Mesh::MeshObject* mo = mf->Mesh.getValuePtr(); - std::vector faces(mo->countFacets()); - std::generate(faces.begin(), faces.end(), Base::iotaGen(0)); + std::vector faces(mo->countFacets()); + std::generate(faces.begin(), faces.end(), Base::iotaGen(0)); (*it)->addSelection(faces); } } @@ -301,12 +301,12 @@ bool MeshSelection::deleteSelectionBorder() Mesh::Feature* mf = static_cast((*it)->getObject()); // mark the selected facet as visited - std::vector selection, remove; - std::set borderPoints; + std::vector selection, remove; + std::set borderPoints; MeshCore::MeshAlgorithm meshAlg(mf->Mesh.getValue().getKernel()); meshAlg.GetFacetsFlag(selection, MeshCore::MeshFacet::SELECTED); meshAlg.GetBorderPoints(selection, borderPoints); - std::vector border; + std::vector border; border.insert(border.begin(), borderPoints.begin(), borderPoints.end()); meshAlg.ResetFacetFlag(MeshCore::MeshFacet::VISIT); @@ -359,13 +359,13 @@ void MeshSelection::selectComponent(int size) Mesh::Feature* mf = static_cast((*it)->getObject()); const Mesh::MeshObject* mo = mf->Mesh.getValuePtr(); - std::vector > segm; + std::vector > segm; MeshCore::MeshComponents comp(mo->getKernel()); comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segm); - std::vector faces; - for (std::vector >::iterator jt = segm.begin(); jt != segm.end(); ++jt) { - if (jt->size() < (unsigned long)size) + std::vector faces; + for (std::vector >::iterator jt = segm.begin(); jt != segm.end(); ++jt) { + if (jt->size() < (Mesh::FacetIndex)size) faces.insert(faces.end(), jt->begin(), jt->end()); } @@ -380,13 +380,13 @@ void MeshSelection::deselectComponent(int size) Mesh::Feature* mf = static_cast((*it)->getObject()); const Mesh::MeshObject* mo = mf->Mesh.getValuePtr(); - std::vector > segm; + std::vector > segm; MeshCore::MeshComponents comp(mo->getKernel()); comp.SearchForComponents(MeshCore::MeshComponents::OverEdge,segm); - std::vector faces; - for (std::vector >::iterator jt = segm.begin(); jt != segm.end(); ++jt) { - if (jt->size() > (unsigned long)size) + std::vector faces; + for (std::vector >::iterator jt = segm.begin(); jt != segm.end(); ++jt) { + if (jt->size() > (Mesh::FacetIndex)size) faces.insert(faces.end(), jt->begin(), jt->end()); } @@ -472,7 +472,7 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n) for (std::list::iterator it = views.begin(); it != views.end(); ++it) { ViewProviderMesh* vp = *it; - std::vector faces; + std::vector faces; const Mesh::MeshObject& mesh = static_cast((*it)->getObject())->Mesh.getValue(); const MeshCore::MeshKernel& kernel = mesh.getKernel(); @@ -494,23 +494,23 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n) const SbVec2s& p = *it; rect.extendBy(SbVec2s(p[0],height-p[1])); } - std::vector rf; rf.swap(faces); - std::vector vf = vp->getVisibleFacetsAfterZoom + std::vector rf; rf.swap(faces); + std::vector vf = vp->getVisibleFacetsAfterZoom (rect, view->getSoRenderManager()->getViewportRegion(), view->getSoRenderManager()->getCamera()); // get common facets of the viewport and the visible one std::sort(vf.begin(), vf.end()); std::sort(rf.begin(), rf.end()); - std::back_insert_iterator > biit(faces); + std::back_insert_iterator > biit(faces); std::set_intersection(vf.begin(), vf.end(), rf.begin(), rf.end(), biit); } // if set filter out all triangles which do not point into user direction if (self->onlyPointToUserTriangles) { - std::vector screen; + std::vector screen; screen.reserve(faces.size()); MeshCore::MeshFacetIterator it_f(kernel); - for (std::vector::iterator it = faces.begin(); it != faces.end(); ++it) { + for (std::vector::iterator it = faces.begin(); it != faces.end(); ++it) { it_f.Set(*it); if (it_f->GetNormal() * normal > 0.0f) { screen.push_back(*it); @@ -560,7 +560,7 @@ void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n) const SoDetail* detail = point->getDetail(/*mesh->getShapeNode()*/); if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) { // get the boundary to the picked facet - unsigned long uFacet = static_cast(detail)->getFaceIndex(); + Mesh::FacetIndex uFacet = static_cast(detail)->getFaceIndex(); if (self->addToSelection) { if (self->addComponent) mesh->selectComponent(uFacet); diff --git a/src/Mod/Mesh/Gui/SegmentationBestFit.cpp b/src/Mod/Mesh/Gui/SegmentationBestFit.cpp index 380c138476..efcddb8b65 100644 --- a/src/Mod/Mesh/Gui/SegmentationBestFit.cpp +++ b/src/Mod/Mesh/Gui/SegmentationBestFit.cpp @@ -262,7 +262,7 @@ void ParametersDialog::on_compute_clicked() const Mesh::MeshObject& kernel = myMesh->Mesh.getValue(); if (kernel.hasSelectedFacets()) { FitParameter::Points fitpts; - std::vector facets, points; + std::vector facets, points; kernel.getFacetsFromSelection(facets); points = kernel.getPointsFromFacets(facets); MeshCore::MeshPointArray coords = kernel.getKernel().GetPoints(points); diff --git a/src/Mod/Mesh/Gui/SoFCMeshObject.cpp b/src/Mod/Mesh/Gui/SoFCMeshObject.cpp index 03fdcc78b9..a7928a7cab 100644 --- a/src/Mod/Mesh/Gui/SoFCMeshObject.cpp +++ b/src/Mod/Mesh/Gui/SoFCMeshObject.cpp @@ -388,7 +388,7 @@ void SoFCMeshPickNode::pick(SoPickAction * action) const SbVec3f& dir = line.getDirection(); Base::Vector3f pt(pos[0],pos[1],pos[2]); Base::Vector3f dr(dir[0],dir[1],dir[2]); - unsigned long index; + Mesh::FacetIndex index; if (alg.NearestFacetOnRay(pt, dr, *meshGrid, pt, index)) { SoPickedPoint* pp = raypick->addIntersection(SbVec3f(pt.x,pt.y,pt.z)); if (pp) { @@ -1350,7 +1350,7 @@ void SoFCMeshSegmentShape::drawFaces(const Mesh::MeshObject * mesh, SoMaterialBu const MeshCore::MeshFacetArray & rFacets = mesh->getKernel().GetFacets(); if (mesh->countSegments() <= this->index.getValue()) return; - const std::vector rSegm = mesh->getSegment + const std::vector rSegm = mesh->getSegment (this->index.getValue()).getIndices(); bool perVertex = (mb && bind == PER_VERTEX_INDEXED); bool perFace = (mb && bind == PER_FACE_INDEXED); @@ -1360,7 +1360,7 @@ void SoFCMeshSegmentShape::drawFaces(const Mesh::MeshObject * mesh, SoMaterialBu glBegin(GL_TRIANGLES); if (ccw) { // counterclockwise ordering - for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it) + for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it) { const MeshCore::MeshFacet& f = rFacets[*it]; const MeshCore::MeshPoint& v0 = rPoints[f._aulPoints[0]]; @@ -1389,7 +1389,7 @@ void SoFCMeshSegmentShape::drawFaces(const Mesh::MeshObject * mesh, SoMaterialBu } else { // clockwise ordering - for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it) + for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it) { const MeshCore::MeshFacet& f = rFacets[*it]; const MeshCore::MeshPoint& v0 = rPoints[f._aulPoints[0]]; @@ -1412,7 +1412,7 @@ void SoFCMeshSegmentShape::drawFaces(const Mesh::MeshObject * mesh, SoMaterialBu } else { glBegin(GL_TRIANGLES); - for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it) + for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it) { const MeshCore::MeshFacet& f = rFacets[*it]; glVertex(rPoints[f._aulPoints[0]]); @@ -1432,7 +1432,7 @@ void SoFCMeshSegmentShape::drawPoints(const Mesh::MeshObject * mesh, SbBool need const MeshCore::MeshFacetArray & rFacets = mesh->getKernel().GetFacets(); if (mesh->countSegments() <= this->index.getValue()) return; - const std::vector rSegm = mesh->getSegment + const std::vector rSegm = mesh->getSegment (this->index.getValue()).getIndices(); int mod = rSegm.size()/renderTriangleLimit+1; @@ -1444,7 +1444,7 @@ void SoFCMeshSegmentShape::drawPoints(const Mesh::MeshObject * mesh, SbBool need glBegin(GL_POINTS); int ct=0; if (ccw) { - for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++) + for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++) { if (ct%mod==0) { const MeshCore::MeshFacet& f = rFacets[*it]; @@ -1469,7 +1469,7 @@ void SoFCMeshSegmentShape::drawPoints(const Mesh::MeshObject * mesh, SbBool need } } else { - for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++) + for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++) { if (ct%mod==0) { const MeshCore::MeshFacet& f = rFacets[*it]; @@ -1498,7 +1498,7 @@ void SoFCMeshSegmentShape::drawPoints(const Mesh::MeshObject * mesh, SbBool need else { glBegin(GL_POINTS); int ct=0; - for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++) + for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it, ct++) { if (ct%mod==0) { const MeshCore::MeshFacet& f = rFacets[*it]; @@ -1536,7 +1536,7 @@ void SoFCMeshSegmentShape::generatePrimitives(SoAction* action) return; if (mesh->countSegments() <= this->index.getValue()) return; - const std::vector rSegm = mesh->getSegment + const std::vector rSegm = mesh->getSegment (this->index.getValue()).getIndices(); // get material binding @@ -1552,7 +1552,7 @@ void SoFCMeshSegmentShape::generatePrimitives(SoAction* action) beginShape(action, TRIANGLES, &faceDetail); try { - for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it) + for (std::vector::const_iterator it = rSegm.begin(); it != rSegm.end(); ++it) { const MeshCore::MeshFacet& f = rFacets[*it]; const MeshCore::MeshPoint& v0 = rPoints[f._aulPoints[0]]; @@ -1618,13 +1618,13 @@ void SoFCMeshSegmentShape::computeBBox(SoAction *action, SbBox3f &box, SbVec3f & const Mesh::MeshObject * mesh = SoFCMeshObjectElement::get(state); if (mesh && mesh->countSegments() > this->index.getValue()) { const Mesh::Segment& segm = mesh->getSegment(this->index.getValue()); - const std::vector& indices = segm.getIndices(); + const std::vector& indices = segm.getIndices(); Base::BoundBox3f cBox; if (!indices.empty()) { const MeshCore::MeshPointArray& rPoint = mesh->getKernel().GetPoints(); const MeshCore::MeshFacetArray& rFaces = mesh->getKernel().GetFacets(); - for (std::vector::const_iterator it = indices.begin(); + for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) { const MeshCore::MeshFacet& face = rFaces[*it]; cBox.Add(rPoint[face._aulPoints[0]]); @@ -1709,7 +1709,7 @@ void SoFCMeshObjectBoundary::drawLines(const Mesh::MeshObject * mesh) const glBegin(GL_LINES); for (MeshCore::MeshFacetArray::_TConstIterator it = rFacets.begin(); it != rFacets.end(); ++it) { for (int i=0; i<3; i++) { - if (it->_aulNeighbours[i] == ULONG_MAX) { + if (it->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) { glVertex(rPoints[it->_aulPoints[i]]); glVertex(rPoints[it->_aulPoints[(i+1)%3]]); } @@ -1741,7 +1741,7 @@ void SoFCMeshObjectBoundary::generatePrimitives(SoAction* action) for (MeshCore::MeshFacetArray::_TConstIterator it = rFacets.begin(); it != rFacets.end(); ++it) { for (int i=0; i<3; i++) { - if (it->_aulNeighbours[i] == ULONG_MAX) { + if (it->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) { const MeshCore::MeshPoint& v0 = rPoints[it->_aulPoints[i]]; const MeshCore::MeshPoint& v1 = rPoints[it->_aulPoints[(i+1)%3]]; @@ -1805,7 +1805,7 @@ void SoFCMeshObjectBoundary::getPrimitiveCount(SoGetPrimitiveCountAction * actio int ctEdges=0; for (MeshCore::MeshFacetArray::_TConstIterator jt = rFaces.begin(); jt != rFaces.end(); ++jt) { for (int i=0; i<3; i++) { - if (jt->_aulNeighbours[i] == ULONG_MAX) { + if (jt->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) { ctEdges++; } } diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index bf66337d29..c3a23b0575 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -147,14 +147,14 @@ void ViewProviderMeshBuilder::createMesh(const App::Property* prop, SoCoordinate const MeshCore::MeshPointArray& cP = rcMesh.GetPoints(); coords->point.setNum(rcMesh.CountPoints()); SbVec3f* verts = coords->point.startEditing(); - unsigned long i=0; + int i=0; for (MeshCore::MeshPointArray::_TConstIterator it = cP.begin(); it != cP.end(); ++it, i++) { verts[i].setValue(it->x, it->y, it->z); } coords->point.finishEditing(); // set the face indices - unsigned long j=0; + int j=0; const MeshCore::MeshFacetArray& cF = rcMesh.GetFacets(); faces->coordIndex.setNum(4*rcMesh.CountFacets()); int32_t* indices = faces->coordIndex.startEditing(); @@ -1211,7 +1211,7 @@ void ViewProviderMesh::selectGLCallback(void * ud, SoEventCallback * n) void ViewProviderMesh::getFacetsFromPolygon(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner, - std::vector& indices) const + std::vector& indices) const { const bool ok = true; Base::Polygon2d polygon; @@ -1225,11 +1225,11 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector& picked, if (!inner) { // get the indices that are completely outside - std::vector complete(meshProp.getValue().countFacets()); - std::generate(complete.begin(), complete.end(), Base::iotaGen(0)); + std::vector complete(meshProp.getValue().countFacets()); + std::generate(complete.begin(), complete.end(), Base::iotaGen(0)); std::sort(indices.begin(), indices.end()); - std::vector complementary; - std::back_insert_iterator > biit(complementary); + std::vector complementary; + std::back_insert_iterator > biit(complementary); std::set_difference(complete.begin(), complete.end(), indices.begin(), indices.end(), biit); indices = complementary; } @@ -1238,7 +1238,7 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector& picked, Base::Console().Message("The picked polygon seems to have self-overlappings. This could lead to strange results."); } -std::vector ViewProviderMesh::getFacetsOfRegion(const SbViewportRegion& select, +std::vector ViewProviderMesh::getFacetsOfRegion(const SbViewportRegion& select, const SbViewportRegion& region, SoCamera* camera) const { @@ -1251,7 +1251,7 @@ std::vector ViewProviderMesh::getFacetsOfRegion(const SbViewportR gl.apply(root); root->unref(); - std::vector faces; + std::vector faces; faces.insert(faces.end(), gl.indices.begin(), gl.indices.end()); return faces; } @@ -1315,7 +1315,7 @@ void ViewProviderMesh::boxZoom(const SbBox2s& box, const SbViewportRegion & vp, } } -std::vector ViewProviderMesh::getVisibleFacetsAfterZoom(const SbBox2s& rect, +std::vector ViewProviderMesh::getVisibleFacetsAfterZoom(const SbBox2s& rect, const SbViewportRegion& vp, SoCamera* camera) const { @@ -1363,7 +1363,7 @@ private: } -std::vector ViewProviderMesh::getVisibleFacets(const SbViewportRegion& vp, +std::vector ViewProviderMesh::getVisibleFacets(const SbViewportRegion& vp, SoCamera* camera) const { #if 0 @@ -1458,14 +1458,14 @@ std::vector ViewProviderMesh::getVisibleFacets(const SbViewportRe int width = img.width(); int height = img.height(); QRgb color=0; - std::vector faces; + std::vector faces; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { QRgb rgb = img.pixel(x,y); rgb = rgb-(0xff << 24); if (rgb != 0 && rgb != color) { color = rgb; - faces.push_back((unsigned long)rgb); + faces.push_back((Mesh::FacetIndex)rgb); } } } @@ -1481,7 +1481,7 @@ void ViewProviderMesh::cutMesh(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner) { // Get the facet indices inside the tool mesh - std::vector indices; + std::vector indices; getFacetsFromPolygon(picked, proj, inner, indices); removeFacets(indices); } @@ -1510,17 +1510,17 @@ void ViewProviderMesh::splitMesh(const MeshCore::MeshKernel& toolMesh, const Bas const MeshCore::MeshKernel& meshPropKernel = meshProp.getValue().getKernel(); // Get the facet indices inside the tool mesh - std::vector indices; + std::vector indices; MeshCore::MeshFacetGrid cGrid(meshPropKernel); MeshCore::MeshAlgorithm cAlg(meshPropKernel); cAlg.GetFacetsFromToolMesh(toolMesh, normal, cGrid, indices); if (!clip_inner) { // get the indices that are completely outside - std::vector complete(meshPropKernel.CountFacets()); - std::generate(complete.begin(), complete.end(), Base::iotaGen(0)); + std::vector complete(meshPropKernel.CountFacets()); + std::generate(complete.begin(), complete.end(), Base::iotaGen(0)); std::sort(indices.begin(), indices.end()); - std::vector complementary; - std::back_insert_iterator > biit(complementary); + std::vector complementary; + std::back_insert_iterator > biit(complementary); std::set_difference(complete.begin(), complete.end(), indices.begin(), indices.end(), biit); indices = complementary; } @@ -1542,17 +1542,17 @@ void ViewProviderMesh::segmentMesh(const MeshCore::MeshKernel& toolMesh, const B const MeshCore::MeshKernel& meshPropKernel = meshProp.getValue().getKernel(); // Get the facet indices inside the tool mesh - std::vector indices; + std::vector indices; MeshCore::MeshFacetGrid cGrid(meshPropKernel); MeshCore::MeshAlgorithm cAlg(meshPropKernel); cAlg.GetFacetsFromToolMesh(toolMesh, normal, cGrid, indices); if (!clip_inner) { // get the indices that are completely outside - std::vector complete(meshPropKernel.CountFacets()); - std::generate(complete.begin(), complete.end(), Base::iotaGen(0)); + std::vector complete(meshPropKernel.CountFacets()); + std::generate(complete.begin(), complete.end(), Base::iotaGen(0)); std::sort(indices.begin(), indices.end()); - std::vector complementary; - std::back_insert_iterator > biit(complementary); + std::vector complementary; + std::back_insert_iterator > biit(complementary); std::set_difference(complete.begin(), complete.end(), indices.begin(), indices.end(), biit); indices = complementary; } @@ -1617,7 +1617,7 @@ void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n) if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) { // get the boundary to the picked facet const SoFaceDetail* faceDetail = static_cast(detail); - unsigned long uFacet = faceDetail->getFaceIndex(); + Mesh::FacetIndex uFacet = faceDetail->getFaceIndex(); that->faceInfo(uFacet); Gui::GLFlagWindow* flags = 0; std::list glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId()); @@ -1683,7 +1683,7 @@ void ViewProviderMesh::fillHoleCallback(void * ud, SoEventCallback * n) const SoDetail* detail = point->getDetail(that->getShapeNode()); if ( detail && detail->getTypeId() == SoFaceDetail::getClassTypeId() ) { // get the boundary to the picked facet - unsigned long uFacet = ((SoFaceDetail*)detail)->getFaceIndex(); + Mesh::FacetIndex uFacet = ((SoFaceDetail*)detail)->getFaceIndex(); that->fillHole(uFacet); } } @@ -1750,14 +1750,14 @@ void ViewProviderMesh::markPartCallback(void * ud, SoEventCallback * n) const SoDetail* detail = point->getDetail(that->getShapeNode()); if ( detail && detail->getTypeId() == SoFaceDetail::getClassTypeId() ) { // get the boundary to the picked facet - unsigned long uFacet = static_cast(detail)->getFaceIndex(); + Mesh::FacetIndex uFacet = static_cast(detail)->getFaceIndex(); that->selectComponent(uFacet); } } } } -void ViewProviderMesh::faceInfo(unsigned long uFacet) +void ViewProviderMesh::faceInfo(Mesh::FacetIndex uFacet) { Mesh::Feature* fea = static_cast(this->getObject()); const MeshCore::MeshKernel& rKernel = fea->Mesh.getValue().getKernel(); @@ -1775,28 +1775,28 @@ void ViewProviderMesh::faceInfo(unsigned long uFacet) } } -void ViewProviderMesh::fillHole(unsigned long uFacet) +void ViewProviderMesh::fillHole(Mesh::FacetIndex uFacet) { // get parameter from user settings Base::Reference hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("Mod/Mesh"); int level = (int)hGrp->GetInt("FillHoleLevel", 2); // get the boundary to the picked facet - std::list aBorder; + std::list aBorder; Mesh::Feature* fea = reinterpret_cast(this->getObject()); const MeshCore::MeshKernel& rKernel = fea->Mesh.getValue().getKernel(); MeshCore::MeshRefPointToFacets cPt2Fac(rKernel); MeshCore::MeshAlgorithm meshAlg(rKernel); meshAlg.GetMeshBorder(uFacet, aBorder); - std::vector boundary(aBorder.begin(), aBorder.end()); - std::list > boundaries; + std::vector boundary(aBorder.begin(), aBorder.end()); + std::list > boundaries; boundaries.push_back(boundary); meshAlg.SplitBoundaryLoops(boundaries); std::vector newFacets; std::vector newPoints; unsigned long numberOfOldPoints = rKernel.CountPoints(); - for (std::list >::iterator it = boundaries.begin(); it != boundaries.end(); ++it) { + for (std::list >::iterator it = boundaries.begin(); it != boundaries.end(); ++it) { if (it->size() < 3/* || it->size() > 200*/) continue; boundary = *it; @@ -1863,7 +1863,12 @@ void ViewProviderMesh::resetFacetTransparency() pcShapeMaterial->transparency.setValue(0); } -void ViewProviderMesh::removeFacets(const std::vector& facets) +/*! The triangles with the passed indices are already added to the mesh. */ +void ViewProviderMesh::appendFacets(const std::vector&) +{ +} + +void ViewProviderMesh::removeFacets(const std::vector& facets) { // Get the attached mesh property Mesh::PropertyMeshKernel& meshProp = static_cast(pcObject)->Mesh; @@ -1874,7 +1879,7 @@ void ViewProviderMesh::removeFacets(const std::vector& facets) bool ok = Coloring.getValue(); if (prop && prop->getSize() == static_cast(kernel->countPoints())) { - std::vector pointDegree; + std::vector pointDegree; unsigned long invalid = kernel->getPointDegree(facets, pointDegree); if (invalid > 0) { // switch off coloring mode @@ -1921,9 +1926,9 @@ void ViewProviderMesh::removeFacets(const std::vector& facets) Coloring.setValue(ok); } -void ViewProviderMesh::selectFacet(unsigned long facet) +void ViewProviderMesh::selectFacet(Mesh::FacetIndex facet) { - std::vector selection; + std::vector selection; selection.push_back(facet); const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); @@ -1941,9 +1946,9 @@ void ViewProviderMesh::selectFacet(unsigned long facet) } } -void ViewProviderMesh::deselectFacet(unsigned long facet) +void ViewProviderMesh::deselectFacet(Mesh::FacetIndex facet) { - std::vector selection; + std::vector selection; selection.push_back(facet); const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); @@ -1967,16 +1972,16 @@ void ViewProviderMesh::deselectFacet(unsigned long facet) } } -bool ViewProviderMesh::isFacetSelected(unsigned long facet) +bool ViewProviderMesh::isFacetSelected(Mesh::FacetIndex facet) { const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); const MeshCore::MeshFacetArray& faces = rMesh.getKernel().GetFacets(); return faces[facet].IsFlag(MeshCore::MeshFacet::SELECTED); } -void ViewProviderMesh::selectComponent(unsigned long uFacet) +void ViewProviderMesh::selectComponent(Mesh::FacetIndex uFacet) { - std::vector selection; + std::vector selection; selection.push_back(uFacet); MeshCore::MeshTopFacetVisitor clVisitor(selection); @@ -1990,9 +1995,9 @@ void ViewProviderMesh::selectComponent(unsigned long uFacet) highlightSelection(); } -void ViewProviderMesh::deselectComponent(unsigned long uFacet) +void ViewProviderMesh::deselectComponent(Mesh::FacetIndex uFacet) { - std::vector selection; + std::vector selection; selection.push_back(uFacet); MeshCore::MeshTopFacetVisitor clVisitor(selection); @@ -2009,7 +2014,7 @@ void ViewProviderMesh::deselectComponent(unsigned long uFacet) unhighlightSelection(); } -void ViewProviderMesh::setSelection(const std::vector& indices) +void ViewProviderMesh::setSelection(const std::vector& indices) { const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); rMesh.clearFacetSelection(); @@ -2022,7 +2027,7 @@ void ViewProviderMesh::setSelection(const std::vector& indices) highlightSelection(); } -void ViewProviderMesh::addSelection(const std::vector& indices) +void ViewProviderMesh::addSelection(const std::vector& indices) { const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); rMesh.addFacetsToSelection(indices); @@ -2031,7 +2036,7 @@ void ViewProviderMesh::addSelection(const std::vector& indices) highlightSelection(); } -void ViewProviderMesh::removeSelection(const std::vector& indices) +void ViewProviderMesh::removeSelection(const std::vector& indices) { const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); rMesh.removeFacetsFromSelection(indices); @@ -2051,7 +2056,7 @@ void ViewProviderMesh::invertSelection() unsigned long num_notsel = std::count_if(faces.begin(), faces.end(), [flag](const MeshCore::MeshFacet& f) { return flag(f, MeshCore::MeshFacet::SELECTED); }); - std::vector notselect; + std::vector notselect; notselect.reserve(num_notsel); MeshCore::MeshFacetArray::_TConstIterator beg = faces.begin(); MeshCore::MeshFacetArray::_TConstIterator end = faces.end(); @@ -2071,7 +2076,7 @@ void ViewProviderMesh::clearSelection() void ViewProviderMesh::deleteSelection() { - std::vector indices; + std::vector indices; Mesh::PropertyMeshKernel& meshProp = static_cast(pcObject)->Mesh; const Mesh::MeshObject& rMesh = meshProp.getValue(); rMesh.getFacetsFromSelection(indices); @@ -2084,7 +2089,6 @@ void ViewProviderMesh::deleteSelection() bool ViewProviderMesh::hasSelection() const { - std::vector indices; Mesh::PropertyMeshKernel& meshProp = static_cast(pcObject)->Mesh; const Mesh::MeshObject& rMesh = meshProp.getValue(); return rMesh.hasSelectedFacets(); @@ -2096,7 +2100,7 @@ void ViewProviderMesh::selectArea(short x, short y, short w, short h, { SbViewportRegion vp; vp.setViewportPixels (x, y, w, h); - std::vector faces = getFacetsOfRegion(vp, region, camera); + std::vector faces = getFacetsOfRegion(vp, region, camera); const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); rMesh.addFacetsToSelection(faces); @@ -2107,7 +2111,7 @@ void ViewProviderMesh::selectArea(short x, short y, short w, short h, void ViewProviderMesh::highlightSelection() { - std::vector selection; + std::vector selection; const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); rMesh.getFacetsFromSelection(selection); if (selection.empty()) { @@ -2125,7 +2129,7 @@ void ViewProviderMesh::highlightSelection() SbColor* cols = pcShapeMaterial->diffuseColor.startEditing(); for (int i=0; i::iterator it = selection.begin(); it != selection.end(); ++it) + for (std::vector::iterator it = selection.begin(); it != selection.end(); ++it) cols[*it].setValue(1.0f,0.0f,0.0f); pcShapeMaterial->diffuseColor.finishEditing(); } @@ -2153,7 +2157,7 @@ void ViewProviderMesh::setHighlightedComponents(bool on) void ViewProviderMesh::highlightComponents() { const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); - std::vector > comps = rMesh.getComponents(); + std::vector > comps = rMesh.getComponents(); // Colorize the components pcMatBinding->value = SoMaterialBinding::PER_FACE; @@ -2161,12 +2165,12 @@ void ViewProviderMesh::highlightComponents() pcShapeMaterial->diffuseColor.setNum(uCtFacets); SbColor* cols = pcShapeMaterial->diffuseColor.startEditing(); - for (std::vector >::iterator it = comps.begin(); it != comps.end(); ++it) { + for (std::vector >::iterator it = comps.begin(); it != comps.end(); ++it) { float fMax = (float)RAND_MAX; float fRed = (float)rand()/fMax; float fGrn = (float)rand()/fMax; float fBlu = (float)rand()/fMax; - for (std::vector::iterator jt = it->begin(); jt != it->end(); ++jt) { + for (std::vector::iterator jt = it->begin(); jt != it->end(); ++jt) { cols[*jt].setValue(fRed,fGrn,fBlu); } } @@ -2213,11 +2217,11 @@ void ViewProviderMesh::highlightSegments(const std::vector& colors) pcShapeMaterial->diffuseColor.setNum(uCtFacets); SbColor* cols = pcShapeMaterial->diffuseColor.startEditing(); for (unsigned long i=0; i segm = rMesh.getSegment(i).getIndices(); + std::vector segm = rMesh.getSegment(i).getIndices(); float fRed = colors[i].r; float fGrn = colors[i].g; float fBlu = colors[i].b; - for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) { + for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) { cols[*it].setValue(fRed,fGrn,fBlu); } } @@ -2311,7 +2315,7 @@ void ViewProviderIndexedFaceSet::showOpenEdges(bool show) const MeshCore::MeshFacetArray& rFaces = rMesh.GetFacets(); for (MeshCore::MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) { for (int i=0; i<3; i++) { - if (it->_aulNeighbours[i] == ULONG_MAX) { + if (it->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) { lines->coordIndex.set1Value(index++,it->_aulPoints[i]); lines->coordIndex.set1Value(index++,it->_aulPoints[(i+1)%3]); lines->coordIndex.set1Value(index++,SO_END_LINE_INDEX); diff --git a/src/Mod/Mesh/Gui/ViewProvider.h b/src/Mod/Mesh/Gui/ViewProvider.h index 4ac5979a99..7a0d87b22b 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.h +++ b/src/Mod/Mesh/Gui/ViewProvider.h @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -142,27 +143,28 @@ public: /** @name Editing */ //@{ bool doubleClicked(void){ return false; } - bool isFacetSelected(unsigned long facet); - void selectComponent(unsigned long facet); - void deselectComponent(unsigned long facet); - void selectFacet(unsigned long facet); - void deselectFacet(unsigned long facet); - void setSelection(const std::vector&); - void addSelection(const std::vector&); - void removeSelection(const std::vector&); + bool isFacetSelected(Mesh::FacetIndex facet); + void selectComponent(Mesh::FacetIndex facet); + void deselectComponent(Mesh::FacetIndex facet); + void selectFacet(Mesh::FacetIndex facet); + void deselectFacet(Mesh::FacetIndex facet); + void setSelection(const std::vector&); + void addSelection(const std::vector&); + void removeSelection(const std::vector&); void invertSelection(); void clearSelection(); void deleteSelection(); bool hasSelection() const; void getFacetsFromPolygon(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner, - std::vector& indices) const; - std::vector getFacetsOfRegion(const SbViewportRegion&, const SbViewportRegion&, SoCamera*) const; - std::vector getVisibleFacetsAfterZoom(const SbBox2s&, const SbViewportRegion&, SoCamera*) const; - std::vector getVisibleFacets(const SbViewportRegion&, SoCamera*) const; + std::vector& indices) const; + std::vector getFacetsOfRegion(const SbViewportRegion&, const SbViewportRegion&, SoCamera*) const; + std::vector getVisibleFacetsAfterZoom(const SbBox2s&, const SbViewportRegion&, SoCamera*) const; + std::vector getVisibleFacets(const SbViewportRegion&, SoCamera*) const; virtual void cutMesh(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner); virtual void trimMesh(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner); - virtual void removeFacets(const std::vector&); + virtual void appendFacets(const std::vector&); + virtual void removeFacets(const std::vector&); /*! The size of the array must be equal to the number of facets. */ void setFacetTransparency(const std::vector&); void resetFacetTransparency(); @@ -180,8 +182,8 @@ protected: void setOpenEdgeColorFrom(const App::Color& col); virtual void splitMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner); virtual void segmentMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner); - virtual void faceInfo(unsigned long facet); - virtual void fillHole(unsigned long facet); + virtual void faceInfo(Mesh::FacetIndex facet); + virtual void fillHole(Mesh::FacetIndex facet); virtual void selectArea(short, short, short, short, const SbViewportRegion&, SoCamera*); virtual void highlightSelection(); virtual void unhighlightSelection(); diff --git a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp index 89cc682171..73bafb8578 100644 --- a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp @@ -340,7 +340,7 @@ void ViewProviderMeshCurvature::setVertexCurvatureMode(int mode) // curvature values std::vector fValues = pCurvInfo->getCurvature( mode ); - unsigned long j=0; + int j=0; for ( std::vector::const_iterator jt = fValues.begin(); jt != fValues.end(); ++jt, j++ ) { App::Color col = pcColorBar->getColor( *jt ); pcColorMat->diffuseColor.set1Value(j, SbColor(col.r, col.g, col.b)); diff --git a/src/Mod/Mesh/Gui/ViewProviderDefects.cpp b/src/Mod/Mesh/Gui/ViewProviderDefects.cpp index d0e9673a09..d086511e70 100644 --- a/src/Mod/Mesh/Gui/ViewProviderDefects.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderDefects.cpp @@ -149,7 +149,7 @@ void ViewProviderMeshOrientation::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcFaceRoot, "Face"); } -void ViewProviderMeshOrientation::showDefects(const std::vector& inds) +void ViewProviderMeshOrientation::showDefects(const std::vector& inds) { Mesh::Feature* f = static_cast(pcObject); const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel(); @@ -157,9 +157,9 @@ void ViewProviderMeshOrientation::showDefects(const std::vector& pcCoords->point.deleteValues(0); pcCoords->point.setNum(3*inds.size()); MeshCore::MeshFacetIterator cF(rMesh); - unsigned long i=0; - unsigned long j=0; - for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { + int i=0; + int j=0; + for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { cF.Set(*it); for (int k=0; k<3; k++) { Base::Vector3f cP = cF->_aclPoints[k]; @@ -214,7 +214,7 @@ void ViewProviderMeshNonManifolds::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcLineRoot, "Line"); } -void ViewProviderMeshNonManifolds::showDefects(const std::vector& inds) +void ViewProviderMeshNonManifolds::showDefects(const std::vector& inds) { if ((inds.size() % 2) != 0) return; @@ -224,9 +224,9 @@ void ViewProviderMeshNonManifolds::showDefects(const std::vector& pcCoords->point.deleteValues(0); pcCoords->point.setNum(inds.size()); MeshCore::MeshPointIterator cP(rMesh); - unsigned long i=0; - unsigned long j=0; - for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { + int i=0; + int j=0; + for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { cP.Set(*it); pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z); ++it; // go to end point @@ -279,15 +279,15 @@ void ViewProviderMeshNonManifoldPoints::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcPointRoot, "Point"); } -void ViewProviderMeshNonManifoldPoints::showDefects(const std::vector& inds) +void ViewProviderMeshNonManifoldPoints::showDefects(const std::vector& inds) { Mesh::Feature* f = static_cast(pcObject); const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel(); pcCoords->point.deleteValues(0); pcCoords->point.setNum(inds.size()); MeshCore::MeshPointIterator cP(rMesh); - unsigned long i = 0; - for ( std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it ) { + int i = 0; + for ( std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it ) { cP.Set(*it); pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z); } @@ -343,7 +343,7 @@ void ViewProviderMeshDuplicatedFaces::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcFaceRoot, "Face"); } -void ViewProviderMeshDuplicatedFaces::showDefects(const std::vector& inds) +void ViewProviderMeshDuplicatedFaces::showDefects(const std::vector& inds) { Mesh::Feature* f = static_cast(pcObject); const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel(); @@ -351,9 +351,9 @@ void ViewProviderMeshDuplicatedFaces::showDefects(const std::vectorpoint.deleteValues(0); pcCoords->point.setNum(3*inds.size()); MeshCore::MeshFacetIterator cF(rMesh); - unsigned long i=0; - unsigned long j=0; - for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { + int i=0; + int j=0; + for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { cF.Set(*it); for (int k=0; k<3; k++) { Base::Vector3f cP = cF->_aclPoints[k]; @@ -408,15 +408,15 @@ void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcPointRoot, "Point"); } -void ViewProviderMeshDuplicatedPoints::showDefects(const std::vector& inds) +void ViewProviderMeshDuplicatedPoints::showDefects(const std::vector& inds) { Mesh::Feature* f = static_cast(pcObject); const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel(); pcCoords->point.deleteValues(0); pcCoords->point.setNum(inds.size()); MeshCore::MeshPointIterator cP(rMesh); - unsigned long i = 0; - for ( std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it ) { + int i = 0; + for ( std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it ) { cP.Set(*it); pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z); } @@ -465,7 +465,7 @@ void ViewProviderMeshDegenerations::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcLineRoot, "Line"); } -void ViewProviderMeshDegenerations::showDefects(const std::vector& inds) +void ViewProviderMeshDegenerations::showDefects(const std::vector& inds) { Mesh::Feature* f = static_cast(pcObject); const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel(); @@ -473,9 +473,9 @@ void ViewProviderMeshDegenerations::showDefects(const std::vector pcCoords->point.deleteValues(0); pcCoords->point.setNum(2*inds.size()); MeshCore::MeshFacetIterator cF(rMesh); - unsigned long i=0; - unsigned long j=0; - for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { + int i=0; + int j=0; + for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { cF.Set(*it); const MeshCore::MeshPoint& rE0 = cF->_aclPoints[0]; const MeshCore::MeshPoint& rE1 = cF->_aclPoints[1]; @@ -571,7 +571,7 @@ void ViewProviderMeshIndices::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcFaceRoot, "Face"); } -void ViewProviderMeshIndices::showDefects(const std::vector& inds) +void ViewProviderMeshIndices::showDefects(const std::vector& inds) { Mesh::Feature* f = static_cast(pcObject); const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel(); @@ -580,9 +580,9 @@ void ViewProviderMeshIndices::showDefects(const std::vector& inds pcCoords->point.deleteValues(0); pcCoords->point.setNum(3*inds.size()); MeshCore::MeshFacetIterator cF(rMesh); - unsigned long i=0; - unsigned long j=0; - for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { + int i=0; + int j=0; + for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { cF.Set(*it); for (int k=0; k<3; k++) { Base::Vector3f cP = cF->_aclPoints[k]; @@ -638,7 +638,7 @@ void ViewProviderMeshSelfIntersections::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcLineRoot, "Line"); } -void ViewProviderMeshSelfIntersections::showDefects(const std::vector& indices) +void ViewProviderMeshSelfIntersections::showDefects(const std::vector& indices) { if (indices.size() % 2 != 0) return; @@ -646,12 +646,12 @@ void ViewProviderMeshSelfIntersections::showDefects(const std::vectorMesh.getValue().getKernel(); MeshCore::MeshEvalSelfIntersection eval(rMesh); - std::vector > intersection; - std::vector::const_iterator it; + std::vector > intersection; + std::vector::const_iterator it; for (it = indices.begin(); it != indices.end(); ) { - unsigned long id1 = *it; ++it; - unsigned long id2 = *it; ++it; - intersection.emplace_back(id1,id2); + Mesh::ElementIndex id1 = *it; ++it; + Mesh::ElementIndex id2 = *it; ++it; + intersection.push_back(std::make_pair(id1,id2)); } std::vector > lines; @@ -659,8 +659,8 @@ void ViewProviderMeshSelfIntersections::showDefects(const std::vectorpoint.deleteValues(0); pcCoords->point.setNum(2*lines.size()); - unsigned long i=0; - unsigned long j=0; + int i=0; + int j=0; for (std::vector >::const_iterator it = lines.begin(); it != lines.end(); ++it) { pcCoords->point.set1Value(i++,it->first.x,it->first.y,it->first.z); pcCoords->point.set1Value(i++,it->second.x,it->second.y,it->second.z); @@ -718,7 +718,7 @@ void ViewProviderMeshFolds::attach(App::DocumentObject* pcFeat) addDisplayMaskMode(pcFaceRoot, "Face"); } -void ViewProviderMeshFolds::showDefects(const std::vector& inds) +void ViewProviderMeshFolds::showDefects(const std::vector& inds) { Mesh::Feature* f = static_cast(pcObject); const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel(); @@ -726,9 +726,9 @@ void ViewProviderMeshFolds::showDefects(const std::vector& inds) pcCoords->point.deleteValues(0); pcCoords->point.setNum(3*inds.size()); MeshCore::MeshFacetIterator cF(rMesh); - unsigned long i=0; - unsigned long j=0; - for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { + int i=0; + int j=0; + for (std::vector::const_iterator it = inds.begin(); it != inds.end(); ++it) { cF.Set(*it); for (int k=0; k<3; k++) { Base::Vector3f cP = cF->_aclPoints[k]; diff --git a/src/Mod/Mesh/Gui/ViewProviderDefects.h b/src/Mod/Mesh/Gui/ViewProviderDefects.h index d9815a8f2b..223585558f 100644 --- a/src/Mod/Mesh/Gui/ViewProviderDefects.h +++ b/src/Mod/Mesh/Gui/ViewProviderDefects.h @@ -50,7 +50,7 @@ public: // Build up the initial Inventor node virtual void attach(App::DocumentObject* pcFeature) = 0; /// Fill up the Inventor node with data - virtual void showDefects(const std::vector&) = 0; + virtual void showDefects(const std::vector&) = 0; protected: /// get called by the container whenever a property has been changed @@ -72,7 +72,7 @@ public: virtual ~ViewProviderMeshOrientation(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoFaceSet* pcFaces; @@ -90,7 +90,7 @@ public: virtual ~ViewProviderMeshNonManifolds(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoLineSet* pcLines; @@ -108,7 +108,7 @@ public: virtual ~ViewProviderMeshNonManifoldPoints(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoPointSet* pcPoints; @@ -126,7 +126,7 @@ public: virtual ~ViewProviderMeshDuplicatedFaces(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoFaceSet* pcFaces; @@ -144,7 +144,7 @@ public: virtual ~ViewProviderMeshDegenerations(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoLineSet* pcLines; @@ -159,7 +159,7 @@ public: virtual ~ViewProviderMeshDuplicatedPoints(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoPointSet* pcPoints; @@ -174,7 +174,7 @@ public: virtual ~ViewProviderMeshIndices(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoFaceSet* pcFaces; @@ -192,7 +192,7 @@ public: virtual ~ViewProviderMeshSelfIntersections(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoLineSet* pcLines; @@ -207,7 +207,7 @@ public: virtual ~ViewProviderMeshFolds(); void attach(App::DocumentObject* pcFeature); - void showDefects(const std::vector&); + void showDefects(const std::vector&); protected: SoFaceSet* pcFaces; diff --git a/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp b/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp index 822de958c9..7c0d7765a7 100644 --- a/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp @@ -167,7 +167,7 @@ void ViewProviderMeshFaceSet::updateData(const App::Property* prop) } showOpenEdges(OpenEdges.getValue()); - std::vector selection; + std::vector selection; mesh->getFacetsFromSelection(selection); if (selection.empty()) unhighlightSelection(); @@ -181,7 +181,7 @@ void ViewProviderMeshFaceSet::showOpenEdges(bool show) if (pcOpenEdge) { // remove the node and destroy the data pcRoot->removeChild(pcOpenEdge); - pcOpenEdge = 0; + pcOpenEdge = nullptr; } if (show) { @@ -204,7 +204,7 @@ void ViewProviderMeshFaceSet::showOpenEdges(bool show) const MeshCore::MeshFacetArray& rFaces = rMesh.GetFacets(); for (MeshCore::MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) { for (int i=0; i<3; i++) { - if (it->_aulNeighbours[i] == ULONG_MAX) { + if (it->_aulNeighbours[i] == MeshCore::FACET_INDEX_MAX) { lines->coordIndex.set1Value(index++,it->_aulPoints[i]); lines->coordIndex.set1Value(index++,it->_aulPoints[(i+1)%3]); lines->coordIndex.set1Value(index++,SO_END_LINE_INDEX); diff --git a/src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp b/src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp index 7c4d546473..543c1f6953 100644 --- a/src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp @@ -51,11 +51,11 @@ PyObject* ViewProviderMeshPy::setSelection(PyObject *args) return 0; Py::Sequence list(obj); - std::vector selection; + std::vector selection; selection.reserve(list.size()); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { Py::Long index(*it); - unsigned long value = static_cast(index); + Mesh::FacetIndex value = static_cast(index); selection.push_back(value); } @@ -71,11 +71,11 @@ PyObject* ViewProviderMeshPy::addSelection(PyObject *args) return 0; Py::Sequence list(obj); - std::vector selection; + std::vector selection; selection.reserve(list.size()); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { Py::Long index(*it); - unsigned long value = static_cast(index); + Mesh::FacetIndex value = static_cast(index); selection.push_back(value); } @@ -91,11 +91,11 @@ PyObject* ViewProviderMeshPy::removeSelection(PyObject *args) return 0; Py::Sequence list(obj); - std::vector selection; + std::vector selection; selection.reserve(list.size()); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { Py::Long index(*it); - unsigned long value = static_cast(index); + Mesh::FacetIndex value = static_cast(index); selection.push_back(value); } diff --git a/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.cpp b/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.cpp index 996cdf89d7..1bd005df30 100644 --- a/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.cpp @@ -150,7 +150,7 @@ void ViewProviderMeshTransformDemolding::calcMaterialIndex(const SbRotation &rot // 3.1415926535897932384626433832795 SbVec3f Up(0,0,1),result; - unsigned long i=0; + int i=0; for( std::vector::const_iterator it=normalVector.begin();it != normalVector.end(); ++it,i++) { rot.multVec(*it,result); diff --git a/src/Mod/MeshPart/App/AppMeshPartPy.cpp b/src/Mod/MeshPart/App/AppMeshPartPy.cpp index c33f16daa8..489ae76933 100644 --- a/src/Mod/MeshPart/App/AppMeshPartPy.cpp +++ b/src/Mod/MeshPart/App/AppMeshPartPy.cpp @@ -419,7 +419,7 @@ private: Py::List list(o); Mesh::MeshObject* mesh = static_cast(m)->getMeshObjectPtr(); - std::vector segm; + std::vector segm; segm.reserve(list.size()); for (Py_ssize_t i=0; i > FaceProjctMap; + std::map > FaceProjctMap; for (unsigned long i = 0; i <= ulNbOfPoints; i++) { @@ -387,7 +387,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge, MeshGeomFacet cCurFacet= MeshK.GetFacet(uCurFacetIdx); MeshK.GetFacetNeighbours ( uCurFacetIdx, auNeighboursIdx[0], auNeighboursIdx[1], auNeighboursIdx[2]); - uCurFacetIdx = ULONG_MAX; + uCurFacetIdx = MeshCore::FACET_INDEX_MAX; PointCount = 0; for(int i=0; i<3; i++) @@ -405,7 +405,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge, } - }while(uCurFacetIdx != ULONG_MAX); + }while(uCurFacetIdx != MeshCore::FACET_INDEX_MAX); */ } @@ -425,9 +425,9 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge, // projection of the first point Base::Vector3f cStartPoint = Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z()); Base::Vector3f cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal,TempResultPoint; - unsigned long uStartFacetIdx,uCurFacetIdx; - unsigned long uLastFacetIdx=ULONG_MAX-1; // use another value as ULONG_MAX - unsigned long auNeighboursIdx[3]; + MeshCore::FacetIndex uStartFacetIdx,uCurFacetIdx; + MeshCore::FacetIndex uLastFacetIdx=MeshCore::FACET_INDEX_MAX-1; // use another value as FACET_INDEX_MAX + MeshCore::FacetIndex auNeighboursIdx[3]; bool GoOn; // go through the whole Mesh, find the first projection @@ -471,7 +471,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge, for(int i=0; i<3; i++) { // if the i'th neighbour is valid - if ( auNeighboursIdx[i] != ULONG_MAX ) + if ( auNeighboursIdx[i] != MeshCore::FACET_INDEX_MAX ) { // try to project next interval MeshGeomFacet N = MeshK.GetFacet( auNeighboursIdx[i] ); @@ -511,9 +511,9 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge, // projection of the first point Base::Vector3f cStartPoint = Base::Vector3f(gpPt.X(),gpPt.Y(),gpPt.Z()); Base::Vector3f cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal; - unsigned long uStartFacetIdx,uCurFacetIdx; - unsigned long uLastFacetIdx=ULONG_MAX-1; // use another value as ULONG_MAX - unsigned long auNeighboursIdx[3]; + MeshCore::FacetIndex uStartFacetIdx,uCurFacetIdx; + MeshCore::FacetIndex uLastFacetIdx=MeshCore::FACET_INDEX_MAX-1; // use another value as FACET_INDEX_MAX + MeshCore::FacetIndex auNeighboursIdx[3]; bool GoOn; if( !findStartPoint(MeshK,cStartPoint,cResultPoint,uStartFacetIdx) ) @@ -542,7 +542,7 @@ void CurveProjectorSimple::projectCurve( const TopoDS_Edge& aEdge, } */ -bool CurveProjectorSimple::findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex) +bool CurveProjectorSimple::findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex) { Base::Vector3f TempResultPoint; float MinLength = FLOAT_MAX; @@ -621,7 +621,7 @@ void CurveProjectorWithToolMesh::makeToolMesh( const TopoDS_Edge& aEdge,std::vec Base::SequencerLauncher seq("Building up tool mesh...", ulNbOfPoints+1); - std::map > FaceProjctMap; + std::map > FaceProjctMap; for (unsigned long i = 0; i < ulNbOfPoints; i++) { @@ -878,7 +878,7 @@ void MeshProjection::projectOnMesh(const std::vector& pointsIn, for (auto it : pointsIn) { Base::Vector3f result; - unsigned long index; + MeshCore::FacetIndex index; if (clAlg.NearestFacetOnRay(it, dir, cGrid, result, index)) { MeshCore::MeshGeomFacet geomFacet = _rcMesh.GetFacet(index); if (tolerance > 0 && geomFacet.IntersectPlaneWithLine(it, dir, result)) { @@ -943,13 +943,13 @@ void MeshProjection::projectParallelToMesh (const TopoDS_Shape &aShape, const Ba std::vector points; discretize(aEdge, points, 5); - typedef std::pair HitPoint; + typedef std::pair HitPoint; std::vector hitPoints; typedef std::pair HitPoints; std::vector hitPointPairs; for (auto it : points) { Base::Vector3f result; - unsigned long index; + MeshCore::FacetIndex index; if (clAlg.NearestFacetOnRay(it, dir, cGrid, result, index)) { hitPoints.emplace_back(result, index); @@ -988,13 +988,13 @@ void MeshProjection::projectParallelToMesh (const std::vector &aEdges, for (auto it : aEdges) { std::vector points = it.points; - typedef std::pair HitPoint; + typedef std::pair HitPoint; std::vector hitPoints; typedef std::pair HitPoints; std::vector hitPointPairs; for (auto it : points) { Base::Vector3f result; - unsigned long index; + MeshCore::FacetIndex index; if (clAlg.NearestFacetOnRay(it, dir, cGrid, result, index)) { hitPoints.emplace_back(result, index); @@ -1024,8 +1024,8 @@ void MeshProjection::projectParallelToMesh (const std::vector &aEdges, void MeshProjection::projectEdgeToEdge( const TopoDS_Edge &aEdge, float fMaxDist, const MeshFacetGrid& rGrid, std::vector& rSplitEdges ) const { - std::vector auFInds; - std::map, std::list > pEdgeToFace; + std::vector auFInds; + std::map, std::list > pEdgeToFace; const std::vector& rclFAry = _rcMesh.GetFacets(); // search the facets in the local area of the curve @@ -1038,12 +1038,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::iterator pI = auFInds.begin(); pI != auFInds.end(); ++pI ) { + for ( std::vector::iterator pI = auFInds.begin(); pI != auFInds.end(); ++pI ) { const MeshFacet& rF = rclFAry[*pI]; for (int i = 0; i < 3; i++) { - unsigned long ulPt0 = std::min(rF._aulPoints[i], rF._aulPoints[(i+1)%3]); - unsigned long ulPt1 = std::max(rF._aulPoints[i], rF._aulPoints[(i+1)%3]); - pEdgeToFace[std::pair(ulPt0, ulPt1)].push_front(*pI); + MeshCore::PointIndex ulPt0 = std::min(rF._aulPoints[i], rF._aulPoints[(i+1)%3]); + MeshCore::PointIndex ulPt1 = std::max(rF._aulPoints[i], rF._aulPoints[(i+1)%3]); + pEdgeToFace[std::pair(ulPt0, ulPt1)].push_front(*pI); } } @@ -1063,26 +1063,26 @@ void MeshProjection::projectEdgeToEdge( const TopoDS_Edge &aEdge, float fMaxDist MeshFacetIterator cFI( _rcMesh ); Base::SequencerLauncher seq( "Project curve on mesh", pEdgeToFace.size() ); - std::map, std::list >::iterator it; + std::map, std::list >::iterator it; for ( it = pEdgeToFace.begin(); it != pEdgeToFace.end(); ++it ) { seq.next(); // edge points - unsigned long uE0 = it->first.first; + MeshCore::PointIndex uE0 = it->first.first; cPI.Set( uE0 ); Base::Vector3f cE0 = *cPI; - unsigned long uE1 = it->first.second; + MeshCore::PointIndex uE1 = it->first.second; cPI.Set( uE1 ); Base::Vector3f cE1 = *cPI; - const std::list& auFaces = it->second; + const std::list& auFaces = it->second; if ( auFaces.size() > 2 ) continue; // non-manifold edge -> don't handle this // if ( clBB.IsOut( gp_Pnt(cE0.x, cE0.y, cE0.z) ) && clBB.IsOut( gp_Pnt(cE1.x, cE1.y, cE1.z) ) ) // continue; Base::Vector3f cEdgeNormal; - for ( std::list::const_iterator itF = auFaces.begin(); itF != auFaces.end(); ++itF ) { + for ( std::list::const_iterator itF = auFaces.begin(); itF != auFaces.end(); ++itF ) { cFI.Set( *itF ); cEdgeNormal += cFI->GetNormal(); } diff --git a/src/Mod/MeshPart/App/CurveProjector.h b/src/Mod/MeshPart/App/CurveProjector.h index 6076971d14..20d2479fea 100644 --- a/src/Mod/MeshPart/App/CurveProjector.h +++ b/src/Mod/MeshPart/App/CurveProjector.h @@ -57,7 +57,7 @@ public: struct FaceSplitEdge { - unsigned long ulFaceIndex; + MeshCore::FacetIndex ulFaceIndex; Base::Vector3f p1,p2; }; @@ -95,7 +95,7 @@ public: void projectCurve(const TopoDS_Edge& aEdge, std::vector &vSplitEdges); - bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex); + bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex); @@ -121,7 +121,7 @@ public: const std::vector &rclPoints, std::vector &vSplitEdges); - bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex); + bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex); @@ -162,7 +162,7 @@ public: /// Helper class struct SplitEdge { - unsigned long uE0, uE1; /**< start and endpoint of an edge */ + MeshCore::PointIndex uE0, uE1; /**< start and endpoint of an edge */ Base::Vector3f cPt; /**< Point on edge (\a uE0, \a uE1) */ }; struct Edge diff --git a/src/Mod/MeshPart/App/MeshAlgos.cpp b/src/Mod/MeshPart/App/MeshAlgos.cpp index f7d0b19044..0f1f2439d2 100644 --- a/src/Mod/MeshPart/App/MeshAlgos.cpp +++ b/src/Mod/MeshPart/App/MeshAlgos.cpp @@ -67,7 +67,7 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize) Base::Builder3D builder; std::vector PointNormals= Mesh->CalcVertexNormals(); std::vector FaceNormals; - std::set fliped; + std::set fliped; MeshFacetIterator it(*Mesh); for ( it.Init(); it.More(); it.Next() ) @@ -103,7 +103,7 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize) if(fliped.size() == 0) break; - for(std::set::iterator It= fliped.begin();It!=fliped.end();++It) + for(std::set::iterator It= fliped.begin();It!=fliped.end();++It) alg.CollapseFacet(*It); fliped.clear(); } @@ -112,7 +112,7 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize) // search for intersected facets MeshCore::MeshEvalSelfIntersection eval(*Mesh); - std::vector > faces; + std::vector > faces; eval.GetIntersections(faces); diff --git a/src/Mod/MeshPart/App/Mesher.cpp b/src/Mod/MeshPart/App/Mesher.cpp index a23e048f24..2f51741111 100644 --- a/src/Mod/MeshPart/App/Mesher.cpp +++ b/src/Mod/MeshPart/App/Mesher.cpp @@ -186,7 +186,7 @@ public: Standard_Real x2, y2, z2; Standard_Real x3, y3, z3; - std::vector< std::vector > meshSegments; + std::vector< std::vector > meshSegments; std::size_t numMeshFaces = 0; for (std::size_t i = 0; i < domains.size(); ++i) { @@ -256,8 +256,8 @@ public: // add a segment for the face if (createSegm || this->segments) { - std::vector segment(numDomainFaces); - std::generate(segment.begin(), segment.end(), Base::iotaGen(numMeshFaces)); + std::vector segment(numDomainFaces); + std::generate(segment.begin(), segment.end(), Base::iotaGen(numMeshFaces)); numMeshFaces += numDomainFaces; meshSegments.push_back(segment); } diff --git a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp index 833f8fd06f..1a7aab7f2e 100644 --- a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp +++ b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp @@ -217,7 +217,7 @@ class CurveOnMeshHandler::Private public: struct PickedPoint { - unsigned long facet; + MeshCore::FacetIndex facet; SbVec3f point; SbVec3f normal; }; diff --git a/src/Mod/ReverseEngineering/App/SurfaceTriangulation.cpp b/src/Mod/ReverseEngineering/App/SurfaceTriangulation.cpp index 6cafed46dd..f597cf4fd4 100644 --- a/src/Mod/ReverseEngineering/App/SurfaceTriangulation.cpp +++ b/src/Mod/ReverseEngineering/App/SurfaceTriangulation.cpp @@ -466,7 +466,7 @@ void ImageTriangulation::perform() const MeshCore::MeshFacetArray& face = kernel.GetFacets(); MeshCore::MeshAlgorithm meshAlg(kernel); meshAlg.SetPointFlag(MeshCore::MeshPoint::INVALID); - std::vector validPoints; + std::vector validPoints; validPoints.reserve(face.size()*3); for (MeshCore::MeshFacetArray::_TConstIterator it = face.begin(); it != face.end(); ++it) { validPoints.push_back(it->_aulPoints[0]); @@ -481,7 +481,7 @@ void ImageTriangulation::perform() unsigned long countInvalid = meshAlg.CountPointFlag(MeshCore::MeshPoint::INVALID); if (countInvalid > 0) { - std::vector invalidPoints; + std::vector invalidPoints; invalidPoints.reserve(countInvalid); meshAlg.GetPointsFlag(invalidPoints, MeshCore::MeshPoint::INVALID); diff --git a/src/Mod/ReverseEngineering/Gui/Command.cpp b/src/Mod/ReverseEngineering/Gui/Command.cpp index e954e1d042..e7c7fb9c94 100644 --- a/src/Mod/ReverseEngineering/Gui/Command.cpp +++ b/src/Mod/ReverseEngineering/Gui/Command.cpp @@ -227,8 +227,8 @@ void CmdApproxCylinder::activated(int) // get normals { - std::vector facets(kernel.CountFacets()); - std::generate(facets.begin(), facets.end(), Base::iotaGen(0)); + std::vector facets(kernel.CountFacets()); + std::generate(facets.begin(), facets.end(), Base::iotaGen(0)); std::vector normals = kernel.GetFacetNormals(facets); Base::Vector3f base = fit.GetGravity(); Base::Vector3f axis = fit.GetInitialAxisFromNormals(normals); @@ -460,7 +460,7 @@ void CmdSegmentationFromComponents::activated(int) group->Label.setValue(labelname); const Mesh::MeshObject& mesh = it->Mesh.getValue(); - std::vector > comps = mesh.getComponents(); + std::vector > comps = mesh.getComponents(); for (auto jt : comps) { std::unique_ptr segment(mesh.meshFromSegment(jt)); Mesh::Feature* feaSegm = static_cast(group->addObject("Mesh::Feature", "Segment")); diff --git a/src/Mod/ReverseEngineering/Gui/Segmentation.cpp b/src/Mod/ReverseEngineering/Gui/Segmentation.cpp index ad830963fe..21b6e128c8 100644 --- a/src/Mod/ReverseEngineering/Gui/Segmentation.cpp +++ b/src/Mod/ReverseEngineering/Gui/Segmentation.cpp @@ -111,7 +111,7 @@ void Segmentation::accept() // For each planar segment compute a plane and use this then for a more accurate 2nd segmentation if (strcmp((*it)->GetType(), "Plane") == 0) { for (std::vector::const_iterator jt = data.begin(); jt != data.end(); ++jt) { - std::vector indexes = kernel.GetFacetPoints(*jt); + std::vector indexes = kernel.GetFacetPoints(*jt); MeshCore::PlaneFit fit; fit.AddPoints(kernel.GetPoints(indexes)); if (fit.Fit() < FLOAT_MAX) { @@ -213,7 +213,7 @@ void Segmentation::accept() if (createUnused) { // collect all facets that don't have set the flag TMP0 - std::vector unusedFacets; + std::vector unusedFacets; algo.GetFacetsFlag(unusedFacets, MeshCore::MeshFacet::TMP0); if (!unusedFacets.empty()) { diff --git a/src/Mod/ReverseEngineering/Gui/SegmentationManual.cpp b/src/Mod/ReverseEngineering/Gui/SegmentationManual.cpp index 64b3806283..3176463659 100644 --- a/src/Mod/ReverseEngineering/Gui/SegmentationManual.cpp +++ b/src/Mod/ReverseEngineering/Gui/SegmentationManual.cpp @@ -130,7 +130,8 @@ static void findGeometry(int minFaces, double tolerance, if (mesh.hasSelectedFacets()) { const MeshCore::MeshKernel& kernel = mesh.getKernel(); - std::vector facets, vertexes; + std::vector facets; + std::vector vertexes; mesh.getFacetsFromSelection(facets); vertexes = mesh.getPointsFromFacets(facets); MeshCore::MeshPointArray coords = kernel.GetPoints(vertexes); @@ -244,7 +245,7 @@ void SegmentationManual::createSegment() if (ct > 0) { selected = true; - std::vector facets; + std::vector facets; algo.GetFacetsFlag(facets, MeshCore::MeshFacet::SELECTED); std::unique_ptr segment(mesh.meshFromSegment(facets));