0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / AIS / AIS_LocalContext_1.cxx
index 5b5cb97..140a845 100644 (file)
 //              - use of optimisation in SelectMgr_ViewerSelector
 //              -> Best management in detected entities...
 
-#include <AIS_LocalContext.jxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <TColStd_ListOfInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TColStd_MapOfTransient.hxx>
-#include <TColStd_MapIteratorOfMapOfTransient.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_ShadingAspect.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_LocalContext.hxx>
 #include <AIS_LocalStatus.hxx>
+#include <AIS_Selection.hxx>
+#include <AIS_Shape.hxx>
+#include <Aspect_Grid.hxx>
+#include <Geom_Transformation.hxx>
 #include <Graphic3d_ArrayOfTriangles.hxx>
 #include <Graphic3d_Group.hxx>
+#include <NCollection_Map.hxx>
+#include <OSD_Environment.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_ShadingAspect.hxx>
 #include <Select3D_SensitiveTriangulation.hxx>
-#include <StdSelect_ViewerSelector3d.hxx>
 #include <SelectBasics_SensitiveEntity.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <NCollection_Map.hxx>
-#include <Visual3d_View.hxx>
-
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_OrFilter.hxx>
+#include <SelectMgr_SelectableObject.hxx>
 #include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SelectionManager.hxx>
 #include <SelectMgr_SequenceOfOwner.hxx>
-#include <OSD_Environment.hxx>
-
-#include <Geom_Transformation.hxx>
-#include <AIS_Selection.hxx>
-#include <Aspect_Grid.hxx>
-#include <AIS_Shape.hxx>
+#include <Standard_Transient.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <StdSelect_ViewerSelector3d.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfTransient.hxx>
+#include <TColStd_MapOfTransient.hxx>
+#include <TopoDS_Shape.hxx>
+#include <V3d_View.hxx>
+#include <Visual3d_View.hxx>
 
 static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO)
 {
@@ -531,11 +539,11 @@ void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
        Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
        if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
          Handle(SelectMgr_SelectableObject) SO  = Ownr->Selectable();
-         IO = *((Handle(AIS_InteractiveObject)*)&SO);
+         IO = Handle(AIS_InteractiveObject)::DownCast (SO);
        }
       }
       Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
-      Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
+      Standard_Integer HM = GetHiMod(Handle(AIS_InteractiveObject)::DownCast (SO));
       if ( Ownr->IsAutoHilight() )
         Ownr->HilightWithColor(PM,myCTX->SelectionColor(),HM);
       else if ( aMap.IsBound (SO) )
@@ -583,7 +591,7 @@ void AIS_LocalContext::UnhilightPicked (const Standard_Boolean updateviewer)
       Standard_Integer HM(0);
       if(Ownr->HasSelectable()){
        Handle(SelectMgr_SelectableObject) SO  = Ownr->Selectable();
-       Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
+       Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast (SO);
         anObjMap.Add (IO);
 
         HM = GetHiMod(IO);
@@ -665,7 +673,7 @@ HasShape() const
 {
   Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
   if( Tr.IsNull() ) return Standard_False;
-  Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
+  Handle(SelectMgr_EntityOwner) EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr);
   Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
   if(BRO.IsNull()) return Standard_False;
   Standard_Boolean hasshape = BRO->HasShape();
@@ -702,7 +710,7 @@ Standard_Boolean AIS_LocalContext::HasSelectedShape() const
 TopoDS_Shape AIS_LocalContext::SelectedShape() const 
 {
   Handle(Standard_Transient) aTr = AIS_Selection::CurrentSelection()->Value();
-  Handle(SelectMgr_EntityOwner) anEO = *((Handle(SelectMgr_EntityOwner)*)&aTr);
+  Handle(SelectMgr_EntityOwner) anEO = Handle(SelectMgr_EntityOwner)::DownCast (aTr);
   Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(anEO);
   if( aBRO.IsNull() ) 
   {
@@ -722,11 +730,11 @@ SelectedInteractive() const
   Handle(AIS_InteractiveObject) IO;
   Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
   if( !Tr.IsNull() ) {
-    Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
+    Handle(SelectMgr_EntityOwner) EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr);
     Handle(SelectMgr_SelectableObject) SO;
     if(EO->HasSelectable()){
       SO = EO->Selectable();
-      IO = *((Handle(AIS_InteractiveObject)*)&SO);
+      IO = Handle(AIS_InteractiveObject)::DownCast (SO);
     }
   }
   return IO;
@@ -741,7 +749,7 @@ SelectedOwner() const
   Handle(SelectMgr_EntityOwner) EO;
   Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
   if( !Tr.IsNull() )
-       EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
+       EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr);
   return EO;
 }
 
@@ -1014,11 +1022,11 @@ void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,
       SIOBJ->Init();
       if(SIOBJ->More()){
         Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
-       EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
+       EO = Handle(SelectMgr_EntityOwner)::DownCast (BO);
       }
     }
     if(EO.IsNull()) 
-      EO = new SelectMgr_EntityOwner(anIObj);
+      EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
   }
   
   ClearSelected(Standard_False);
@@ -1052,12 +1060,12 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)&
       SIOBJ->Init();
       if(SIOBJ->More()){
         Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
-       EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
+       EO = Handle(SelectMgr_EntityOwner)::DownCast (BO);
       }
     }
     if(EO.IsNull())
     {
-      EO = new SelectMgr_EntityOwner(anIObj);
+      EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
     }
   }
   
@@ -1240,7 +1248,7 @@ AIS_LocalContext::DetectedInteractive() const
   Handle(AIS_InteractiveObject) Iobj;
   if(IsValidIndex(mylastindex)){
     Handle(SelectMgr_SelectableObject) SO = myMapOfOwner->FindKey(mylastindex)->Selectable();
-    Iobj = *((Handle(AIS_InteractiveObject)*) &SO);
+    Iobj = Handle(AIS_InteractiveObject)::DownCast (SO);
   }
   return Iobj;
 }
@@ -1313,7 +1321,7 @@ Standard_Boolean AIS_LocalContext::IsValidForSelection(const Handle(AIS_Interact
   Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(anIObj);
   if( !shape.IsNull() ) 
     return myFilters->IsOk(new StdSelect_BRepOwner(shape->Shape(),shape));
-  return myFilters->IsOk(new SelectMgr_EntityOwner(anIObj));
+  return myFilters->IsOk(new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj));
 }
 
 
@@ -1418,7 +1426,7 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO
   for(; anIter.More(); anIter.Next()){
     const Handle(Standard_Transient)& Tr = anIter.Value();
     if(!Tr.IsNull()){
-      EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
+      EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr);
       if(EO->HasSelectable()){
        Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
        if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){