From 7d47ebdbcd3e801187d0a71430e8e83d4261d941 Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 28 Aug 2020 15:18:43 +0300 Subject: [PATCH] 0030617: Coding - using reinterpret_cast instead of static_cast for downcast Several reinterpret_cast have been replaced by static_cast when applicable. --- src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx | 3 +- src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx | 4 +- src/OpenGl/OpenGl_View.cxx | 8 +- .../SelectMgr_SelectingVolumeManager.cxx | 11 +-- src/TColStd/TColStd_PackedMapOfInteger.cxx | 78 +++++++++---------- 5 files changed, 46 insertions(+), 58 deletions(-) diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx index a687b58cc1..6c27314ce3 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx @@ -145,8 +145,7 @@ Standard_Integer BOPAlgo_PaveFiller::MakeSDVertices Standard_Integer nV; if (nSD != -1) { // update old SD vertex with new value - Handle(BRep_TVertex)& aTVertex = - reinterpret_cast(const_cast(aVSD.TShape())); + BRep_TVertex* aTVertex = static_cast(aVSD.TShape().get()); aTVertex->Pnt(BRep_Tool::Pnt(aVn)); aTVertex->Tolerance(BRep_Tool::Tolerance(aVn)); aVn = aVSD; diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 044bbc83f0..5e81be520d 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -3328,7 +3328,7 @@ void BOPAlgo_PaveFiller::CorrectToleranceOfSE() Standard_Real aTolE = BRep_Tool::Tolerance(aE); if (aTolC < aTolE) { // reduce edge tolerance - reinterpret_cast(aE.TShape().operator->())->Tolerance(aTolC); + static_cast(aE.TShape().get())->Tolerance(aTolC); bIsReduced = Standard_True; } } @@ -3446,7 +3446,7 @@ void BOPAlgo_PaveFiller::CorrectToleranceOfSE() } // if (aMaxTol < aTolV) { - reinterpret_cast(aV.TShape().operator->())->Tolerance(aMaxTol); + static_cast(aV.TShape().get())->Tolerance(aMaxTol); } } } diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index c6c3e97b75..fce3dea695 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -782,7 +782,7 @@ void OpenGl_View::FBOChangeViewport (const Handle(Standard_Transient)& theFbo, void OpenGl_View::displayStructure (const Handle(Graphic3d_CStructure)& theStructure, const Standard_Integer thePriority) { - const OpenGl_Structure* aStruct = reinterpret_cast (theStructure.operator->()); + const OpenGl_Structure* aStruct = static_cast (theStructure.get()); const Graphic3d_ZLayerId aZLayer = aStruct->ZLayer(); myZLayers.AddStructure (aStruct, aZLayer, thePriority); } @@ -793,7 +793,7 @@ void OpenGl_View::displayStructure (const Handle(Graphic3d_CStructure)& theStruc //======================================================================= void OpenGl_View::eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) { - const OpenGl_Structure* aStruct = reinterpret_cast (theStructure.operator->()); + const OpenGl_Structure* aStruct = static_cast (theStructure.get()); myZLayers.RemoveStructure (aStruct); } @@ -805,7 +805,7 @@ void OpenGl_View::changeZLayer (const Handle(Graphic3d_CStructure)& theStructure const Graphic3d_ZLayerId theNewLayerId) { const Graphic3d_ZLayerId anOldLayer = theStructure->ZLayer(); - const OpenGl_Structure* aStruct = reinterpret_cast (theStructure.operator->()); + const OpenGl_Structure* aStruct = static_cast (theStructure.get()); myZLayers.ChangeLayer (aStruct, anOldLayer, theNewLayerId); Update (anOldLayer); Update (theNewLayerId); @@ -819,7 +819,7 @@ void OpenGl_View::changePriority (const Handle(Graphic3d_CStructure)& theStructu const Standard_Integer theNewPriority) { const Graphic3d_ZLayerId aLayerId = theStructure->ZLayer(); - const OpenGl_Structure* aStruct = reinterpret_cast (theStructure.operator->()); + const OpenGl_Structure* aStruct = static_cast (theStructure.get()); myZLayers.ChangePriority (aStruct, aLayerId, theNewPriority); } diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx index b72f45cdff..f6e96e25bc 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx @@ -415,8 +415,7 @@ const gp_Pnt* SelectMgr_SelectingVolumeManager::GetVertices() const if (myActiveSelectionType == Polyline) return NULL; - const SelectMgr_RectangularFrustum* aFr = - reinterpret_cast (mySelectingVolumes[myActiveSelectionType / 2].get()); + const SelectMgr_RectangularFrustum* aFr = static_cast (mySelectingVolumes[myActiveSelectionType / 2].get()); return aFr->GetVertices(); } @@ -429,8 +428,7 @@ gp_Pnt SelectMgr_SelectingVolumeManager::GetNearPickedPnt() const if (myActiveSelectionType == Polyline) return gp_Pnt(); - const SelectMgr_RectangularFrustum* aFr = - reinterpret_cast (mySelectingVolumes[myActiveSelectionType / 2].get()); + const SelectMgr_RectangularFrustum* aFr = static_cast (mySelectingVolumes[myActiveSelectionType / 2].get()); return aFr->GetNearPnt(); } @@ -443,8 +441,7 @@ gp_Pnt SelectMgr_SelectingVolumeManager::GetFarPickedPnt() const if (myActiveSelectionType == Polyline) return gp_Pnt(); - const SelectMgr_RectangularFrustum* aFr = - reinterpret_cast (mySelectingVolumes[myActiveSelectionType / 2].get()); + const SelectMgr_RectangularFrustum* aFr = static_cast (mySelectingVolumes[myActiveSelectionType / 2].get()); return aFr->GetFarPnt(); } @@ -462,7 +459,7 @@ void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_S return; const SelectMgr_SelectingVolumeManager* aWorldSelMgr = theWorldSelMgr != NULL ? theWorldSelMgr : this; - const SelectMgr_RectangularFrustum* aFrustum = reinterpret_cast(aWorldSelMgr->mySelectingVolumes[Frustum].get()); + const SelectMgr_RectangularFrustum* aFrustum = static_cast(aWorldSelMgr->mySelectingVolumes[Frustum].get()); myViewClipRange.SetVoid(); if (!theViewPlanes.IsNull() && !theViewPlanes->IsEmpty()) diff --git a/src/TColStd/TColStd_PackedMapOfInteger.cxx b/src/TColStd/TColStd_PackedMapOfInteger.cxx index 86b7d2da84..6dbc311cd8 100644 --- a/src/TColStd/TColStd_PackedMapOfInteger.cxx +++ b/src/TColStd/TColStd_PackedMapOfInteger.cxx @@ -319,7 +319,7 @@ TColStd_PackedMapOfInteger& TColStd_PackedMapOfInteger::Assign aData[aHashCode] = new TColStd_intMapNode (p->Mask(), p->Data(), aData[aHashCode]); Increment(); - p = reinterpret_cast (p->Next()); + p = static_cast (p->Next()); } } // TColStd_MapIteratorOfPackedMapOfInteger anIt (theOther); @@ -414,7 +414,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Add (const Standard_Integer aKey) // break; goto finish; // goto saves us 4 CPU clocks or 4% performance } - p = reinterpret_cast (p->Next()); + p = static_cast (p->Next()); } // if (!p) { // not needed, as long as we exit the loop by goto data[aHashCode] = new TColStd_intMapNode(aKey, aBucketHead); @@ -444,7 +444,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Contains aResult = (p->HasValue (aKey) != 0); break; } - p = reinterpret_cast (p->Next()); + p = static_cast (p->Next()); } } return aResult; @@ -472,14 +472,14 @@ Standard_Boolean TColStd_PackedMapOfInteger::Remove(const Standard_Integer aKey) if (p->HasValues() == Standard_False) { Decrement(); if (q) q->Next() = p->Next(); - else aBucketHead = reinterpret_cast(p->Next()); + else aBucketHead = static_cast(p->Next()); delete p; } } break; } q = p; - p = reinterpret_cast (p->Next()); + p = static_cast (p->Next()); } } return aResult; @@ -498,11 +498,10 @@ Standard_Integer TColStd_PackedMapOfInteger::GetMinimalMapped () const const TColStd_intMapNode * pFoundNode = 0L; for (Standard_Integer i = 0; i <= NbBuckets(); i++) { for (const TCollection_MapNode * p = aData[i]; p != 0L; p = p->Next()) { - const Standard_Integer aKey = - reinterpret_cast (p)->Key(); + const Standard_Integer aKey = static_cast (p)->Key(); if (aResult > aKey) { aResult = aKey; - pFoundNode = reinterpret_cast(p); + pFoundNode = static_cast(p); } } } @@ -527,11 +526,10 @@ Standard_Integer TColStd_PackedMapOfInteger::GetMaximalMapped () const const TColStd_intMapNode * pFoundNode = 0L; for (Standard_Integer i = 0; i <= NbBuckets(); i++) { for (const TCollection_MapNode * p = aData[i]; p != 0L; p = p->Next()) { - const Standard_Integer aKey = - reinterpret_cast (p)->Key(); + const Standard_Integer aKey = static_cast (p)->Key(); if (aResult < aKey) { aResult = aKey; - pFoundNode = reinterpret_cast(p); + pFoundNode = static_cast(p); } } } @@ -585,7 +583,7 @@ void TColStd_PackedMapOfInteger::Union (const TColStd_PackedMapOfInteger& theMap nValues = TColStd_Population (aNewMask, aNewData); break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } // Store the block - result of operation if (Resizable()) { @@ -597,7 +595,7 @@ void TColStd_PackedMapOfInteger::Union (const TColStd_PackedMapOfInteger& theMap aData[aHashCode]); Increment(); myExtent += nValues; - p1 = reinterpret_cast (p1->Next()); + p1 = static_cast (p1->Next()); } } // Iteration of the 2nd map. @@ -610,7 +608,7 @@ void TColStd_PackedMapOfInteger::Union (const TColStd_PackedMapOfInteger& theMap while (p1) { if (p1->IsEqual(*p2)) break; - p1 = reinterpret_cast (p1->Next()); + p1 = static_cast (p1->Next()); } // Add the block from the 2nd map only in the case when the similar // block has not been found in the 1st map @@ -625,7 +623,7 @@ void TColStd_PackedMapOfInteger::Union (const TColStd_PackedMapOfInteger& theMap Increment(); myExtent += p2->NbValues(); } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } } } @@ -669,7 +667,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Unite(const TColStd_PackedMapOfInte } break; } - p1 = reinterpret_cast (p1->Next()); + p1 = static_cast (p1->Next()); } // If the block is not found in the 1st map, add it to the 1st map if (p1 == 0L) { @@ -683,7 +681,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Unite(const TColStd_PackedMapOfInte Increment(); aNewExtent += p2->NbValues(); } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } } Standard_Boolean isChanged = ( myExtent != aNewExtent ); @@ -749,9 +747,9 @@ void TColStd_PackedMapOfInteger::Intersection } break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } - p1 = reinterpret_cast (p1->Next()); + p1 = static_cast (p1->Next()); } } } @@ -802,10 +800,9 @@ Standard_Boolean TColStd_PackedMapOfInteger::Intersect } break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } - TColStd_intMapNode* pNext = - reinterpret_cast (p1->Next()); + TColStd_intMapNode* pNext = static_cast (p1->Next()); // If p2!=NULL, then the map node is kept and we move to the next one // Otherwise we should remove the current node if (p2) @@ -870,7 +867,7 @@ void TColStd_PackedMapOfInteger::Subtraction nValues = TColStd_Population (aNewMask, aNewData); break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } // Store the block - result of operation if (aNewData) { @@ -884,7 +881,7 @@ void TColStd_PackedMapOfInteger::Subtraction Increment(); myExtent += nValues; } - p1 = reinterpret_cast (p1->Next()); + p1 = static_cast (p1->Next()); } } } @@ -915,8 +912,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Subtract TColStd_intMapNode * q = 0L; TColStd_intMapNode * p1 = aData[i]; while (p1 != 0L) { - TColStd_intMapNode* pNext = - reinterpret_cast (p1->Next()); + TColStd_intMapNode* pNext = static_cast (p1->Next()); // Find the corresponding block in the 2nd map const TColStd_intMapNode * p2 = aData2 [p1->HashCode (nBuckets2)]; @@ -942,7 +938,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Subtract } break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } if (p2 == 0L) { aNewExtent += p1->NbValues(); @@ -1000,7 +996,7 @@ void TColStd_PackedMapOfInteger::Difference (const TColStd_PackedMapOfInteger& nValues = TColStd_Population (aNewMask, aNewData); break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } // Store the block - result of operation if (aNewData) { @@ -1014,7 +1010,7 @@ void TColStd_PackedMapOfInteger::Difference (const TColStd_PackedMapOfInteger& Increment(); myExtent += nValues; } - p1 = reinterpret_cast (p1->Next()); + p1 = static_cast (p1->Next()); } } @@ -1028,7 +1024,7 @@ void TColStd_PackedMapOfInteger::Difference (const TColStd_PackedMapOfInteger& while (p1) { if (p1->IsEqual(*p2)) break; - p1 = reinterpret_cast (p1->Next()); + p1 = static_cast (p1->Next()); } // Add the block from the 2nd map only in the case when the similar // block has not been found in the 1st map @@ -1043,7 +1039,7 @@ void TColStd_PackedMapOfInteger::Difference (const TColStd_PackedMapOfInteger& Increment(); myExtent += p2->NbValues(); } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } } } @@ -1082,8 +1078,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Differ(const TColStd_PackedMapOfInt // Find the corresponding block in the 1st map TColStd_intMapNode * p1 = aData1[p2->HashCode (NbBuckets())]; - TColStd_intMapNode* pNext = - reinterpret_cast (p1->Next()); + TColStd_intMapNode* pNext = static_cast (p1->Next()); while (p1) { if (p1->IsEqual(*p2)) { @@ -1121,7 +1116,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Differ(const TColStd_PackedMapOfInt aNewExtent += p2->NbValues(); isChanged = Standard_True; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } } myExtent = aNewExtent; @@ -1152,8 +1147,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::IsEqual(const TColStd_PackedMapOfIn for (; i <= NbBuckets(); i++) { const TColStd_intMapNode * p1 = aData1[i]; while (p1 != 0L) { - TColStd_intMapNode* pNext = - reinterpret_cast (p1->Next()); + TColStd_intMapNode* pNext = static_cast (p1->Next()); // Find the corresponding block in the 2nd map const TColStd_intMapNode * p2 = aData2 [p1->HashCode (nBuckets2)]; @@ -1163,7 +1157,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::IsEqual(const TColStd_PackedMapOfIn return Standard_False; break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } // if the same block not found, maps are different if (p2 == 0L) @@ -1201,8 +1195,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::IsSubset (const TColStd_PackedMapOf for (; i <= NbBuckets(); i++) { const TColStd_intMapNode * p1 = aData1[i]; while (p1 != 0L) { - TColStd_intMapNode* pNext = - reinterpret_cast (p1->Next()); + TColStd_intMapNode* pNext = static_cast (p1->Next()); // Find the corresponding block in the 2nd map const TColStd_intMapNode * p2 = aData2 [p1->HashCode (nBuckets2)]; @@ -1214,7 +1207,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::IsSubset (const TColStd_PackedMapOf return Standard_False; break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } p1 = pNext; } @@ -1244,8 +1237,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::HasIntersection (const TColStd_Pack for (; i <= NbBuckets(); i++) { const TColStd_intMapNode * p1 = aData1[i]; while (p1 != 0L) { - TColStd_intMapNode* pNext = - reinterpret_cast (p1->Next()); + TColStd_intMapNode* pNext = static_cast (p1->Next()); // Find the corresponding block in the 2nd map const TColStd_intMapNode * p2 = aData2 [p1->HashCode (nBuckets2)]; @@ -1255,7 +1247,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::HasIntersection (const TColStd_Pack return Standard_True; break; } - p2 = reinterpret_cast (p2->Next()); + p2 = static_cast (p2->Next()); } p1 = pNext; }