0024023: Revamp the OCCT Handle -- downcast (automatic)
[occt.git] / src / AIS / AIS_ConcentricRelation.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 723d9e8..ee87e19
@@ -1,13 +1,25 @@
-// File:       AIS_ConcentricRelation.cdl
-// Created:    Tue Dec  5 15:09:04 1996
-// Author:     Flore Lantheaume/Odile Olivier
-//              <ODL>
+// Created on: 1996-12-05
+// Created by: Flore Lantheaume/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #include <Standard_NotImplemented.hxx>
 
 #include <AIS_ConcentricRelation.ixx>
 
 #include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
 #include <Select3D_SensitiveCircle.hxx>
 #include <Select3D_SensitiveSegment.hxx>
 
@@ -75,9 +87,9 @@ void AIS_ConcentricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&
   }  
 }
 
-void AIS_ConcentricRelation::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
+void AIS_ConcentricRelation::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTransformation, const Handle(Prs3d_Presentation)& aPresentation)
 {
-// Standard_NotImplemented::Raise("AIS_ConcentricRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
+// Standard_NotImplemented::Raise("AIS_ConcentricRelation::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
   PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
 }
 
@@ -94,8 +106,8 @@ void AIS_ConcentricRelation::ComputeEdgeVertexConcentric(const Handle(Prs3d_Pres
     V = TopoDS::Vertex(mySShape);
   }
   else {
-    E = TopoDS::Edge(myFShape);
-    V = TopoDS::Vertex(mySShape);
+    E = TopoDS::Edge(mySShape);
+    V = TopoDS::Vertex(myFShape);
   }
   gp_Pnt p1,p2;
   Handle(Geom_Curve) C;
@@ -106,7 +118,7 @@ void AIS_ConcentricRelation::ComputeEdgeVertexConcentric(const Handle(Prs3d_Pres
   gp_Pnt P;
   AIS::ComputeGeometry(V,P, myPlane, isOnPlanVertex);
 
-  const Handle(Geom_Circle)& CIRCLE = (Handle(Geom_Circle)&) C;
+  Handle(Geom_Circle) CIRCLE (Handle(Geom_Circle)::DownCast (C));
   myCenter = CIRCLE->Location();
   myRad = Min(CIRCLE->Radius()/5.,15.);
   gp_Dir vec(p1.XYZ() - myCenter.XYZ() );
@@ -137,7 +149,7 @@ void AIS_ConcentricRelation::ComputeTwoVerticesConcentric(const Handle(Prs3d_Pre
   myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
   DsgPrs_ConcentricPresentation::Add(aPresentation,myDrawer,myCenter,myRad,myDir,myPnt);
   if (!isOnPlanVertex1) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V1,P1);
-  if (!isOnPlanVertex1) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V2,P2);
+  if (!isOnPlanVertex2) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V2,P2);
 }
 
 //=======================================================================
@@ -168,13 +180,13 @@ void AIS_ConcentricRelation::ComputeTwoEdgesConcentric(const Handle(Prs3d_Presen
     return;
   }
   
-  const Handle(Geom_Circle)& gcirc1 = (Handle(Geom_Circle)&) geom1;
-  const Handle(Geom_Circle)& gcirc2 = (Handle(Geom_Circle)&) geom2;
+  Handle(Geom_Circle) gcirc1 (Handle(Geom_Circle)::DownCast (geom1));
+  Handle(Geom_Circle) gcirc2 (Handle(Geom_Circle)::DownCast (geom2));
   
   myCenter = gcirc1->Location();
   
-  // on choisit le rayon egal a 1/5 ieme du rayon du plus petit des
-  // 2 cercles. On impose une borne sup au rayon( 0.02 au hasard)
+  // choose the radius equal to 1/5 of the smallest radius of 
+  // 2 circles. Limit is imposed ( 0.02 by chance)
   Standard_Real rad1 = gcirc1->Radius();
   Standard_Real rad2 = gcirc2->Radius();
   myRad = (rad1 > rad2 ) ? rad2 : rad1;
@@ -182,7 +194,7 @@ void AIS_ConcentricRelation::ComputeTwoEdgesConcentric(const Handle(Prs3d_Presen
   if (myRad > 15.) myRad =15.;
   
   
-  //Calcul d'un point du cercle de rayon myRad
+  //Calculate a point of circle of radius myRad
   gp_Dir vec(ptat11.XYZ() - myCenter.XYZ() );
   gp_Vec vectrans(vec);
   myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
@@ -222,17 +234,6 @@ void AIS_ConcentricRelation::Compute(const Handle(Prs3d_Projector)&,
 {
 }
 
-//=======================================================================
-//function : Compute
-//purpose  : to avoid warning
-//=======================================================================
-
-void AIS_ConcentricRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&, 
-                                    const Handle(Graphic2d_GraphicObject)&,
-                                    const Standard_Integer)
-{
-}
-
 //=======================================================================
 //function : ComputeSelection
 //purpose  : 
@@ -243,21 +244,21 @@ void AIS_ConcentricRelation::ComputeSelection(const Handle(SelectMgr_Selection)&
 {
   Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
   
-  //Creation de 2 sensitives cercles
-     // le plus grand
+  //Creation of 2 sensitive circles
+     // the greater
   gp_Ax2 ax(myCenter, myDir);
   Handle(Geom_Circle) Circ = new Geom_Circle(ax, myRad) ;
   Handle(Select3D_SensitiveCircle) 
     sensit = new Select3D_SensitiveCircle (own,
                                           Circ);
   aSelection->Add(sensit);
-     // le plus petit
+     // the smaller
   Circ->SetRadius(myRad/2);
   sensit = new Select3D_SensitiveCircle (own,
                                         Circ);
   aSelection->Add(sensit);
 
-  //Creation de 2 segments sensitifs pour la croix
+  //Creation of 2 segments sensitive for the cross
   Handle(Select3D_SensitiveSegment) seg;
   gp_Pnt otherPnt = myPnt.Mirrored(myCenter);
   seg = new Select3D_SensitiveSegment(own,
@@ -266,8 +267,8 @@ void AIS_ConcentricRelation::ComputeSelection(const Handle(SelectMgr_Selection)&
   aSelection->Add(seg);
 
   gp_Ax1 RotateAxis(myCenter, myDir);
-  gp_Pnt FPnt = myCenter.Rotated(RotateAxis, PI/2);
-  gp_Pnt SPnt = myCenter.Rotated(RotateAxis, -PI/2);
+  gp_Pnt FPnt = myCenter.Rotated(RotateAxis, M_PI/2);
+  gp_Pnt SPnt = myCenter.Rotated(RotateAxis, -M_PI/2);
   seg = new Select3D_SensitiveSegment(own,
                                      FPnt,
                                      SPnt);