1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

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).
This commit is contained in:
abv
2016-01-25 10:14:20 +03:00
parent 5d351a0822
commit a9dde4a31b
65 changed files with 190 additions and 380 deletions

View File

@@ -365,7 +365,7 @@ Standard_Boolean ShapeFix_Face::Perform()
{
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
myFixWire->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;

View File

@@ -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 &&

View File

@@ -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();