From a9dde4a31b9851bad5658aa34033a3f3ec9b2677 Mon Sep 17 00:00:00 2001 From: abv Date: Mon, 25 Jan 2016 10:14:20 +0300 Subject: [PATCH] 0027104: DownCast() cannot return null for mismatched handle Method DownCast() is made template, to be available only when argument is actually a pointer or handle to a base class. For compatibility with existing code, method DownCast() that can be used for the same type, derived, or unrelated class (i.e. where there is no actual down casting) is still available, its use shall cause "deprecated" compiler warning. OCCT code is updated to remove meaningless DownCast()s; a few places where DownCast() was used with argument of unrelated type are corrected. DRAW command QAHandleCast is removed (it was useful only during redesign of handles). --- dox/dev_guides/upgrade/upgrade.md | 25 +++ src/AIS/AIS_AttributeFilter.cxx | 4 +- src/AIS/AIS_InteractiveContext_1.cxx | 7 +- src/AIS/AIS_LocalContext.cxx | 6 +- src/BRepAlgo/BRepAlgo_NormalProjection.cxx | 2 +- src/BRepFeat/BRepFeat_MakeLinearForm.cxx | 4 +- src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx | 4 +- src/BRepFeat/BRepFeat_RibSlot.cxx | 2 +- src/BRepFill/BRepFill_ACRLaw.cxx | 2 +- src/BRepFill/BRepFill_Evolved.cxx | 5 +- .../BinTObjDrivers_ReferenceDriver.cxx | 6 +- src/ChFi2d/ChFi2d_Builder.cxx | 12 +- src/ChFi2d/ChFi2d_Builder_0.cxx | 4 +- src/DDocStd/DDocStd.cxx | 2 +- src/DDocStd/DDocStd_DrawDocument.cxx | 2 +- src/DrawDim/DrawDim_PlanarDistance.cxx | 2 +- src/Geom/Geom_OffsetSurface.cxx | 4 +- src/Geom/Geom_RectangularTrimmedSurface.cxx | 6 +- src/Geom2dConvert/Geom2dConvert.cxx | 11 +- src/GeomAdaptor/GeomAdaptor_Surface.cxx | 13 +- src/GeomConvert/GeomConvert.cxx | 11 +- src/GeomPlate/GeomPlate_BuildPlateSurface.cxx | 6 +- .../GeomliteTest_CurveCommands.cxx | 4 +- src/IGESAppli/IGESAppli_Node.cxx | 2 +- src/IGESControl/IGESControl_IGESBoundary.cxx | 3 +- src/IGESSelect/IGESSelect.cxx | 2 +- src/IGESToBRep/IGESToBRep_IGESBoundary.cxx | 3 +- ...IVtkDraw_HighlightAndSelectionPipeline.cxx | 2 +- src/IntPatch/IntPatch_Intersection.cxx | 14 +- src/MAT2d/MAT2d_Tool2d.cxx | 29 ++- src/Message/Message_Messenger.cxx | 6 +- src/QABugs/QABugs_PresentableObject.cxx | 2 +- src/QANCollection/QANCollection_Handle.cxx | 180 +----------------- ...eCurveWithKnotsAndRationalBSplineCurve.cxx | 3 +- ...faceWithKnotsAndRationalBSplineSurface.cxx | 4 +- src/STEPCAFControl/STEPCAFControl_Reader.cxx | 25 +-- src/STEPCAFControl/STEPCAFControl_Writer.cxx | 16 +- src/STEPSelections/STEPSelections_Counter.cxx | 2 +- .../STEPSelections_SelectInstances.cxx | 2 +- src/SelectMgr/SelectMgr_SelectionManager.cxx | 6 +- src/ShapeBuild/ShapeBuild_Edge.cxx | 2 +- src/ShapeConstruct/ShapeConstruct.cxx | 6 +- .../ShapeCustom_BSplineRestriction.cxx | 4 +- src/ShapeFix/ShapeFix_Face.cxx | 2 +- src/ShapeFix/ShapeFix_Shape.cxx | 2 +- src/ShapeFix/ShapeFix_Wire.cxx | 14 +- src/ShapeProcess/ShapeProcess_OperLibrary.cxx | 4 +- .../ShapeUpgrade_ConvertCurve2dToBezier.cxx | 2 +- .../ShapeUpgrade_ConvertCurve3dToBezier.cxx | 2 +- .../ShapeUpgrade_SplitSurface.cxx | 4 +- src/Standard/Standard_Handle.hxx | 26 ++- src/StdObjMgt/StdObjMgt_ReadData.hxx | 2 +- src/StdSelect/StdSelect_ViewerSelector3d.cxx | 2 +- src/StepAP209/StepAP209_Construct.cxx | 12 +- src/StepToGeom/StepToGeom.cxx | 7 +- .../StepToGeom_MakeBSplineCurve.pxx | 2 +- .../TCollection_HExtendedString.cxx | 4 +- src/TObj/TObj_Object.cxx | 3 +- src/TObj/TObj_TReference.cxx | 2 +- src/TestTopOpe/TestTopOpe_HDSCommands.cxx | 4 +- .../TestTopOpeDraw_Displayer.cxx | 2 +- src/ViewerTest/ViewerTest.cxx | 2 +- src/VrmlData/VrmlData_Scene.cxx | 3 +- src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx | 6 +- .../XmlTObjDrivers_ReferenceDriver.cxx | 6 +- 65 files changed, 190 insertions(+), 380 deletions(-) diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 518f59179c..0a3cb467a5 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -322,6 +322,30 @@ os << aLine; // in OCCT 6.9.0, resolves to operator << (void*) Call method get() explicitly to output the address of the Handle. +#### Method DownCast for non-base types + +Method *DownCast()* in OCCT 7.0 is made templated; if it is used with argument which is not a base class, "deprecated" compiler warning is generated. +This is done to prevent possible unintended errors like this: + +~~~~~ +Handle(Geom_Surface) aSurf = ; +Handle(Geom_Line) aLine = + Handle(Geom_Line)::DownCast (aSurf); // will cause a compiler warning in OCCT 7.0, but not OCCT 6.x +~~~~~ + +The places where this cast has been used should be corrected manually. + +If down casting is used in a template context where argument can have the same or unrelated type so that *DownCast()* may be not available in all cases, use C++ *dynamic_cast<>* instead, e.g.: + +~~~~~ +template +bool CheckLine (const Handle(T) theArg) +{ + Handle(Geom_Line) aLine = dynamic_cast (theArg.get()); + ... +} +~~~~~ + @subsubsection upgrade_occt700_cdl_runtime Possible runtime problems Here is the list of known possible problems at run time after the upgrade to OCCT 7.0. @@ -330,6 +354,7 @@ Here is the list of known possible problems at run time after the upgrade to OCC In previous versions, the compiler was able to detect the situation when a local variable of a "reference to a Handle" type is initialized by temporary object, and ensured that lifetime of that object is longer than that of the variable. In OCCT 7.0 with default options, it will not work if types of the temporary object and variable are different (due to involvement of user-defined type cast), thus such temporary object will be destroyed immediately. + This problem does not appear if macro *OCCT_HANDLE_NOCAST* is used during compilation, see below. Example: diff --git a/src/AIS/AIS_AttributeFilter.cxx b/src/AIS/AIS_AttributeFilter.cxx index e19e8a7c51..3419c44f4d 100644 --- a/src/AIS/AIS_AttributeFilter.cxx +++ b/src/AIS/AIS_AttributeFilter.cxx @@ -47,10 +47,10 @@ Standard_Boolean AIS_AttributeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& Standard_Boolean okstat = Standard_True; if( hasC && aSelectable->HasColor() ) - okstat = (myCol == Handle(AIS_InteractiveObject)::DownCast (anObj)->Color()); + okstat = (myCol == aSelectable->Color()); if( hasW && aSelectable->HasWidth() ) - okstat = (myWid == Handle(AIS_InteractiveObject)::DownCast (anObj)->Width()) && okstat; + okstat = (myWid == aSelectable->Width()) && okstat; return okstat; } diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 894dfe250e..9b80e596f6 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -389,8 +389,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the for (aSelector->Init(); aSelector->More(); aSelector->Next()) { - const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked()); + const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked(); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; @@ -527,7 +526,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); for (aSelector->Init(); aSelector->More(); aSelector->Next()) { - const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked()); + const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked(); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; @@ -578,7 +577,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); for (aSelector->Init(); aSelector->More(); aSelector->Next()) { - const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked()); + const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked(); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 367df8fe2d..2f1ccd9583 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -1006,8 +1006,10 @@ void AIS_LocalContext::ClearObjects() // myMainPM->Clear(SO,CurAtt->DisplayMode());} } else { - if (CurAtt->IsSubIntensityOn()){ - myCTX->SubIntensityOff(Handle(AIS_InteractiveObject)::DownCast(SO));} + if (CurAtt->IsSubIntensityOn()) + { + myCTX->SubIntensityOff(SO); + } Standard_Integer DiMo = SO->HasDisplayMode()? SO->DisplayMode():myCTX->DisplayMode(); if(CurAtt->DisplayMode()!=-1 && diff --git a/src/BRepAlgo/BRepAlgo_NormalProjection.cxx b/src/BRepAlgo/BRepAlgo_NormalProjection.cxx index 3ffb47aa33..6e676f4194 100644 --- a/src/BRepAlgo/BRepAlgo_NormalProjection.cxx +++ b/src/BRepAlgo/BRepAlgo_NormalProjection.cxx @@ -396,7 +396,7 @@ void BRepAlgo_NormalProjection::SetDefaultParams() // points has less diameter than the tolerance 3D Degenerated = Standard_True; Standard_Real Dist; - Handle(Geom_BSplineCurve) BS3d = Handle(Geom_BSplineCurve)::DownCast( appr.Curve3d()); + Handle(Geom_BSplineCurve) BS3d = appr.Curve3d(); gp_Pnt P1(0.,0.,0.),PP; // skl : I change "P" to "PP" Standard_Integer NbPoint,ii ; // skl : I change "i" to "ii" Standard_Real Par,DPar; diff --git a/src/BRepFeat/BRepFeat_MakeLinearForm.cxx b/src/BRepFeat/BRepFeat_MakeLinearForm.cxx index c89defa29d..bc72f95f00 100644 --- a/src/BRepFeat/BRepFeat_MakeLinearForm.cxx +++ b/src/BRepFeat/BRepFeat_MakeLinearForm.cxx @@ -432,10 +432,8 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, pt = myLastPnt; Standard_Real fpar = IntPar(cc, myFirstPnt); Standard_Real lpar = IntPar(cc, pt); - Handle(Geom_Curve) ccc; if(fpar > lpar) { - ccc = Handle(Geom_Curve)::DownCast(cc->Reversed()); - cc = ccc; + cc = cc->Reversed(); } } TopoDS_Edge ee1; diff --git a/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx b/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx index 5844407635..c22947ee91 100644 --- a/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx +++ b/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx @@ -552,10 +552,8 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, pt = myLastPnt; Standard_Real fpar = IntPar(cc, myFirstPnt); Standard_Real lpar = IntPar(cc, pt); - Handle(Geom_Curve) ccc; if(fpar > lpar) { - ccc = Handle(Geom_Curve)::DownCast(cc->Reversed()); - cc = ccc; + cc = cc->Reversed(); } } TopoDS_Edge ee1; diff --git a/src/BRepFeat/BRepFeat_RibSlot.cxx b/src/BRepFeat/BRepFeat_RibSlot.cxx index 38f14f91d4..006329e0d2 100644 --- a/src/BRepFeat/BRepFeat_RibSlot.cxx +++ b/src/BRepFeat/BRepFeat_RibSlot.cxx @@ -1577,7 +1577,7 @@ Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, Standard_Real lpar = IntPar(FirstCurve, myLastPnt); Handle(Geom_Curve) c; if(fpar > lpar) - c = Handle(Geom_Curve)::DownCast(FirstCurve->Reversed()); + c = FirstCurve->Reversed(); else c = FirstCurve; diff --git a/src/BRepFill/BRepFill_ACRLaw.cxx b/src/BRepFill/BRepFill_ACRLaw.cxx index 8c8368a53c..2b91200be4 100644 --- a/src/BRepFill/BRepFill_ACRLaw.cxx +++ b/src/BRepFill/BRepFill_ACRLaw.cxx @@ -88,7 +88,7 @@ BRepFill_ACRLaw::BRepFill_ACRLaw(const TopoDS_Wire& Path, Standard_Real t1 = OrigParam->Value(ipath-1); Standard_Real t2 = OrigParam->Value(ipath); Handle(GeomFill_LocationGuide) Loc; - Loc = Handle(GeomFill_LocationGuide)::DownCast(theLaw); + Loc = theLaw; Loc->SetOrigine(t1,t2); myLaws->SetValue(ipath, Loc->Copy()); diff --git a/src/BRepFill/BRepFill_Evolved.cxx b/src/BRepFill/BRepFill_Evolved.cxx index 7f9007e1a4..4986b5e4d6 100644 --- a/src/BRepFill/BRepFill_Evolved.cxx +++ b/src/BRepFill/BRepFill_Evolved.cxx @@ -3077,10 +3077,7 @@ void CutEdgeProf (const TopoDS_Edge& E, // project it in the plane and return the associated PCurve gp_Dir Normal = Plane->Pln().Axis().Direction(); - C = - Handle(Geom_Curve)::DownCast(GeomProjLib::ProjectOnPlane(CT,Plane, - Normal, - Standard_False)); + C = GeomProjLib::ProjectOnPlane (CT, Plane, Normal, Standard_False); C2d = GeomProjLib::Curve2d(C,Plane); // Calculate the extrema with the straight line diff --git a/src/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.cxx b/src/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.cxx index b23020529d..cbc1ce3e9e 100644 --- a/src/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.cxx +++ b/src/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.cxx @@ -76,8 +76,7 @@ Standard_Boolean BinTObjDrivers_ReferenceDriver::Paste { TCollection_AsciiString aName; if (! (theSource >> aName)) return Standard_False; - Handle(TObj_Model) aModel = Handle(TObj_Model)::DownCast - ( TObj_Assistant::FindModel( aName.ToCString() )); + Handle(TObj_Model) aModel = TObj_Assistant::FindModel (aName.ToCString()); if (aModel.IsNull()) { TCollection_AsciiString anEntry; @@ -133,8 +132,7 @@ void BinTObjDrivers_ReferenceDriver::Paste if (! isSameDoc) { TCollection_AsciiString aName; - Handle(TObj_Model) aModel = - Handle(TObj_Model)::DownCast( aLObject->GetModel() ); + Handle(TObj_Model) aModel = aLObject->GetModel(); aName = TCollection_AsciiString( aModel->GetModelName()->String() ); theTarget << aName; } diff --git a/src/ChFi2d/ChFi2d_Builder.cxx b/src/ChFi2d/ChFi2d_Builder.cxx index e0e4e3125d..868eccee03 100644 --- a/src/ChFi2d/ChFi2d_Builder.cxx +++ b/src/ChFi2d/ChFi2d_Builder.cxx @@ -774,14 +774,14 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V, Handle(Geom2d_Curve) basisC1,basisC2; Handle(Geom2d_TrimmedCurve) T1 = Handle(Geom2d_TrimmedCurve)::DownCast(C1); if (!T1.IsNull()) - basisC1 = Handle(Geom2d_Curve)::DownCast(T1->BasisCurve()); + basisC1 = T1->BasisCurve(); else - basisC1 = Handle(Geom2d_Curve)::DownCast(C1); + basisC1 = C1; Handle(Geom2d_TrimmedCurve) T2 = Handle(Geom2d_TrimmedCurve)::DownCast(C2); if (!T2.IsNull()) - basisC2 = Handle(Geom2d_Curve)::DownCast(T2->BasisCurve()); + basisC2 = T2->BasisCurve(); else - basisC2 = Handle(Geom2d_Curve)::DownCast(C2); + basisC2 = C2; if (basisC1->DynamicType() == STANDARD_TYPE(Geom2d_Circle)) { Handle(Geom2d_Circle) CC1 = Handle(Geom2d_Circle)::DownCast(basisC1); @@ -1132,9 +1132,9 @@ Standard_Boolean IsLineOrCircle(const TopoDS_Edge& E, Handle(Geom2d_Curve) basisC; Handle(Geom2d_TrimmedCurve) TC = Handle(Geom2d_TrimmedCurve)::DownCast(C); if (!TC.IsNull()) - basisC = Handle(Geom2d_Curve)::DownCast(TC->BasisCurve()); + basisC = TC->BasisCurve(); else - basisC = Handle(Geom2d_Curve)::DownCast(C); + basisC = C; if ( basisC->DynamicType() == STANDARD_TYPE(Geom2d_Circle) || basisC->DynamicType() == STANDARD_TYPE(Geom2d_Line) ) { diff --git a/src/ChFi2d/ChFi2d_Builder_0.cxx b/src/ChFi2d/ChFi2d_Builder_0.cxx index a3d0c6e9aa..657ba0c6df 100644 --- a/src/ChFi2d/ChFi2d_Builder_0.cxx +++ b/src/ChFi2d/ChFi2d_Builder_0.cxx @@ -777,9 +777,9 @@ Standard_Boolean IsLineOrCircle(const TopoDS_Edge& E, Handle(Geom2d_Curve) basisC; Handle(Geom2d_TrimmedCurve) TC = Handle(Geom2d_TrimmedCurve)::DownCast(C); if (!TC.IsNull()) - basisC = Handle(Geom2d_Curve)::DownCast(TC->BasisCurve()); + basisC = TC->BasisCurve(); else - basisC = Handle(Geom2d_Curve)::DownCast(C); + basisC = C; if ( basisC->DynamicType() == STANDARD_TYPE(Geom2d_Circle) || basisC->DynamicType() == STANDARD_TYPE(Geom2d_Line) ) { diff --git a/src/DDocStd/DDocStd.cxx b/src/DDocStd/DDocStd.cxx index db28c4f908..31114a1b45 100644 --- a/src/DDocStd/DDocStd.cxx +++ b/src/DDocStd/DDocStd.cxx @@ -66,7 +66,7 @@ Standard_Boolean DDocStd::GetDocument (Standard_CString& Name, if (Complain) cout << Name << " is not a Document" << endl; return Standard_False; } - Handle(TDocStd_Document) STDDOC = Handle(TDocStd_Document)::DownCast(DD->GetDocument()); + Handle(TDocStd_Document) STDDOC = DD->GetDocument(); if (!STDDOC.IsNull()) { DOC = STDDOC; return Standard_True; diff --git a/src/DDocStd/DDocStd_DrawDocument.cxx b/src/DDocStd/DDocStd_DrawDocument.cxx index c0f1442cfe..51794e248c 100644 --- a/src/DDocStd/DDocStd_DrawDocument.cxx +++ b/src/DDocStd/DDocStd_DrawDocument.cxx @@ -83,7 +83,7 @@ Handle(Draw_Drawable3D) DDocStd_DrawDocument::Copy() const void DDocStd_DrawDocument::Dump (Standard_OStream& S) const { - Handle(TDocStd_Document) STDDOC = Handle(TDocStd_Document)::DownCast(myDocument); + Handle(TDocStd_Document) STDDOC = myDocument; if (!STDDOC.IsNull()) { S << "TDocStd_Document\n"; DDF_Data::Dump(S); diff --git a/src/DrawDim/DrawDim_PlanarDistance.cxx b/src/DrawDim/DrawDim_PlanarDistance.cxx index 4e09571940..301331682d 100644 --- a/src/DrawDim/DrawDim_PlanarDistance.cxx +++ b/src/DrawDim/DrawDim_PlanarDistance.cxx @@ -42,7 +42,7 @@ void DrawDim_PlanarDistance::Draw { Standard_Real f,l; Handle(Geom_Curve) line = BRep_Tool::Curve(edge,f,l); - GeomAPI_ProjectPointOnCurve pj (point,Handle(Geom_Curve)::DownCast(line)); + GeomAPI_ProjectPointOnCurve pj (point, line); if (pj.NbPoints() == 1) { gp_Pnt first = point; gp_Pnt last = pj.Point(1); diff --git a/src/Geom/Geom_OffsetSurface.cxx b/src/Geom/Geom_OffsetSurface.cxx index 9eda42ef14..ac6c3cd32b 100644 --- a/src/Geom/Geom_OffsetSurface.cxx +++ b/src/Geom/Geom_OffsetSurface.cxx @@ -685,7 +685,7 @@ Standard_Boolean Geom_OffsetSurface::IsUClosed () const Handle(Geom_RectangularTrimmedSurface) St = Handle(Geom_RectangularTrimmedSurface)::DownCast(SBasis); - Handle(Geom_Surface) S = Handle(Geom_Surface)::DownCast(St->BasisSurface()); + Handle(Geom_Surface) S = St->BasisSurface(); if (S->IsKind (STANDARD_TYPE(Geom_ElementarySurface))) { UClosed = SBasis->IsUClosed(); } @@ -737,7 +737,7 @@ Standard_Boolean Geom_OffsetSurface::IsVClosed () const Handle(Geom_RectangularTrimmedSurface) St = Handle(Geom_RectangularTrimmedSurface)::DownCast(SBasis); - Handle(Geom_Surface) S = Handle(Geom_Surface)::DownCast(St->BasisSurface()); + Handle(Geom_Surface) S = St->BasisSurface(); if (S->IsKind (STANDARD_TYPE(Geom_ElementarySurface))) { VClosed = SBasis->IsVClosed(); } diff --git a/src/Geom/Geom_RectangularTrimmedSurface.cxx b/src/Geom/Geom_RectangularTrimmedSurface.cxx index a024e31f71..fc2ba15b12 100644 --- a/src/Geom/Geom_RectangularTrimmedSurface.cxx +++ b/src/Geom/Geom_RectangularTrimmedSurface.cxx @@ -118,8 +118,7 @@ const Standard_Boolean VSense) { Handle(Geom_RectangularTrimmedSurface) S2 = new Geom_RectangularTrimmedSurface( O->BasisSurface(),U1,U2, V1, V2, USense, VSense); - Handle(Geom_OffsetSurface) OS = new Geom_OffsetSurface(S2, O->Offset()); - basisSurf = Handle(Geom_Surface)::DownCast(OS); + basisSurf = new Geom_OffsetSurface(S2, O->Offset()); } SetTrim( U1, U2, V1, V2, USense, VSense); @@ -154,8 +153,7 @@ Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface ( { Handle(Geom_RectangularTrimmedSurface) S2 = new Geom_RectangularTrimmedSurface( O->BasisSurface(),Param1,Param2, UTrim, Sense); - Handle(Geom_OffsetSurface) OS = new Geom_OffsetSurface(S2, O->Offset()); - basisSurf = Handle(Geom_Surface)::DownCast(OS); + basisSurf = new Geom_OffsetSurface(S2, O->Offset()); } SetTrim(Param1, Param2, UTrim, Sense); diff --git a/src/Geom2dConvert/Geom2dConvert.cxx b/src/Geom2dConvert/Geom2dConvert.cxx index 9a7208c7bd..8b952ac081 100644 --- a/src/Geom2dConvert/Geom2dConvert.cxx +++ b/src/Geom2dConvert/Geom2dConvert.cxx @@ -1112,7 +1112,7 @@ void Geom2dConvert::ConcatG1(TColGeom2d_Array1OfBSplineCurve& ArrayOf NewPoles(ii).SetCoord(jj,NewPoles(ii).Coord(jj)/NewWeights(ii)); Curve1= new Geom2d_BSplineCurve(NewPoles,NewWeights,KnotC1,KnotC1Mults,2*Curve1->Degree()); } - Geom2dConvert_CompCurveToBSplineCurve C(Handle(Geom2d_BSplineCurve)::DownCast(Curve2)); + Geom2dConvert_CompCurveToBSplineCurve C(Curve2); fusion=C.Add(Curve1, local_tolerance(j-1)); //fusion de deux courbes adjacentes if (fusion==Standard_False) @@ -1139,7 +1139,7 @@ void Geom2dConvert::ConcatG1(TColGeom2d_Array1OfBSplineCurve& ArrayOf if (index==j) //initialisation en debut de groupe ArrayOfConcatenated->SetValue(i,Curve1); else{ - Geom2dConvert_CompCurveToBSplineCurve C(Handle(Geom2d_BSplineCurve)::DownCast(ArrayOfConcatenated->Value(i))); + Geom2dConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(i)); fusion=C.Add(Curve1,ArrayOfToler(j-1)); //fusion de deux courbes adjacentes if (fusion==Standard_False) Standard_ConstructionError::Raise("Geom2dConvert Concatenation Error") ; @@ -1351,7 +1351,7 @@ void Geom2dConvert::ConcatC1(TColGeom2d_Array1OfBSplineCurve& ArrayOf } Curve1= new Geom2d_BSplineCurve(NewPoles,NewWeights,KnotC1,KnotC1Mults,2*Curve1->Degree()); } - Geom2dConvert_CompCurveToBSplineCurve C(Handle(Geom2d_BSplineCurve)::DownCast(Curve2)); + Geom2dConvert_CompCurveToBSplineCurve C(Curve2); fusion=C.Add(Curve1, local_tolerance(j-1)); //fusion de deux courbes adjacentes if (fusion==Standard_False) @@ -1395,7 +1395,7 @@ void Geom2dConvert::ConcatC1(TColGeom2d_Array1OfBSplineCurve& ArrayOf if (index==j) //initialisation en debut de groupe ArrayOfConcatenated->SetValue(i,Curve1); else{ - Geom2dConvert_CompCurveToBSplineCurve C(Handle(Geom2d_BSplineCurve)::DownCast(ArrayOfConcatenated->Value(i))); + Geom2dConvert_CompCurveToBSplineCurve C (ArrayOfConcatenated->Value(i)); fusion=C.Add(Curve1,ArrayOfToler(j-1)); //fusion de deux courbes adjacentes if (fusion==Standard_False) Standard_ConstructionError::Raise("Geom2dConvert Concatenation Error") ; @@ -1469,8 +1469,7 @@ void Geom2dConvert::C0BSplineToC1BSplineCurve(Handle(Geom2d_BSplineCurve)& BS, closed_flag, tolerance); - Geom2dConvert_CompCurveToBSplineCurve - C(Handle(Geom2d_BSplineCurve)::DownCast(ArrayOfConcatenated->Value(0))); + Geom2dConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(0)); if (ArrayOfConcatenated->Length()>=2){ for (i=1;iLength();i++){ fusion=C.Add(ArrayOfConcatenated->Value(i),tolerance); diff --git a/src/GeomAdaptor/GeomAdaptor_Surface.cxx b/src/GeomAdaptor/GeomAdaptor_Surface.cxx index 11723d6bce..dc479ccb5d 100644 --- a/src/GeomAdaptor/GeomAdaptor_Surface.cxx +++ b/src/GeomAdaptor/GeomAdaptor_Surface.cxx @@ -161,11 +161,10 @@ void GeomAdaptor_Surface::load(const Handle(Geom_Surface)& S, Handle(Geom_SurfaceOfRevolution)::DownCast(mySurface); // Create nested adaptor for base curve Handle(Geom_Curve) aBaseCurve = myRevSurf->BasisCurve(); - Handle(GeomAdaptor_HCurve) aBaseAdaptor = new GeomAdaptor_HCurve(aBaseCurve); + Handle(Adaptor3d_HCurve) aBaseAdaptor = new GeomAdaptor_HCurve(aBaseCurve); // Create corresponding evaluator - myNestedEvaluator = new GeomEvaluator_SurfaceOfRevolution( - Handle(Adaptor3d_HCurve)::DownCast(aBaseAdaptor), - myRevSurf->Direction(), myRevSurf->Location()); + myNestedEvaluator = + new GeomEvaluator_SurfaceOfRevolution (aBaseAdaptor, myRevSurf->Direction(), myRevSurf->Location()); } else if ( TheType == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) { @@ -174,10 +173,10 @@ void GeomAdaptor_Surface::load(const Handle(Geom_Surface)& S, Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(mySurface); // Create nested adaptor for base curve Handle(Geom_Curve) aBaseCurve = myExtSurf->BasisCurve(); - Handle(GeomAdaptor_HCurve) aBaseAdaptor = new GeomAdaptor_HCurve(aBaseCurve); + Handle(Adaptor3d_HCurve) aBaseAdaptor = new GeomAdaptor_HCurve(aBaseCurve); // Create corresponding evaluator - myNestedEvaluator = new GeomEvaluator_SurfaceOfExtrusion( - Handle(Adaptor3d_HCurve)::DownCast(aBaseAdaptor), myExtSurf->Direction()); + myNestedEvaluator = + new GeomEvaluator_SurfaceOfExtrusion (aBaseAdaptor, myExtSurf->Direction()); } else if (TheType == STANDARD_TYPE(Geom_BezierSurface)) { diff --git a/src/GeomConvert/GeomConvert.cxx b/src/GeomConvert/GeomConvert.cxx index e1316415e2..10d59c8437 100644 --- a/src/GeomConvert/GeomConvert.cxx +++ b/src/GeomConvert/GeomConvert.cxx @@ -937,7 +937,7 @@ private: NewPoles(ii).SetCoord(jj,NewPoles(ii).Coord(jj)/NewWeights(ii)); Curve1= new Geom_BSplineCurve(NewPoles,NewWeights,KnotC1,KnotC1Mults,2*Curve1->Degree()); } - GeomConvert_CompCurveToBSplineCurve C(Handle(Geom_BSplineCurve)::DownCast(Curve2)); + GeomConvert_CompCurveToBSplineCurve C (Curve2); fusion=C.Add(Curve1, local_tolerance(j-1)); //merge of two consecutive curves if (fusion==Standard_False) @@ -964,7 +964,7 @@ private: if (index==j) //initialisation at the begining of the loop ArrayOfConcatenated->SetValue(i,Curve1); else{ - GeomConvert_CompCurveToBSplineCurve C(Handle(Geom_BSplineCurve)::DownCast(ArrayOfConcatenated->Value(i))); + GeomConvert_CompCurveToBSplineCurve C (ArrayOfConcatenated->Value(i)); fusion=C.Add(Curve1,ArrayOfToler(j-1)); //merge of two consecutive curves if (fusion==Standard_False) Standard_ConstructionError::Raise("GeomConvert Concatenation Error") ; @@ -1172,7 +1172,7 @@ void GeomConvert::ConcatC1(TColGeom_Array1OfBSplineCurve& ArrayOfCurv NewPoles(ii).SetCoord(jj,NewPoles(ii).Coord(jj)/NewWeights(ii)); Curve1= new Geom_BSplineCurve(NewPoles,NewWeights,KnotC1,KnotC1Mults,2*Curve1->Degree()); } - GeomConvert_CompCurveToBSplineCurve C(Handle(Geom_BSplineCurve)::DownCast(Curve2)); + GeomConvert_CompCurveToBSplineCurve C (Curve2); fusion=C.Add(Curve1, local_tolerance(j-1)); //merge of two consecutive curves if (fusion==Standard_False) @@ -1218,7 +1218,7 @@ void GeomConvert::ConcatC1(TColGeom_Array1OfBSplineCurve& ArrayOfCurv else { // Merge of two consecutive curves. - GeomConvert_CompCurveToBSplineCurve C(Handle(Geom_BSplineCurve)::DownCast(ArrayOfConcatenated->Value(i))); + GeomConvert_CompCurveToBSplineCurve C (ArrayOfConcatenated->Value(i)); fusion=C.Add(Curve1, local_tolerance(j-1), Standard_True); if (fusion==Standard_False) Standard_ConstructionError::Raise("GeomConvert Concatenation Error"); @@ -1246,8 +1246,7 @@ void GeomConvert::C0BSplineToC1BSplineCurve(Handle(Geom_BSplineCurve)& BS, GeomConvert::C0BSplineToArrayOfC1BSplineCurve(BS, ArrayOfConcatenated, AngularTol, tolerance); - GeomConvert_CompCurveToBSplineCurve C - (Handle(Geom_BSplineCurve)::DownCast(ArrayOfConcatenated->Value(0))); + GeomConvert_CompCurveToBSplineCurve C (ArrayOfConcatenated->Value(0)); if (ArrayOfConcatenated->Length()>=2){ Standard_Integer i; for (i=1;iLength();i++){ diff --git a/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx b/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx index 9bdd064423..80e41859c6 100644 --- a/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx +++ b/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx @@ -767,8 +767,7 @@ EcartContraintesMil ( const Standard_Integer c, } break; case 2 : - Handle(Geom_Surface) Splate; - Splate = Handle(Geom_Surface)::DownCast(myGeomPlateSurface); + Handle(Geom_Surface) Splate (myGeomPlateSurface); LocalAnalysis_SurfaceContinuity CG2; for (i=1; iValue(c).Value(i) + @@ -2532,8 +2531,7 @@ void GeomPlate_BuildPlateSurface:: Ang = M_PI -Ang; break; case 2 : - Handle(Geom_Surface) Splate; - Splate = Handle(Geom_Surface)::DownCast(myGeomPlateSurface); + Handle(Geom_Surface) Splate (myGeomPlateSurface); LocalAnalysis_SurfaceContinuity CG2; P2d = PntCont->Pnt2dOnSurf(); GeomLProp_SLProps Prop (Splate, P2d.Coord(1), P2d.Coord(2), diff --git a/src/GeomliteTest/GeomliteTest_CurveCommands.cxx b/src/GeomliteTest/GeomliteTest_CurveCommands.cxx index 9325f31f70..180bae2373 100644 --- a/src/GeomliteTest/GeomliteTest_CurveCommands.cxx +++ b/src/GeomliteTest/GeomliteTest_CurveCommands.cxx @@ -1751,7 +1751,7 @@ static Standard_Integer splitc12d(Draw_Interpretor& di, tolerance=Draw::Atof(c[3]); if (n==5) angular_tolerance = Draw::Atof(c[4]) ; - Handle(Geom2d_Curve) ACurve = Handle(Geom2d_Curve)::DownCast(DrawTrSurf::GetCurve2d(c[1])) ; + Handle(Geom2d_Curve) ACurve = DrawTrSurf::GetCurve2d(c[1]); Standard_Real f = ACurve->FirstParameter(); Standard_Real l = ACurve->LastParameter(); @@ -1805,7 +1805,7 @@ static Standard_Integer canceldenom(Draw_Interpretor& , udirection=Standard_True; if (voption) vdirection=Standard_True; - Handle(Geom_BSplineSurface) BSurf = Handle(Geom_BSplineSurface)::DownCast(DrawTrSurf::GetBSplineSurface(c[1])); + Handle(Geom_BSplineSurface) BSurf = DrawTrSurf::GetBSplineSurface(c[1]); GeomLib::CancelDenominatorDerivative(BSurf,udirection,vdirection); DrawTrSurf::Set(c[1],BSurf); return 0; diff --git a/src/IGESAppli/IGESAppli_Node.cxx b/src/IGESAppli/IGESAppli_Node.cxx index 4cae056c65..4ba0822c03 100644 --- a/src/IGESAppli/IGESAppli_Node.cxx +++ b/src/IGESAppli/IGESAppli_Node.cxx @@ -47,7 +47,7 @@ IGESAppli_Node::IGESAppli_Node () { } Handle(IGESData_TransfEntity) IGESAppli_Node::System () const { //if Null, Global Cartesian Coordinate System - return GetCasted(IGESData_TransfEntity,theSystem); + return Handle(IGESData_TransfEntity)(theSystem); } Standard_Integer IGESAppli_Node::SystemType () const diff --git a/src/IGESControl/IGESControl_IGESBoundary.cxx b/src/IGESControl/IGESControl_IGESBoundary.cxx index 9ba8c9c856..557900147d 100644 --- a/src/IGESControl/IGESControl_IGESBoundary.cxx +++ b/src/IGESControl/IGESControl_IGESBoundary.cxx @@ -236,8 +236,7 @@ static Standard_Boolean Connect (const Handle(ShapeAnalysis_Wire)& theSAW, } else if (!GTranslate3d && GTranslate2d) { for (Standard_Integer i = curves2d->Lower(); i <= curves2d->Upper(); i++) { - TopoDS_Shape Sh = TC.Transfer2dTopoCurve (Handle(IGESData_IGESEntity)::DownCast (curves2d->Value (i)), - myface, mytrsf, myuFact); + TopoDS_Shape Sh = TC.Transfer2dTopoCurve (curves2d->Value (i), myface, mytrsf, myuFact); if (!Sh.IsNull()) Gsewd2d->Add (Sh); } if (toreverse2d) { diff --git a/src/IGESSelect/IGESSelect.cxx b/src/IGESSelect/IGESSelect.cxx index 759ad05d8a..6ce03026bf 100644 --- a/src/IGESSelect/IGESSelect.cxx +++ b/src/IGESSelect/IGESSelect.cxx @@ -41,7 +41,7 @@ Standard_Integer IGESSelect::WhatIges (const Handle(IGESData_IGESEntity)& ent, const Interface_Graph& G, Handle(IGESData_IGESEntity)& /* sup */, Standard_Integer& /* index */) { - DeclareAndCast(IGESData_IGESEntity,igesent,ent); + Handle(IGESData_IGESEntity) igesent = ent; if (igesent.IsNull()) return Standard_False; // Standard_Integer igt = igesent->TypeNumber(); DeclareAndCast(IGESData_IGESModel,model,G.Model()); diff --git a/src/IGESToBRep/IGESToBRep_IGESBoundary.cxx b/src/IGESToBRep/IGESToBRep_IGESBoundary.cxx index 3dc90d40f5..b6f023acf4 100644 --- a/src/IGESToBRep/IGESToBRep_IGESBoundary.cxx +++ b/src/IGESToBRep/IGESToBRep_IGESBoundary.cxx @@ -201,8 +201,7 @@ IGESToBRep_IGESBoundary::IGESToBRep_IGESBoundary(const IGESToBRep_CurveAndSurfac } else if (!GTranslate3d && GTranslate2d) { for (Standard_Integer i = curves2d->Lower(); i <= curves2d->Upper(); i++) { - TopoDS_Shape Sh = TC.Transfer2dTopoCurve (Handle(IGESData_IGESEntity)::DownCast (curves2d->Value (i)), - myface, mytrsf, myuFact); + TopoDS_Shape Sh = TC.Transfer2dTopoCurve (curves2d->Value (i), myface, mytrsf, myuFact); if (!Sh.IsNull()) Gsewd2d->Add (Sh); } if (toreverse2d) diff --git a/src/IVtkDraw/IVtkDraw_HighlightAndSelectionPipeline.cxx b/src/IVtkDraw/IVtkDraw_HighlightAndSelectionPipeline.cxx index f2275f308e..e6a05975c7 100644 --- a/src/IVtkDraw/IVtkDraw_HighlightAndSelectionPipeline.cxx +++ b/src/IVtkDraw/IVtkDraw_HighlightAndSelectionPipeline.cxx @@ -57,7 +57,7 @@ IVtkDraw_HighlightAndSelectionPipeline::IVtkDraw_HighlightAndSelectionPipeline ( IVtkOCC_Shape::Handle anIVtkShape = new IVtkOCC_Shape (theShape); anIVtkShape->SetId (theShapeID); vtkSmartPointer aDataSource = vtkSmartPointer::New(); - aDataSource->SetShape (IVtkOCC_Shape::Handle::DownCast (anIVtkShape) ); + aDataSource->SetShape (anIVtkShape); IVtkTools_DisplayModeFilter* aDMFilter = IVtkTools_DisplayModeFilter::SafeDownCast (myFilterMap.Find(Filter_DM_Shape)); diff --git a/src/IntPatch/IntPatch_Intersection.cxx b/src/IntPatch/IntPatch_Intersection.cxx index c557f70930..d5e6296a72 100644 --- a/src/IntPatch/IntPatch_Intersection.cxx +++ b/src/IntPatch/IntPatch_Intersection.cxx @@ -554,10 +554,8 @@ static void FUN_PL_Intersection(const Handle(Adaptor3d_HSurface)& S1, Handle(Geom_Curve) C2Prj = GeomProjLib::ProjectOnPlane(C2,GPln,gp_Dir(DV),Standard_True); if(C1Prj.IsNull() || C2Prj.IsNull()) return; - Handle(Geom2d_Curve) C1Prj2d = - GeomProjLib::Curve2d(C1Prj,Handle(Geom_Surface)::DownCast (GPln)); - Handle(Geom2d_Curve) C2Prj2d = - GeomProjLib::Curve2d(C2Prj,Handle(Geom_Surface)::DownCast (GPln)); + Handle(Geom2d_Curve) C1Prj2d = GeomProjLib::Curve2d (C1Prj,GPln); + Handle(Geom2d_Curve) C2Prj2d = GeomProjLib::Curve2d (C2Prj,GPln); Geom2dAPI_InterCurveCurve ICC(C1Prj2d,C2Prj2d,1.0e-7); if(ICC.NbPoints() > 0 ) { @@ -1286,8 +1284,8 @@ void IntPatch_Intersection::ParamParamPerfom(const Handle(Adaptor3d_HSurface)& for(Standard_Integer ip = 1; ip <= sop.Length(); ip++) { gp_Lin lin(sop.Value(ip),gp_Dir(v)); - Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False); - slin.Append(Handle(IntPatch_Line)::DownCast (gl)); + Handle(IntPatch_Line) gl = new IntPatch_GLine(lin,Standard_False); + slin.Append(gl); } done = Standard_True; @@ -1470,8 +1468,8 @@ void IntPatch_Intersection:: for(Standard_Integer ip = 1; ip <= sop.Length(); ip++) { gp_Lin lin(sop.Value(ip),gp_Dir(v)); - Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False); - slin.Append(Handle(IntPatch_Line)::DownCast (gl)); + Handle(IntPatch_Line) gl = new IntPatch_GLine(lin,Standard_False); + slin.Append(gl); } done = Standard_True; diff --git a/src/MAT2d/MAT2d_Tool2d.cxx b/src/MAT2d/MAT2d_Tool2d.cxx index f3d8c16801..96e6e84856 100644 --- a/src/MAT2d/MAT2d_Tool2d.cxx +++ b/src/MAT2d/MAT2d_Tool2d.cxx @@ -503,9 +503,8 @@ Standard_Boolean MAT2d_Tool2d::TrimBisector if (Affich) cout<<"TRIM de "<BisectorNumber()<BisectorNumber()).ChangeValue()); + Handle(Geom2d_TrimmedCurve) bisector = + ChangeGeomBis(abisector->BisectorNumber()).ChangeValue(); if(bisector->BasisCurve()->IsPeriodic() && param == Precision::Infinite()) { param = bisector->FirstParameter() + 2*M_PI; @@ -528,9 +527,8 @@ Standard_Boolean MAT2d_Tool2d::TrimBisector const Standard_Integer apoint) { Standard_Real Param; - Handle(Geom2d_TrimmedCurve) - Bisector = Handle(Geom2d_TrimmedCurve):: - DownCast(ChangeGeomBis(abisector->BisectorNumber()).ChangeValue()); + Handle(Geom2d_TrimmedCurve) Bisector = + ChangeGeomBis(abisector->BisectorNumber()).ChangeValue(); Handle(Bisector_Curve) Bis = Handle(Bisector_Curve):: DownCast(Bisector->BasisCurve()); @@ -763,13 +761,11 @@ Standard_Real MAT2d_Tool2d::IntersectBisector ( Standard_Boolean SolutionValide; gp_Pnt2d PointSolution; - Handle(Geom2d_TrimmedCurve) - Bisector1 = Handle(Geom2d_TrimmedCurve) - ::DownCast(ChangeGeomBis(BisectorOne->BisectorNumber()).ChangeValue()); + Handle(Geom2d_TrimmedCurve) Bisector1 = + ChangeGeomBis(BisectorOne->BisectorNumber()).ChangeValue(); - Handle(Geom2d_TrimmedCurve) - Bisector2 = Handle(Geom2d_TrimmedCurve) - ::DownCast(ChangeGeomBis(BisectorTwo->BisectorNumber()).ChangeValue()); + Handle(Geom2d_TrimmedCurve) Bisector2 = + ChangeGeomBis(BisectorTwo->BisectorNumber()).ChangeValue(); if(Bisector1.IsNull() || Bisector2.IsNull()) return Precision::Infinite(); @@ -1159,8 +1155,8 @@ void MAT2d_Tool2d::BisecFusion(const Standard_Integer I1, Handle(Geom2d_TrimmedCurve) Bisector1; Handle(Geom2d_TrimmedCurve) Bisector2; - Bisector1 = Handle(Geom2d_TrimmedCurve)::DownCast(GeomBis(I1).Value()); - Bisector2 = Handle(Geom2d_TrimmedCurve)::DownCast(GeomBis(I2).Value()); + Bisector1 = GeomBis(I1).Value(); + Bisector2 = GeomBis(I2).Value(); UF1 = Bisector1->FirstParameter(); UL1 = Bisector1->LastParameter(); @@ -1184,7 +1180,7 @@ void MAT2d_Tool2d::BisecFusion(const Standard_Integer I1, Bis.Perform(BCC1->Curve(2), BCC1->Curve(1), P2, VBid, VBid, theDirection, theJoinType, Tolerance, Standard_False); - Bisector1 = Handle(Geom2d_TrimmedCurve)::DownCast(Bis.Value()); + Bisector1 = Bis.Value(); BCC1 = Handle(Bisector_BisecCC) ::DownCast(Bisector1->BasisCurve()); UF1 = BCC1->FirstParameter(); UL1 = BCC1->Parameter(P1); @@ -1246,8 +1242,7 @@ static void SetTrim(Bisector_Bisec& Bis, const Handle(Geom2d_Curve)& Line1) Geom2dInt_GInter Intersect; Standard_Real Distance; Standard_Real Tolerance = MAT2d_TOLCONF; - Handle(Geom2d_TrimmedCurve) Bisector = - Handle(Geom2d_TrimmedCurve)::DownCast(Bis.ChangeValue()); + Handle(Geom2d_TrimmedCurve) Bisector = Bis.ChangeValue(); IntRes2d_Domain Domain1 = Domain(Bisector,Tolerance); Standard_Real UB1 = Bisector->FirstParameter(); diff --git a/src/Message/Message_Messenger.cxx b/src/Message/Message_Messenger.cxx index 3f7e4d658e..ec95858d80 100644 --- a/src/Message/Message_Messenger.cxx +++ b/src/Message/Message_Messenger.cxx @@ -105,7 +105,7 @@ void Message_Messenger::Send (const Standard_CString theString, Standard_Integer nb = myPrinters.Length(); for (Standard_Integer i = 1; i <= nb; i++) { - Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) ); + Handle(Message_Printer) aPrinter = myPrinters(i); if ( ! aPrinter.IsNull() ) aPrinter->Send ( theString, theGravity, putEndl ); } @@ -123,7 +123,7 @@ void Message_Messenger::Send (const TCollection_AsciiString& theString, Standard_Integer nb = myPrinters.Length(); for (Standard_Integer i = 1; i <= nb; i++) { - Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) ); + Handle(Message_Printer) aPrinter = myPrinters(i); if ( ! aPrinter.IsNull() ) aPrinter->Send ( theString, theGravity, putEndl ); } @@ -141,7 +141,7 @@ void Message_Messenger::Send (const TCollection_ExtendedString& theString, Standard_Integer nb = myPrinters.Length(); for (Standard_Integer i = 1; i <= nb; i++) { - Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) ); + Handle(Message_Printer) aPrinter = myPrinters(i); if ( ! aPrinter.IsNull() ) aPrinter->Send ( theString, theGravity, putEndl ); } diff --git a/src/QABugs/QABugs_PresentableObject.cxx b/src/QABugs/QABugs_PresentableObject.cxx index a77c79da8a..6dff125d49 100644 --- a/src/QABugs/QABugs_PresentableObject.cxx +++ b/src/QABugs/QABugs_PresentableObject.cxx @@ -38,7 +38,7 @@ void QABugs_PresentableObject::Compute(const Handle(PrsMgr_PresentationManager3d const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) { - Handle(Graphic3d_Structure) aStructure = Handle(Graphic3d_Structure)::DownCast (thePrs); + Handle(Graphic3d_Structure) aStructure (thePrs); Handle(Graphic3d_Group) aGroup = aStructure->NewGroup(); Handle(Prs3d_ShadingAspect) anAspect = myDrawer->ShadingAspect(); Graphic3d_MaterialAspect aMat = anAspect->Aspect()->FrontMaterial(); diff --git a/src/QANCollection/QANCollection_Handle.cxx b/src/QANCollection/QANCollection_Handle.cxx index df52bb17c2..4711261562 100644 --- a/src/QANCollection/QANCollection_Handle.cxx +++ b/src/QANCollection/QANCollection_Handle.cxx @@ -220,7 +220,7 @@ static Standard_Integer QAHandleBool (Draw_Interpretor& theDI, Handle(NCollection_IncAllocator) anInc = Handle(NCollection_IncAllocator)::DownCast (aPtr); CHECK (theDI, ! anInc.IsNull(), "cast to NCollection_IncAllocator"); - Handle(NCollection_BaseAllocator) anAlloc = Handle(NCollection_BaseAllocator)::DownCast (aPtr); + Handle(NCollection_BaseAllocator) anAlloc = aPtr; CHECK (theDI, ! anAlloc.IsNull(), "cast to NCollection_BaseAllocator"); Handle(NCollection_HeapAllocator) aHAlloc = Handle(NCollection_HeapAllocator)::DownCast (aPtr); @@ -423,178 +423,6 @@ static Standard_Integer QAHandleInc (Draw_Interpretor& theDI, return 0; } -namespace -{ - //! Auxiliary class to perform casting to specified type. - template struct QACast - { - //! Perform casting using OCCT DownCast() operation. - template - static void doDownCast (Draw_Interpretor& theDI, - const Standard_Integer theNbIters, - const TFrom& theHandle) - { - std::vector aHandles (theNbIters); - { - QATimer aTimer (theDI, " ", QATimer::ns, theNbIters); - for (Standard_Integer anIter = 0; anIter < theNbIters; ++anIter) - { - aHandles[anIter] = TTo::DownCast (theHandle); - } - } - } - - //! Perform casting using standard C++ dynamic_cast<> operation. - template - static void doDynamicCast (Draw_Interpretor& theDI, - const Standard_Integer theNbIters, - const TFrom& theHandle) - { - std::vector aPointers (theNbIters); - { - QATimer aTimer (theDI, " ", QATimer::ns, theNbIters); - for (Standard_Integer anIter = 0; anIter < theNbIters; ++anIter) - { - aPointers[anIter] = dynamic_cast (theHandle.operator->()); - } - } - } - - //! Perform dynamic casting using shared_ptr::dynamic_pointer_cast operation. - template - static void doShareCast (Draw_Interpretor& theDI, - const Standard_Integer theNbIters, - const std::shared_ptr& theSharePtr) - { - std::vector< std::shared_ptr > aSharePointers (theNbIters); - { - QATimer aTimer (theDI, " ", QATimer::ns, theNbIters); - for (Standard_Integer anIter = 0; anIter < theNbIters; ++anIter) - { - aSharePointers[anIter] = std::dynamic_pointer_cast (theSharePtr); - } - } - } - - }; - - template - static void qaCastAs (Draw_Interpretor& theDI, - const qaclass00_50& theInst, - const Standard_Integer theNbIters) - { - #define QA_TEST_CAST10(theTens, theDoCast) \ - QACast::theDoCast(theDI, theNbIters, aPtr); \ - QACast::theDoCast(theDI, theNbIters, aPtr); - - typedef typename TAs::element_type aPtrType; - TAs aDummy (new aPtrType()); - theDI << "Making a pointer:\n"; - theDI << aDummy->DynamicType()->Name() << "* ptr = new " << theInst.DynamicType()->Name() << "\n"; - theDI << "then measuring the time of casting it to base classes from qaclass00_50 to qaclass50_50, ns\n"; - if (!theInst.IsKind (aDummy->DynamicType())) - { - return; - } - - theDI << "\nOCCT Handle: "; - { - TAs aPtr ((typename TAs::element_type* )theInst.Clone()); - QA_TEST_CAST10(0, doDownCast); - QA_TEST_CAST10(1, doDownCast); - QA_TEST_CAST10(2, doDownCast); - QA_TEST_CAST10(3, doDownCast); - QA_TEST_CAST10(4, doDownCast); - QACast::doDownCast(theDI, theNbIters, aPtr); - } - theDI << "\nC++ dynamic_cast: "; - { - TAs aPtr ((typename TAs::element_type* )theInst.Clone()); - QA_TEST_CAST10(0, doDynamicCast); - QA_TEST_CAST10(1, doDynamicCast); - QA_TEST_CAST10(2, doDynamicCast); - QA_TEST_CAST10(3, doDynamicCast); - QA_TEST_CAST10(4, doDynamicCast); - QACast::doDynamicCast(theDI, theNbIters, aPtr); - } - theDI << "\nC++ dynamic_pointer_cast: "; - { - std::shared_ptr aPtr ((typename TAs::element_type* )theInst.Clone()); - QA_TEST_CAST10(0, doShareCast); - QA_TEST_CAST10(1, doShareCast); - QA_TEST_CAST10(2, doShareCast); - QA_TEST_CAST10(3, doShareCast); - QA_TEST_CAST10(4, doShareCast); - QACast::doShareCast(theDI, theNbIters, aPtr); - } - } - -} - -//======================================================================= -//function : QAHandleCast -//purpose : Estimate performance of RTTI mechanisms - dynamic type casting -//======================================================================= -static Standard_Integer QAHandleCast (Draw_Interpretor& theDI, - Standard_Integer theArgNb, - const char** theArgVec) -{ - if (theArgNb > 4) - { - std::cout << "Error: wrong syntax! See usage:\n"; - theDI.PrintHelp (theArgVec[0]); - return 1; - } - Standard_Integer anArgIter = 0; - const Standard_Integer anInst = (++anArgIter < theArgNb) ? Draw::Atoi (theArgVec[anArgIter]) : 50; - const Standard_Integer aPtrTo = (++anArgIter < theArgNb) ? Draw::Atoi (theArgVec[anArgIter]) : 0; - const Standard_Integer aNbIters = (++anArgIter < theArgNb) ? Draw::Atoi (theArgVec[anArgIter]) : 1000000; - - if (aNbIters < 1) - { - std::cout << "Error: number of iterations (" << aNbIters << ") should be positive!\n"; - return 1; - } - if (anInst > 50 || anInst < 0) - { - std::cout << "Error: class instance (" << anInst << ") should be specified within 0..50 range!\n"; - return 1; - } - if (aPtrTo > anInst || aPtrTo < 0) - { - std::cout << "Error: class pointer (" << aPtrTo << ") should be specified within 0.." << anInst << " range!\n"; - return 1; - } - else if (aPtrTo % 10 != 0) - { - std::cout << "Error: class pointer (" << aPtrTo << ") should be multiple of 10!\n"; - return 1; - } - - Handle(qaclass00_50) aHandle = new qaclass50_50(); - for (Standard_Integer anInstIter = 50 - anInst; anInstIter > 0; --anInstIter) - { - Handle(Standard_Transient) aParent (aHandle->CreateParent()); - aHandle = Handle(qaclass00_50)::DownCast (aParent); - } - - std::ios::fmtflags aFlags = std::cout.flags(); - std::cout.precision (5); - - switch (aPtrTo) - { - // vc11 requires /bigobj option - case 0: qaCastAs(theDI, *aHandle, aNbIters); break; - case 10: qaCastAs(theDI, *aHandle, aNbIters); break; - case 20: qaCastAs(theDI, *aHandle, aNbIters); break; - case 30: qaCastAs(theDI, *aHandle, aNbIters); break; - case 40: qaCastAs(theDI, *aHandle, aNbIters); break; - case 50: qaCastAs(theDI, *aHandle, aNbIters); break; - } - std::cout.setf (aFlags); - return 0; -} - //======================================================================= //function : QAHandleKind //purpose : @@ -692,12 +520,6 @@ void QANCollection::CommandsHandle (Draw_Interpretor& theCommands) "QAHandleInc nbIter=1000000" "\n\t\t: Test handle increment performance", __FILE__, QAHandleInc, THE_GROUP); - theCommands.Add ("QAHandleCast", - "QAHandleCast [instance=50 [pointerTo=0 [nbIter=1000000]]]" - "\n\t\t: Test handle DownCast performance." - "\n\t\t: instance - specifies the depth of instantiated class" - "\n\t\t: pointerTo - specifies the depth of pointer class, where instance is stored into", - __FILE__, QAHandleCast, THE_GROUP); theCommands.Add ("QAHandleKind", "Test handle IsKind", __FILE__, QAHandleKind, THE_GROUP); diff --git a/src/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.cxx b/src/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.cxx index 63d4a18391..f38d385d67 100644 --- a/src/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.cxx +++ b/src/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.cxx @@ -335,8 +335,7 @@ void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::Check const Interface_ShareTool& aShto, Handle(Interface_Check)& ach) const { - Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) aRationalBSC = - Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)::DownCast(ent); + Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) aRationalBSC = ent; Handle(StepGeom_BSplineCurveWithKnots) aBSCWK = aRationalBSC->BSplineCurveWithKnots(); RWStepGeom_RWBSplineCurveWithKnots t1; diff --git a/src/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx b/src/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx index 35116e3e5f..b1556526fa 100644 --- a/src/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx +++ b/src/RWStepGeom/RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface.cxx @@ -428,9 +428,7 @@ void RWStepGeom_RWBSplineSurfaceWithKnotsAndRationalBSplineSurface::Check const Interface_ShareTool& aShto, Handle(Interface_Check)& ach) const { - Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) aRationalBSS = - Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) - ::DownCast(ent); + Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) aRationalBSS = ent; Handle(StepGeom_BSplineSurfaceWithKnots) aBSSWK = aRationalBSS->BSplineSurfaceWithKnots(); RWStepGeom_RWBSplineSurfaceWithKnots t1; diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 16678048ee..ee7b30bd3f 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -1415,8 +1415,7 @@ static Standard_Boolean findNextSHUOlevel (const Handle(XSControl_WorkSession) & if (subSHUO.IsNull()) return Standard_False; - Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO = - Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subSHUO->NextUsage()); + Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO = subSHUO->NextUsage(); if (NUNAUO.IsNull()) return Standard_False; // Handle(Interface_InterfaceModel) Model = WS->Model(); @@ -1454,8 +1453,7 @@ static TDF_Label setSHUOintoDoc (const Handle(XSControl_WorkSession) &WS, // get upper usage NAUO from SHUO. Handle(StepRepr_NextAssemblyUsageOccurrence) UUNAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(SHUO->UpperUsage()); - Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO = - Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(SHUO->NextUsage()); + Handle(StepRepr_NextAssemblyUsageOccurrence) NUNAUO = SHUO->NextUsage(); if ( UUNAUO.IsNull() || NUNAUO.IsNull() ) { #ifdef OCCT_DEBUG cout << "Warning: " << __FILE__ <<": Upper_usage or Next_usage of styled SHUO is null. Skip it" << endl; @@ -1795,8 +1793,7 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat, Handle(StepRepr_ShapeAspectRelationship) SAR = Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterC.Value()); if(SAR.IsNull()) continue; - Handle(StepRepr_ShapeAspect) aS = - Handle(StepRepr_ShapeAspect)::DownCast(SAR->RelatedShapeAspect()); + Handle(StepRepr_ShapeAspect) aS = SAR->RelatedShapeAspect(); if(aS.IsNull()) continue; Interface_EntityIterator anIterSA = aGraph.Sharings(aS); for(anIterSA.Start(); anIterSA.More() && aPGISU.IsNull(); anIterSA.Next()) { @@ -1835,7 +1832,7 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat, Handle(StepRepr_RepresentationItem) aRI; for(Standard_Integer i = 1 ; i <= aPGISU->NbIdentifiedItem() && aRI.IsNull(); i++) { - aRI = Handle(StepRepr_RepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(i)); + aRI = aPGISU->IdentifiedItemValue(i); } if(aRI.IsNull()) continue; Standard_Integer index = aTP->MapIndex(aRI); @@ -1891,7 +1888,7 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat, = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value()); Handle(StepRepr_RepresentationItem) anItem; if(aPGISU->NbIdentifiedItem() > 0) { - anItem = Handle(StepRepr_RepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(1)); + anItem = aPGISU->IdentifiedItemValue(1); } if(anItem.IsNull()) continue; Standard_Integer anItemIndex = aTP->MapIndex(anItem); @@ -2059,8 +2056,7 @@ static Standard_Boolean readDatumsAP242(const Handle(Standard_Transient)& theEnt { for(Standard_Integer i = aDRCA->Lower(); i <= aDRCA->Upper(); i++) { - Handle(StepDimTol_DatumReferenceCompartment) aDRC - = Handle(StepDimTol_DatumReferenceCompartment)::DownCast(aDRCA->Value(i)); + Handle(StepDimTol_DatumReferenceCompartment) aDRC = aDRCA->Value(i); //gete modifiers Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModif = aDRC->Modifiers(); XCAFDimTolObjects_DatumModifiersSequence aXCAFModifiers; @@ -2328,8 +2324,7 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt, Handle(StepRepr_HArray1OfRepresentationItem) HARI = VR->ItemElement(); if(HARI.IsNull()) continue; if(HARI->Length()>0) { - Handle(StepRepr_RepresentationItem) RI1 = - Handle(StepRepr_RepresentationItem)::DownCast(HARI->Value(1)); + Handle(StepRepr_RepresentationItem) RI1 = HARI->Value(1); if(RI1.IsNull()) continue; if(RI1->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) { Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU = @@ -2344,8 +2339,7 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt, } } if(HARI->Length()>1) { - Handle(StepRepr_RepresentationItem) RI2 = - Handle(StepRepr_RepresentationItem)::DownCast(HARI->Value(2)); + Handle(StepRepr_RepresentationItem) RI2 = HARI->Value(2); if(RI2.IsNull()) continue; if(RI2->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) { Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU = @@ -2635,8 +2629,7 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt, { for(Standard_Integer nr = aHARI->Lower(); nr <= aHARI->Upper(); nr++) { - Handle(StepRepr_RepresentationItem) aDRI = - Handle(StepRepr_RepresentationItem)::DownCast(aHARI->Value(nr)); + Handle(StepRepr_RepresentationItem) aDRI = aHARI->Value(nr); if(aDRI.IsNull()) continue; if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) { diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index b9ab6305c7..d502b2dfd8 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -949,8 +949,7 @@ static Standard_Boolean getStyledItem(const TopoDS_Shape& S, for (Standard_Integer jsi = 1; jsi <= aSelItm->NbStyles() && !found; jsi++) { - Handle(StepVisual_PresentationStyleAssignment) aFatherPSA = - Handle(StepVisual_PresentationStyleAssignment)::DownCast(aSelItm->StylesValue(jsi)); + Handle(StepVisual_PresentationStyleAssignment) aFatherPSA = aSelItm->StylesValue(jsi); // check for PSA for top-level (not Presentation style by contex for NAUO) if (aFatherPSA.IsNull() || aFatherPSA->IsKind(STANDARD_TYPE(StepVisual_PresentationStyleByContext))) continue; @@ -973,8 +972,7 @@ static Standard_Boolean setDefaultInstanceColor (const Handle(StepVisual_StyledI { Standard_Boolean found = Standard_False; for (Standard_Integer jsi = 1; jsi <= aSelItm->NbStyles() && !found; jsi++) { - Handle(StepVisual_PresentationStyleAssignment) aFatherPSA = - Handle(StepVisual_PresentationStyleAssignment)::DownCast(aSelItm->StylesValue(jsi)); + Handle(StepVisual_PresentationStyleAssignment) aFatherPSA = aSelItm->StylesValue(jsi); // check for PSA for top-level (not Presentation style by contex for NAUO) if (aFatherPSA.IsNull() || aFatherPSA->IsKind(STANDARD_TYPE(StepVisual_PresentationStyleByContext))) return Standard_False; @@ -1279,8 +1277,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work for ( si=1; si <= oldLengthlen; si++ ) newItems->SetValue( el++, oldItems->Value( si ) ); for ( si=1; si <= Styles.NbStyles(); si++ ) { - newItems->SetValue( el++, Handle(StepRepr_RepresentationItem)::DownCast(Styles.Style(si))); -// WP->Model()->AddWithRefs ( Handle(StepRepr_RepresentationItem)::DownCast (Styles.Style(si))); + newItems->SetValue( el++, Styles.Style(si)); } if (newItems->Length() > 0) @@ -1294,8 +1291,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work new StepVisual_HArray1OfInvisibleItem (1,Styles.NbStyles()); // put all style item into the harray for ( Standard_Integer si=1; si <= Styles.NbStyles(); si++ ) { - Handle(StepRepr_RepresentationItem) styledItm = - Handle(StepRepr_RepresentationItem)::DownCast(Styles.Style(si)); + Handle(StepRepr_RepresentationItem) styledItm = Styles.Style(si); StepVisual_InvisibleItem anInvItem; anInvItem.SetValue( styledItm ); HInvsblItm->SetValue( si, anInvItem ); @@ -1909,7 +1905,7 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style, Standard_Integer el = 1; for ( si=1; si <= oldLengthlen; si++ ) newItems->SetValue( el++, oldItems->Value( si ) ); - newItems->SetValue( el++, Handle(StepRepr_RepresentationItem)::DownCast(STEPstyle) ); + newItems->SetValue (el++, STEPstyle); // init MDGPR be new array of styled items if (newItems->Length() > 0) aMDGPR->SetItems( newItems ); @@ -2846,7 +2842,7 @@ static Handle(StepDimTol_HArray1OfDatumSystemOrReference) WriteDatumSystem(const StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition; aDefinition.SetValue(aDS); Handle(StepRepr_HArray1OfRepresentationItem) anReprItems = new StepRepr_HArray1OfRepresentationItem(1, 1); - Handle(StepRepr_RepresentationItem) anIdentifiedItem = Handle(StepRepr_RepresentationItem)::DownCast(anAxis); + Handle(StepRepr_RepresentationItem) anIdentifiedItem = anAxis; anReprItems->SetValue(1, anIdentifiedItem); Interface_EntityIterator subs = aGraph.Sharings(aFirstDatum->OfShape()); Handle(StepShape_ShapeDefinitionRepresentation) aSDR; diff --git a/src/STEPSelections/STEPSelections_Counter.cxx b/src/STEPSelections/STEPSelections_Counter.cxx index 8b0c88d762..ae2936c204 100644 --- a/src/STEPSelections/STEPSelections_Counter.cxx +++ b/src/STEPSelections/STEPSelections_Counter.cxx @@ -177,7 +177,7 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph, if (start->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) { DeclareAndCast(StepShape_ContextDependentShapeRepresentation,CDSR,start); - DeclareAndCast(StepRepr_RepresentationRelationship,SRR,CDSR->RepresentationRelation()); + Handle(StepRepr_RepresentationRelationship) SRR = CDSR->RepresentationRelation(); if ( SRR.IsNull() ) return ; Handle(StepRepr_Representation) rep; diff --git a/src/STEPSelections/STEPSelections_SelectInstances.cxx b/src/STEPSelections/STEPSelections_SelectInstances.cxx index ff263f27b7..bc4e8ea15a 100644 --- a/src/STEPSelections/STEPSelections_SelectInstances.cxx +++ b/src/STEPSelections/STEPSelections_SelectInstances.cxx @@ -102,7 +102,7 @@ static void AddInstances(const Handle(Standard_Transient)& start, if (start->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) { DeclareAndCast(StepShape_ContextDependentShapeRepresentation,CDSR,start); - DeclareAndCast(StepRepr_RepresentationRelationship,SRR,CDSR->RepresentationRelation()); + Handle(StepRepr_RepresentationRelationship) SRR = CDSR->RepresentationRelation(); if ( SRR.IsNull() ) return ; Handle(StepRepr_Representation) rep; diff --git a/src/SelectMgr/SelectMgr_SelectionManager.cxx b/src/SelectMgr/SelectMgr_SelectionManager.cxx index 0122caa87e..c24fd61ecc 100644 --- a/src/SelectMgr/SelectMgr_SelectionManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectionManager.cxx @@ -214,8 +214,7 @@ void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject SelectMgr_SequenceOfSelector& aSelectors = myLocal.ChangeFind (theObject); for (Standard_Integer aSelectorsIdx = 1; aSelectorsIdx <= aSelectors.Length(); aSelectorsIdx++) { - Handle(SelectMgr_ViewerSelector) aCurSelector = - Handle(SelectMgr_ViewerSelector)::DownCast (aSelectors (aSelectorsIdx)); + Handle(SelectMgr_ViewerSelector) aCurSelector = aSelectors (aSelectorsIdx); if (!aCurSelector->Contains (theObject)) continue; @@ -334,8 +333,7 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje SelectMgr_SequenceOfSelector& theSelectors = myLocal.ChangeFind (theObject); for (Standard_Integer aSelectorIdx = 1; aSelectorIdx <= theSelectors.Length(); aSelectorIdx++) { - Handle(SelectMgr_ViewerSelector) aCurSelector = - Handle(SelectMgr_ViewerSelector)::DownCast (theSelectors (aSelectorIdx)); + Handle(SelectMgr_ViewerSelector) aCurSelector = theSelectors (aSelectorIdx); Activate (theObject, theMode, aCurSelector); } } diff --git a/src/ShapeBuild/ShapeBuild_Edge.cxx b/src/ShapeBuild/ShapeBuild_Edge.cxx index 89e859a2ce..64aba8ad8d 100644 --- a/src/ShapeBuild/ShapeBuild_Edge.cxx +++ b/src/ShapeBuild/ShapeBuild_Edge.cxx @@ -553,7 +553,7 @@ Handle(Geom2d_Curve) ShapeBuild_Edge::TransformPCurve(const Handle(Geom2d_Curve) Geom2dConvert_ApproxCurve approx (tcurve, Precision::Approximation(), GeomAbs_C1, 100, 6 ); if ( approx.HasResult() ) - aBSpline2d = Handle(Geom2d_BSplineCurve)::DownCast(approx.Curve()); + aBSpline2d = approx.Curve(); else aBSpline2d = Geom2dConvert::CurveToBSplineCurve(tcurve,Convert_QuasiAngular); aFirst = aBSpline2d->FirstParameter(); diff --git a/src/ShapeConstruct/ShapeConstruct.cxx b/src/ShapeConstruct/ShapeConstruct.cxx index e165633b07..9e4f3a4c8d 100644 --- a/src/ShapeConstruct/ShapeConstruct.cxx +++ b/src/ShapeConstruct/ShapeConstruct.cxx @@ -84,7 +84,7 @@ Handle(Geom_BSplineCurve) ShapeConstruct::ConvertCurveToBSpline(const Handle(Geo OCC_CATCH_SIGNALS GeomConvert_ApproxCurve approx (tcurve, Tol3d, Continuity, MaxSegments, MaxDeg); if ( approx.HasResult() ) - aBSpline = Handle(Geom_BSplineCurve)::DownCast(approx.Curve()); + aBSpline = approx.Curve(); else aBSpline = GeomConvert::CurveToBSplineCurve(C3D,Convert_QuasiAngular); } @@ -117,7 +117,7 @@ Handle(Geom2d_BSplineCurve) ShapeConstruct::ConvertCurveToBSpline(const Handle(G Handle(Geom2d_Curve) tcurve = new Geom2d_TrimmedCurve(C2D,First,Last); //protection agains parabols ets Geom2dConvert_ApproxCurve approx (tcurve, Tol2d, Continuity, MaxSegments, MaxDegree); if ( approx.HasResult() ) - aBSpline2d = Handle(Geom2d_BSplineCurve)::DownCast(approx.Curve()); + aBSpline2d = approx.Curve(); else aBSpline2d = Geom2dConvert::CurveToBSplineCurve(tcurve,Convert_QuasiAngular); } @@ -248,7 +248,7 @@ Handle(Geom_BSplineSurface) ShapeConstruct::ConvertSurfaceToBSpline(const Handle } else { if(anApprox.HasResult()) - errSpl = Handle(Geom_BSplineSurface)::DownCast(anApprox.Surface()); + errSpl = anApprox.Surface(); #ifdef OCCT_DEBUG cout << "\terror = " << anApprox.MaxError() <SetContext ( Context() ); - Handle(ShapeFix_Wire) theAdvFixWire = Handle(ShapeFix_Wire)::DownCast(myFixWire); + Handle(ShapeFix_Wire) theAdvFixWire = myFixWire; if (theAdvFixWire.IsNull()) return Standard_False; BRep_Builder B; diff --git a/src/ShapeFix/ShapeFix_Shape.cxx b/src/ShapeFix/ShapeFix_Shape.cxx index 80dd61422b..a064c7a037 100644 --- a/src/ShapeFix/ShapeFix_Shape.cxx +++ b/src/ShapeFix/ShapeFix_Shape.cxx @@ -102,7 +102,7 @@ Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator) { Standard_Integer savFixSmallAreaWireMode = 0; Standard_Integer savFixVertexTolMode = myFixVertexTolMode; - Handle(ShapeFix_Face) fft = Handle(ShapeFix_Face)::DownCast( FixFaceTool() ); + Handle(ShapeFix_Face) fft = FixFaceTool(); if ( !fft.IsNull() ) { savFixSmallAreaWireMode = fft->FixSmallAreaWireMode(); if ( savFixSmallAreaWireMode == -1 && diff --git a/src/ShapeFix/ShapeFix_Wire.cxx b/src/ShapeFix/ShapeFix_Wire.cxx index d475e9129b..6d583648d6 100644 --- a/src/ShapeFix/ShapeFix_Wire.cxx +++ b/src/ShapeFix/ShapeFix_Wire.cxx @@ -535,7 +535,7 @@ Standard_Boolean ShapeFix_Wire::FixEdgeCurves() Handle(ShapeExtend_WireData) sbwd = WireData(); Standard_Integer i, nb = sbwd->NbEdges(); TopoDS_Face face = Face(); - Handle(ShapeFix_Edge) theAdvFixEdge = Handle(ShapeFix_Edge)::DownCast(myFixEdge); + Handle(ShapeFix_Edge) theAdvFixEdge = myFixEdge; if (theAdvFixEdge.IsNull()) myFixReversed2dMode = Standard_False; // fix revesred 2d / 3d curves @@ -1142,7 +1142,7 @@ Standard_Boolean ShapeFix_Wire::FixSmall (const Standard_Integer num, if ( ! IsLoaded() || NbEdges() <=1 ) return Standard_False; // analysis: - Handle(ShapeAnalysis_Wire) theAdvAnalyzer = Handle(ShapeAnalysis_Wire)::DownCast(myAnalyzer); + Handle(ShapeAnalysis_Wire) theAdvAnalyzer = myAnalyzer; if (theAdvAnalyzer.IsNull()) return Standard_False; Standard_Integer n = ( num >0 ? num : NbEdges() ); theAdvAnalyzer->CheckSmall ( n, precsmall ); @@ -2190,7 +2190,7 @@ Standard_Boolean ShapeFix_Wire::FixSelfIntersectingEdge (const Standard_Integer // analysis IntRes2d_SequenceOfIntersectionPoint points2d; TColgp_SequenceOfPnt points3d; - Handle(ShapeAnalysis_Wire) theAdvAnalyzer = Handle(ShapeAnalysis_Wire)::DownCast(myAnalyzer); + Handle(ShapeAnalysis_Wire) theAdvAnalyzer = myAnalyzer; if (theAdvAnalyzer.IsNull()) return Standard_False; theAdvAnalyzer->CheckSelfIntersectingEdge ( num, points2d, points3d ); if ( theAdvAnalyzer->LastCheckStatus ( ShapeExtend_FAIL ) ) { @@ -2385,7 +2385,7 @@ Standard_Boolean ShapeFix_Wire::FixIntersectingEdges (const Standard_Integer num IntRes2d_SequenceOfIntersectionPoint points2d; TColgp_SequenceOfPnt points3d; TColStd_SequenceOfReal errors; - Handle(ShapeAnalysis_Wire) theAdvAnalyzer = Handle(ShapeAnalysis_Wire)::DownCast(myAnalyzer); + Handle(ShapeAnalysis_Wire) theAdvAnalyzer = myAnalyzer; if (theAdvAnalyzer.IsNull()) return Standard_False; theAdvAnalyzer->CheckIntersectingEdges ( num, points2d, points3d, errors ); if ( theAdvAnalyzer->LastCheckStatus ( ShapeExtend_FAIL ) ) { @@ -2647,7 +2647,7 @@ Standard_Boolean ShapeFix_Wire::FixIntersectingEdges (const Standard_Integer num IntRes2d_SequenceOfIntersectionPoint points2d; TColgp_SequenceOfPnt points3d; TColStd_SequenceOfReal errors; - Handle(ShapeAnalysis_Wire) theAdvAnalyzer = Handle(ShapeAnalysis_Wire)::DownCast(myAnalyzer); + Handle(ShapeAnalysis_Wire) theAdvAnalyzer = myAnalyzer; if (theAdvAnalyzer.IsNull()) return Standard_False; theAdvAnalyzer->CheckIntersectingEdges ( num1, num2, points2d, points3d, errors); if ( theAdvAnalyzer->LastCheckStatus ( ShapeExtend_FAIL ) ) { @@ -2918,7 +2918,7 @@ Standard_Boolean ShapeFix_Wire::FixLacking (const Standard_Integer num, //============= // First phase: analysis whether the problem (gap) exists gp_Pnt2d p2d1, p2d2; - Handle(ShapeAnalysis_Wire)::DownCast(myAnalyzer)->CheckLacking ( num, ( force ? Precision() : 0. ), p2d1, p2d2 ); + myAnalyzer->CheckLacking ( num, ( force ? Precision() : 0. ), p2d1, p2d2 ); if ( myAnalyzer->LastCheckStatus ( ShapeExtend_FAIL ) ) { myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 ); } @@ -3186,7 +3186,7 @@ Standard_Boolean ShapeFix_Wire::FixNotchedEdges() myLastFixStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK ); if ( ! IsReady() ) return Standard_False; - Handle(ShapeAnalysis_Wire) theAdvAnalyzer = Handle(ShapeAnalysis_Wire)::DownCast(myAnalyzer); + Handle(ShapeAnalysis_Wire) theAdvAnalyzer = myAnalyzer; TopoDS_Face face = Face(); if ( ! Context().IsNull() ) UpdateWire(); Handle(ShapeExtend_WireData) sewd = WireData(); diff --git a/src/ShapeProcess/ShapeProcess_OperLibrary.cxx b/src/ShapeProcess/ShapeProcess_OperLibrary.cxx index f74d43fa2a..316988e732 100644 --- a/src/ShapeProcess/ShapeProcess_OperLibrary.cxx +++ b/src/ShapeProcess/ShapeProcess_OperLibrary.cxx @@ -692,8 +692,8 @@ static Standard_Boolean fixshape (const Handle(ShapeProcess_Context)& context) if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator; Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; - Handle(ShapeFix_Face) sff = Handle(ShapeFix_Face)::DownCast(sfs->FixFaceTool()); - Handle(ShapeFix_Wire) sfw = Handle(ShapeFix_Wire)::DownCast(sfs->FixWireTool()); + Handle(ShapeFix_Face) sff = sfs->FixFaceTool(); + Handle(ShapeFix_Wire) sfw = sfs->FixWireTool(); sfs->SetMsgRegistrator( msg ); sfs->SetPrecision ( ctx->RealVal ( "Tolerance3d", Precision::Confusion() ) ); diff --git a/src/ShapeUpgrade/ShapeUpgrade_ConvertCurve2dToBezier.cxx b/src/ShapeUpgrade/ShapeUpgrade_ConvertCurve2dToBezier.cxx index 7a766b1074..88fb71debe 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_ConvertCurve2dToBezier.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_ConvertCurve2dToBezier.cxx @@ -138,7 +138,7 @@ void ShapeUpgrade_ConvertCurve2dToBezier::Compute() Geom2dConvert_ApproxCurve approx (tcurve, Precision::Approximation(), GeomAbs_C1, 100, 6 ); if ( approx.HasResult() ) - aBSpline2d = Handle(Geom2d_BSplineCurve)::DownCast(approx.Curve()); + aBSpline2d = approx.Curve(); else aBSpline2d = Geom2dConvert::CurveToBSplineCurve(tcurve,Convert_QuasiAngular); diff --git a/src/ShapeUpgrade/ShapeUpgrade_ConvertCurve3dToBezier.cxx b/src/ShapeUpgrade/ShapeUpgrade_ConvertCurve3dToBezier.cxx index c12a7388bc..d05b7c1905 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_ConvertCurve3dToBezier.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_ConvertCurve3dToBezier.cxx @@ -121,7 +121,7 @@ void ShapeUpgrade_ConvertCurve3dToBezier::Compute() GeomConvert_ApproxCurve approx (tcurve, Precision::Approximation(), GeomAbs_C1, 100, 6 ); if ( approx.HasResult() ) - aBSpline = Handle(Geom_BSplineCurve)::DownCast(approx.Curve()); + aBSpline = approx.Curve(); else { Handle(Geom_TrimmedCurve) t3d = new Geom_TrimmedCurve(myCurve,First,Last); aBSpline = GeomConvert::CurveToBSplineCurve(t3d,Convert_QuasiAngular); diff --git a/src/ShapeUpgrade/ShapeUpgrade_SplitSurface.cxx b/src/ShapeUpgrade/ShapeUpgrade_SplitSurface.cxx index 0b8d7056be..9f1586fdf2 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_SplitSurface.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_SplitSurface.cxx @@ -449,10 +449,8 @@ void ShapeUpgrade_SplitSurface::Build(const Standard_Boolean Segment) } else { // not a BSpline: trimming instead of segmentation - Handle(Geom_Surface) - theNewSurf = Handle(Geom_Surface)::DownCast(theNew); Handle(Geom_RectangularTrimmedSurface) SplittedSurf= - new Geom_RectangularTrimmedSurface(theNewSurf,U1,U2,V1,V2); + new Geom_RectangularTrimmedSurface(theNew,U1,U2,V1,V2); Surfaces->SetValue((irow-1),(icol-1),SplittedSurf); } diff --git a/src/Standard/Standard_Handle.hxx b/src/Standard/Standard_Handle.hxx index 257b9a8284..0eed97c9da 100644 --- a/src/Standard/Standard_Handle.hxx +++ b/src/Standard/Standard_Handle.hxx @@ -181,16 +181,34 @@ namespace opencascade { return get() < theHandle.get(); } - //! Down casting operator + //! Down casting operator from handle to base type template - static handle DownCast (const handle& theObject) + static typename std::enable_if::value, handle>::type + DownCast (const handle& theObject) { return handle (dynamic_cast(const_cast(theObject.get()))); } - //! Down casting operator + //! Down casting operator from pointer to base type template - static handle DownCast (const T2* thePtr) + static typename std::enable_if::value, handle>::type + DownCast (const T2* thePtr) + { + return handle (dynamic_cast(const_cast(thePtr))); + } + + //! For compatibility, define down casting operator from non-base type, as deprecated + template + Standard_DEPRECATED("down-casting from object of the same or unrelated type is meaningless") + static handle DownCast (const handle& theObject, typename std::enable_if::value, void*>::type = 0) + { + return handle (dynamic_cast(const_cast(theObject.get()))); + } + + //! For compatibility, define down casting operator from non-base type, as deprecated + template + Standard_DEPRECATED("down-casting from object of the same or unrelated type is meaningless") + static handle DownCast (const T2* thePtr, typename std::enable_if::value, void*>::type = 0) { return handle (dynamic_cast(const_cast(thePtr))); } diff --git a/src/StdObjMgt/StdObjMgt_ReadData.hxx b/src/StdObjMgt/StdObjMgt_ReadData.hxx index 3f6391413e..09b2ee8b33 100644 --- a/src/StdObjMgt/StdObjMgt_ReadData.hxx +++ b/src/StdObjMgt/StdObjMgt_ReadData.hxx @@ -51,7 +51,7 @@ public: { Handle(StdObjMgt_Persistent) aTarget = theTarget; ReadReference (aTarget); - theTarget = Handle(Type)::DownCast (aTarget); + theTarget = dynamic_cast (aTarget.get()); return *this; } diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index b45f8eba91..b2f122c11c 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -402,7 +402,7 @@ void StdSelect_ViewerSelector3d::ComputeSensitivePrs (const Handle(Graphic3d_Str for (int i = 0; i < anEntities.Length(); i++) { - Handle(Select3D_SensitiveEntity) SubEnt = Handle(Select3D_SensitiveEntity)::DownCast(anEntities.Value(i)); + Handle(Select3D_SensitiveEntity) SubEnt = anEntities.Value(i); //Segment if (SubEnt->DynamicType()==STANDARD_TYPE(Select3D_SensitiveSegment)) diff --git a/src/StepAP209/StepAP209_Construct.cxx b/src/StepAP209/StepAP209_Construct.cxx index 9b893df4e5..f2c20cdc20 100644 --- a/src/StepAP209/StepAP209_Construct.cxx +++ b/src/StepAP209/StepAP209_Construct.cxx @@ -691,8 +691,7 @@ Standard_Boolean StepAP209_Construct::CreateAnalysStructure (const Handle(StepBa Handle(StepData_StepModel) smodel = Handle(StepData_StepModel)::DownCast(Model()); // replace existing contexts for using AP209 - Handle(StepBasic_ProductContext) OldProdCtx = - Handle(StepBasic_ProductContext)::DownCast(Prod->FrameOfReferenceValue(1)); + Handle(StepBasic_ProductContext) OldProdCtx = Prod->FrameOfReferenceValue(1); if(!OldProdCtx.IsNull()) { Handle(StepBasic_ProductContext) ProdCtx = new StepBasic_ProductContext; ProdCtx->Init(OldProdCtx->Name(), @@ -704,8 +703,7 @@ Standard_Boolean StepAP209_Construct::CreateAnalysStructure (const Handle(StepBa HAPC->SetValue(1,ProdCtx); Prod->SetFrameOfReference(HAPC); } - Handle(StepBasic_ProductDefinitionContext) OldPDCtx = - Handle(StepBasic_ProductDefinitionContext)::DownCast(PD->FrameOfReference()); + Handle(StepBasic_ProductDefinitionContext) OldPDCtx = PD->FrameOfReference(); if(!OldPDCtx.IsNull()) { Handle(StepBasic_ProductDefinitionContext) PDCtx = new StepBasic_ProductDefinitionContext; PDCtx->Init(OldPDCtx->Name(), @@ -1308,8 +1306,7 @@ Handle(StepData_StepModel) StepAP209_Construct::CreateAP203Structure() const // replacing contexts: Handle(StepBasic_ApplicationContext) ApplCtx; - Handle(StepBasic_ProductContext) ProdCtx = - Handle(StepBasic_ProductContext)::DownCast(Prod->FrameOfReferenceValue(1)); + Handle(StepBasic_ProductContext) ProdCtx = Prod->FrameOfReferenceValue(1); if(!ProdCtx.IsNull()) { Handle(StepBasic_MechanicalContext) MechCtx = new StepBasic_MechanicalContext; MechCtx->Init(ProdCtx->Name(), ProdCtx->FrameOfReference(), @@ -1320,8 +1317,7 @@ Handle(StepData_StepModel) StepAP209_Construct::CreateAP203Structure() const Prod->SetFrameOfReference(HAPC); ApplCtx = MechCtx->FrameOfReference(); } - Handle(StepBasic_ProductDefinitionContext) PDCtx = - Handle(StepBasic_ProductDefinitionContext)::DownCast(PD->FrameOfReference()); + Handle(StepBasic_ProductDefinitionContext) PDCtx = PD->FrameOfReference(); if(!PDCtx.IsNull()) { Handle(StepBasic_DesignContext) DesCtx = new StepBasic_DesignContext; DesCtx->Init(PDCtx->Name(), PDCtx->FrameOfReference(), diff --git a/src/StepToGeom/StepToGeom.cxx b/src/StepToGeom/StepToGeom.cxx index e2a98a2fdc..3096b4cc7a 100644 --- a/src/StepToGeom/StepToGeom.cxx +++ b/src/StepToGeom/StepToGeom.cxx @@ -689,9 +689,7 @@ Handle(Geom_BSplineSurface) StepToGeom::MakeBSplineSurface (const Handle(StepGeo BSR = Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) ::DownCast(SS); - BS = - Handle(StepGeom_BSplineSurfaceWithKnots) - ::DownCast(BSR->BSplineSurfaceWithKnots()); + BS = BSR->BSplineSurfaceWithKnots(); } else BS = Handle(StepGeom_BSplineSurfaceWithKnots)::DownCast(SS); @@ -1526,8 +1524,7 @@ Handle(Geom_Surface) StepToGeom::MakeSurface (const Handle(StepGeom_Surface)& SS else if (SS->IsKind(STANDARD_TYPE(StepGeom_SurfaceReplica))) { //:n7 abv 16 Feb 99 const Handle(StepGeom_SurfaceReplica) SR = Handle(StepGeom_SurfaceReplica)::DownCast(SS); const Handle(StepGeom_Surface) PS = SR->ParentSurface(); - const Handle(StepGeom_CartesianTransformationOperator3d) T = - Handle(StepGeom_CartesianTransformationOperator3d)::DownCast(SR->Transformation()); + const Handle(StepGeom_CartesianTransformationOperator3d) T = SR->Transformation(); // protect against cyclic references and wrong type of cartop if ( !T.IsNull() && PS != SS ) { Handle(Geom_Surface) S1 = MakeSurface (PS); diff --git a/src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx b/src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx index 4eda09fdec..6933a838a2 100644 --- a/src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx +++ b/src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx @@ -19,7 +19,7 @@ if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve))) { BSCWR = Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)::DownCast(SC); - BSCW = Handle(StepGeom_BSplineCurveWithKnots)::DownCast(BSCWR->BSplineCurveWithKnots()); + BSCW = BSCWR->BSplineCurveWithKnots(); } else BSCW = Handle(StepGeom_BSplineCurveWithKnots)::DownCast(SC); diff --git a/src/TCollection/TCollection_HExtendedString.cxx b/src/TCollection/TCollection_HExtendedString.cxx index 1969fda0a5..05e6c42c4d 100644 --- a/src/TCollection/TCollection_HExtendedString.cxx +++ b/src/TCollection/TCollection_HExtendedString.cxx @@ -296,9 +296,7 @@ void TCollection_HExtendedString::Print(Standard_OStream& S) const Standard_Boolean TCollection_HExtendedString::IsSameState (const Handle(TCollection_HExtendedString)& other) const { - Handle(TCollection_HExtendedString) H; - H = Handle(TCollection_HExtendedString)::DownCast(other); - return ( myString == H->ChangeString() ); + return myString == other->String(); } diff --git a/src/TObj/TObj_Object.cxx b/src/TObj/TObj_Object.cxx index 2c6ca29bcc..6d69b927d5 100644 --- a/src/TObj/TObj_Object.cxx +++ b/src/TObj/TObj_Object.cxx @@ -1268,8 +1268,7 @@ void TObj_Object::CopyReferences new TObj_OcafObjectIterator(GetChildLabel(), NULL, Standard_True); for(; aSrcChildren->More(); aSrcChildren->Next()) { - Handle(TObj_Object) aSrcChild = - Handle(TObj_Object)::DownCast(aSrcChildren->Value()); + Handle(TObj_Object) aSrcChild = aSrcChildren->Value(); TDF_Label aSrcL = aSrcChild->GetLabel(); TDF_Label aDestLabel; if( !theRelocTable->HasRelocation(aSrcL, aDestLabel) ) diff --git a/src/TObj/TObj_TReference.cxx b/src/TObj/TObj_TReference.cxx index 3b71df27b1..a876692e92 100644 --- a/src/TObj/TObj_TReference.cxx +++ b/src/TObj/TObj_TReference.cxx @@ -128,7 +128,7 @@ Handle(TObj_Object) TObj_TReference::Get() const { return anObject; } - anObject = Handle(TObj_Object)::DownCast(aTObject->Get()); + anObject = aTObject->Get(); return anObject; } diff --git a/src/TestTopOpe/TestTopOpe_HDSCommands.cxx b/src/TestTopOpe/TestTopOpe_HDSCommands.cxx index 68db59338d..af1dda9010 100644 --- a/src/TestTopOpe/TestTopOpe_HDSCommands.cxx +++ b/src/TestTopOpe/TestTopOpe_HDSCommands.cxx @@ -214,7 +214,7 @@ static void SetPoint namedisp.ToCString(),namecolor); } char *pname = (char *)namedbrep.ToCString(); - Draw::Set(pname,Handle(Draw_Marker3D)::DownCast(D)); + Draw::Set(pname,D); } void tsee_entity0::See() @@ -259,7 +259,7 @@ static void SetCurve Handle(TestTopOpeDraw_DrawableC3D) D; D = new TestTopOpeDraw_DrawableC3D(GTC,namecolor,namedisp.ToCString(),namecolor); char *pname = (char *)namedbrep.ToCString(); - Draw::Set(pname,Handle(DrawTrSurf_Curve)::DownCast(D)); + Draw::Set(pname,D); } static TopoDS_Shape bidbid; diff --git a/src/TestTopOpeDraw/TestTopOpeDraw_Displayer.cxx b/src/TestTopOpeDraw/TestTopOpeDraw_Displayer.cxx index 7387723121..43a8ec16e8 100644 --- a/src/TestTopOpeDraw/TestTopOpeDraw_Displayer.cxx +++ b/src/TestTopOpeDraw/TestTopOpeDraw_Displayer.cxx @@ -139,7 +139,7 @@ void TestTopOpeDraw_Displayer::DisplayShapePrivate() if (myPar != -1.0 ) D->SetPar(myPar); char* pname = (char *)myNameDBRep.ToCString(); - Draw::Set(pname,Handle(DBRep_DrawableShape)::DownCast(D)); + Draw::Set(pname,D); } //======================================================================= diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 75af39a4c7..1fc28ba9d2 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -4333,7 +4333,7 @@ static void objInfo (const NCollection_Map& theDe template static void printLocalSelectionInfo (const T& theContext, Draw_Interpretor& theDI) { - const Standard_Boolean isGlobalCtx = !(Handle(AIS_InteractiveContext)::DownCast (theContext).IsNull()); + const Standard_Boolean isGlobalCtx = (theContext->DynamicType() == STANDARD_TYPE(AIS_InteractiveContext)); TCollection_AsciiString aPrevName; for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected()) { diff --git a/src/VrmlData/VrmlData_Scene.cxx b/src/VrmlData/VrmlData_Scene.cxx index ef92b569c7..c1862caf45 100644 --- a/src/VrmlData/VrmlData_Scene.cxx +++ b/src/VrmlData/VrmlData_Scene.cxx @@ -621,8 +621,7 @@ void VrmlData_Scene::createShape const Handle(VrmlData_ShapeNode) aNodeShape = Handle(VrmlData_ShapeNode)::DownCast (anIter.Value()); if (aNodeShape.IsNull() == Standard_False) { - const Handle(VrmlData_Geometry) aNodeGeom = - Handle(VrmlData_Geometry)::DownCast(aNodeShape->Geometry()); + const Handle(VrmlData_Geometry) aNodeGeom = aNodeShape->Geometry(); if (aNodeGeom.IsNull() == Standard_False) { if (aSingleShape.IsNull() == Standard_False) isSingleShape = Standard_False; diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index b0ac14a3b4..85fede6756 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -735,11 +735,11 @@ static Standard_Integer meshcolors( Draw_Interpretor& di, Standard_Integer aReflection = Draw::Atoi(argv[3]); for (Standard_Integer aCount = 0 ; aCount < aMesh->GetBuildersCount(); aCount++ ){ - aTempBuilder = Handle(MeshVS_PrsBuilder)::DownCast(aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder")); + aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder"); if( !aTempBuilder.IsNull()) aMesh->RemoveBuilderById(aTempBuilder->GetId()); - aTempBuilder = Handle(MeshVS_PrsBuilder)::DownCast(aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder")); + aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder"); if( !aTempBuilder.IsNull()) aMesh->RemoveBuilderById(aTempBuilder->GetId()); } @@ -942,7 +942,7 @@ static Standard_Integer meshvectors( Draw_Interpretor& di, Handle(MeshVS_PrsBuilder) aTempBuilder; - aTempBuilder = Handle(MeshVS_PrsBuilder)::DownCast(aMesh->FindBuilder("MeshVS_VectorPrsBuilder")); + aTempBuilder = aMesh->FindBuilder("MeshVS_VectorPrsBuilder"); if( !aTempBuilder.IsNull()) aMesh->RemoveBuilderById(aTempBuilder->GetId()); diff --git a/src/XmlTObjDrivers/XmlTObjDrivers_ReferenceDriver.cxx b/src/XmlTObjDrivers/XmlTObjDrivers_ReferenceDriver.cxx index b2e2957364..bafc7547cc 100644 --- a/src/XmlTObjDrivers/XmlTObjDrivers_ReferenceDriver.cxx +++ b/src/XmlTObjDrivers/XmlTObjDrivers_ReferenceDriver.cxx @@ -88,8 +88,7 @@ Standard_Boolean XmlTObjDrivers_ReferenceDriver::Paste TDF_Tool::Label (Target->Label().Data(), RefEntry, aLabel, Standard_True); else { - Handle(TObj_Model) aModel = Handle(TObj_Model)::DownCast - ( TObj_Assistant::FindModel( InHolderEntry.ToCString() )); + Handle(TObj_Model) aModel = TObj_Assistant::FindModel (InHolderEntry.ToCString()); TDF_Tool::Label (aModel->GetLabel().Data(), RefEntry, aLabel, Standard_True); } Handle(TObj_TReference) aTarget = @@ -135,8 +134,7 @@ void XmlTObjDrivers_ReferenceDriver::Paste // is reference to other document if (aLabel.Root() == aMasterLabel.Root()) return; - Handle(TObj_Model) aModel = - Handle(TObj_Model)::DownCast( aLObject->GetModel() ); + Handle(TObj_Model) aModel = aLObject->GetModel(); TCollection_AsciiString aModelName( aModel->GetModelName()->String() ); Target.Element().setAttribute(::ReferredModelEntry(), aModelName.ToCString()); } -- 2.20.1