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

0024023: Revamp the OCCT Handle -- downcast (automatic)

Automatic update by command "occt_upgrade . -downcast"

C-style cast of Handle to that of derived type (now illegal) is replaced by call to DownCast()
Const reference local variables of Handle type initialized by result of DownCast are replaced by normal variables.
This commit is contained in:
abv
2015-07-02 16:41:05 +03:00
parent ce8b059af3
commit c5f3a42524
158 changed files with 863 additions and 888 deletions

View File

@@ -387,7 +387,7 @@ Handle(ViewerTest_EventManager) ViewerTest::CurrentEventManager()
Handle(ViewerTest_EventManager) EM;
if(theEventMgrs.IsEmpty()) return EM;
Handle(Standard_Transient) Tr = theEventMgrs.First();
EM = *((Handle(ViewerTest_EventManager)*)&Tr);
EM = Handle(ViewerTest_EventManager)::DownCast (Tr);
return EM;
}
@@ -440,7 +440,7 @@ Handle(AIS_Shape) GetAISShapeFromName(const char* name)
if (!IO.IsNull()) {
if(IO->Type()==AIS_KOI_Shape) {
if(IO->Signature()==0){
retsh = *((Handle(AIS_Shape)*)&IO);
retsh = Handle(AIS_Shape)::DownCast (IO);
}
else
cout << "an Object which is not an AIS_Shape "
@@ -4569,7 +4569,7 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
result = TheAISContext()->SelectedShape();
else{
Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
result = (*((Handle(AIS_Shape)*) &IO))->Shape();
result = Handle(AIS_Shape)::DownCast (IO)->Shape();
}
}
@@ -4636,7 +4636,7 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
thearr->SetValue(i,TheAISContext()->SelectedShape());
else{
Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
thearr->SetValue(i,(*((Handle(AIS_Shape)*) &IO))->Shape());
thearr->SetValue(i,Handle(AIS_Shape)::DownCast (IO)->Shape());
}
}
@@ -4765,7 +4765,7 @@ static int VPickSelected (Draw_Interpretor& , Standard_Integer theArgNb, const c
else
{
Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
aShape = (*((Handle(AIS_Shape)*) &IO))->Shape();
aShape = Handle(AIS_Shape)::DownCast (IO)->Shape();
}
TCollection_AsciiString aCurrentName = aName;
@@ -4916,7 +4916,7 @@ static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** a
if(dimension_status == -1)
TheAISContext()->Erase(curio,Standard_False);
else {
AIS_KindOfDimension KOD = (*((Handle(AIS_Relation)*)&curio))->KindOfDimension();
AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
(dimension_status==1 && KOD != AIS_KOD_NONE))
TheAISContext()->Erase(curio,Standard_False);
@@ -4949,7 +4949,7 @@ static int VDisplayType(Draw_Interpretor& , Standard_Integer argc, const char**
if(dimension_status == -1)
TheAISContext()->Display(curio,Standard_False);
else {
AIS_KindOfDimension KOD = (*((Handle(AIS_Relation)*)&curio))->KindOfDimension();
AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
(dimension_status==1 && KOD != AIS_KOD_NONE))
TheAISContext()->Display(curio,Standard_False);

View File

@@ -354,7 +354,7 @@ static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv
// On downcast aShape de AIS_InteractiveObject a AIS_Trihedron
// pour lui appliquer la methode SetSize()
Handle(AIS_Trihedron) aTrihedron = *(Handle(AIS_Trihedron)*) &aShape;
Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast (aShape);
// C'est bien un triedre,on chage sa valeur!
aTrihedron->SetSize(value);
@@ -415,7 +415,7 @@ static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv
// On downcast aShape de AIS_InteractiveObject a AIS_Trihedron
// pour lui appliquer la methode SetSize()
Handle(AIS_Trihedron) aTrihedron = *(Handle(AIS_Trihedron)*) &aShape;
Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast (aShape);
// C'est bien un triedre,on chage sa valeur
aTrihedron->SetSize(value);
@@ -475,7 +475,7 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c
if (!ShapeA.IsNull() &&
ShapeA->Type()==AIS_KOI_Datum && ShapeA->Signature()==3 ) {
// on le downcast
Handle(AIS_Trihedron) TrihedronA =((*(Handle(AIS_Trihedron)*)&ShapeA));
Handle(AIS_Trihedron) TrihedronA =(Handle(AIS_Trihedron)::DownCast (ShapeA));
// on le charge dans le contexte et on active le mode Plane.
TheAISContext()->Load(TrihedronA,0,Standard_False);
TheAISContext()->Activate(TrihedronA,3);
@@ -496,7 +496,7 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c
theIOB = TheAISContext()->Interactive();
}
// on le downcast
Handle(AIS_Plane) PlaneB =((*(Handle(AIS_Plane)*)&theIOB));
Handle(AIS_Plane) PlaneB =(Handle(AIS_Plane)::DownCast (theIOB));
// Fermeture du contexte local.
TheAISContext()->CloseLocalContext(myCurrentIndex);
@@ -1796,15 +1796,15 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
}
else {di <<"vline error: wrong type of 1st argument."<<"\n";return 1; }
// Les deux parametres sont du bon type. On verifie que les points ne sont pas confondus
Handle(AIS_Point) theAISPointA= *(Handle(AIS_Point)*)& theShapeA;
Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
Handle(AIS_Point) theAISPointA= Handle(AIS_Point)::DownCast (theShapeA);
Handle(AIS_Point) theAISPointB= Handle(AIS_Point)::DownCast (theShapeB);
Handle(Geom_Point ) myGeomPointBA= theAISPointA->Component();
Handle(Geom_CartesianPoint ) myCartPointA= *((Handle(Geom_CartesianPoint)*)& myGeomPointBA);
Handle(Geom_CartesianPoint ) myCartPointA= Handle(Geom_CartesianPoint)::DownCast (myGeomPointBA);
// Handle(Geom_CartesianPoint ) myCartPointA= *(Handle(Geom_CartesianPoint)*)& (theAISPointA->Component() ) ;
Handle(Geom_Point ) myGeomPointB= theAISPointB->Component();
Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)& myGeomPointB);
Handle(Geom_CartesianPoint ) myCartPointB= Handle(Geom_CartesianPoint)::DownCast (myGeomPointB);
// Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint)*)& (theAISPointB->Component() ) ;
if (myCartPointB->X()==myCartPointA->X() && myCartPointB->Y()==myCartPointA->Y() && myCartPointB->Z()==myCartPointA->Z() ) {