1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0025765: Coding rules - clean up code from obsolete macro checks

Unused code paths (including definition of these macros and meaningless comments) were eliminated.
This commit is contained in:
apn
2015-02-24 19:27:20 +03:00
committed by bugmaster
parent f1b0b4f9c6
commit d2094e110f
130 changed files with 11 additions and 1775 deletions

View File

@@ -16,35 +16,11 @@
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfTransient.hxx>
#define BUC60953 // SAV_050701 : the array of selected objects has always the same length
// independently of number of objects selected. Thus, if there were selected
// more than MaxSizeOfResult objects we have got an exception.
// Moreover, Select method was optimized a little bit.
// Now it checks the state of incoming owner. If the state is 0
// there is no searching for object in <myresult> array.
#define OCC138
#define OCC189 //SAV: 18//03/02 array was replaced with list.
#define OCC1039 //SAV: 25/11/02 clearing selected objects if any on the AIS_Selection remove.
#define USE_MAP //san : 18/04/03 USE_MAP - additional datamap is used to speed up access
//to certain owners in <myresult> list
#ifdef BUC60953
#include <SelectMgr_EntityOwner.hxx>
#endif
#ifdef OCC138 //VTN Avoding infinit loop in AddOrRemoveSelected and AddOrRemoveCurrentObject methods.
#include <AIS_InteractiveObject.hxx>
#endif
#ifndef USE_MAP
#define MaxSizeOfResult 10000
#else
#define MaxSizeOfResult 100000
#endif
//current selection (handle)
static Handle(AIS_Selection) theCurrentSelection;
@@ -68,14 +44,9 @@ static TColStd_SequenceOfTransient& AIS_Sel_GetSelections()
//=======================================================================
AIS_Selection::AIS_Selection(const Standard_CString aName) :
myName(TCollection_AsciiString(aName)),
#if !defined USE_MAP && !defined OCC189
myresult(new TColStd_HArray1OfTransient(1,MaxSizeOfResult)),
#endif
myNb(0)
{
#ifdef USE_MAP
myResultMap.ReSize( MaxSizeOfResult ); // for maximum performnace on medium selections ( < 100000 objects )
#endif
}
//=======================================================================
@@ -150,12 +121,8 @@ void AIS_Selection::Select()
AIS_Sel_CurrentSelection (S);
if(!S.IsNull()){
S->myNb=0;
#if defined OCC189 || defined USE_MAP
S->myresult.Clear();
#ifdef USE_MAP
S->myResultMap.Clear();
#endif
#endif
}
}
@@ -181,66 +148,6 @@ AIS_SelectStatus AIS_Selection::Select(const Handle(Standard_Transient)& anObjec
Handle(SelectMgr_EntityOwner) owner = Handle(SelectMgr_EntityOwner)::DownCast( anObject );
if ( owner.IsNull() )
anAISObj = Handle(AIS_InteractiveObject)::DownCast( anObject );
#ifndef OCC189
TColStd_Array1OfTransient& arr = S->myresult->ChangeArray1();
Standard_Integer Found(-1);
Standard_Integer i ;
#ifdef BUC60953
Standard_Boolean selected = Standard_False;
if ( !owner.IsNull() )
selected = owner->State() != 0;
#ifdef OCC138
else if(!anAISObj.IsNull())
selected = anAISObj->State();
}
#endif
if ( selected ) // looking up index of object
#endif
for( i=arr.Lower() && Found==-1;i<=S->myNb;i++){
if(arr(i)==anObject)
Found=i;
}
// If it is not inside, it is added...
#ifdef BUC60953
if ( !selected || Found == -1 ) {
#else
if(Found==-1){
#endif
if((S->myNb)+1>arr.Length()){
Handle(TColStd_HArray1OfTransient) NiouTab = new TColStd_HArray1OfTransient(1,arr.Length()+MaxSizeOfResult);
for(i=arr.Lower();i<=S->myNb;i++){
const Handle(Standard_Transient)& T = S->myresult->Value(i);
NiouTab->SetValue(i,T);
}
#ifdef BUC60953
S->myresult = NiouTab;
#endif
}
(S->myNb)++;
S->myresult->SetValue(S->myNb,anObject);
return AIS_SS_Added;
}
// it was inside and it is removed...
for(i=Found;i<=S->myNb;i++)
arr(i)=arr(i+1);
S->myNb--;
#elif !defined USE_MAP //OCC189
AIS_NListTransient::Iterator anIter ( S->myresult );
for ( ; anIter.More(); anIter.Next() )
if ( anIter.Value() == anObject ) {
S->myresult.Remove( anIter );
return AIS_SS_Removed;
}
S->myresult.Append( anObject );
return AIS_SS_Added;
#else //USE_MAP
if ( S->myResultMap.IsBound( anObject ) ){
AIS_NListTransient::Iterator aListIter = S->myResultMap.Find( anObject );
//skt-----------------------------------------------------------------
@@ -251,14 +158,12 @@ AIS_SelectStatus AIS_Selection::Select(const Handle(Standard_Transient)& anObjec
S->myIterator = AIS_NListTransient::Iterator();
}
//--------------------------------------------------------------------
#ifdef BUC60953
// In the mode of advanced mesh selection only one owner is created
// for all selection modes. It is necessary to check the current detected
// entity and remove the owner from map only if the detected entity is
// the same as previous selected (IsForcedHilight call)
if( !anAISObj.IsNull() || ( !owner.IsNull() && !owner->IsForcedHilight() ) )
{
#endif
S->myresult.Remove( aListIter );
S->myResultMap.UnBind( anObject );
@@ -280,7 +185,6 @@ AIS_SelectStatus AIS_Selection::Select(const Handle(Standard_Transient)& anObjec
S->myresult.Append( anObject, aListIter );
S->myResultMap.Bind( anObject, aListIter );
return AIS_SS_Added;
#endif //USE_MAP
}
//=======================================================================
@@ -293,29 +197,12 @@ AIS_SelectStatus AIS_Selection::AddSelect(const Handle(Standard_Transient)& anOb
AIS_Sel_CurrentSelection (S);
if(S.IsNull()) return AIS_SS_NotDone;
#ifndef OCC189
TColStd_Array1OfTransient& arr = S->myresult->ChangeArray1();
Standard_Integer i;
if((S->myNb)+1>arr.Length()){
Handle(TColStd_HArray1OfTransient) NiouTab = new TColStd_HArray1OfTransient(1,arr.Length()+MaxSizeOfResult);
for(i=arr.Lower();i<=S->myNb;i++){
const Handle(Standard_Transient)& T = S->myresult->Value(i);
NiouTab->SetValue(i,T);
}
S->myresult = NiouTab;
}
(S->myNb)++;
S->myresult->SetValue(S->myNb,anObject);
#elif !defined USE_MAP //OCC189
S->myresult.Append( anObject );
#else //USE_MAP
if ( S->myResultMap.IsBound( anObject ) )
return AIS_SS_NotDone;
AIS_NListTransient::Iterator aListIter;
S->myresult.Append( anObject, aListIter );
S->myResultMap.Bind( anObject, aListIter );
#endif
return AIS_SS_Added;
}
@@ -343,11 +230,7 @@ void AIS_Selection::ClearAndSelect(const Handle(Standard_Transient)& anObject) {
Standard_Integer AIS_Selection::Extent() {
Handle(AIS_Selection) S;
AIS_Sel_CurrentSelection (S);
#if !defined OCC189 && !defined USE_MAP
return S->myNb;
#else
return S->myresult.Extent();
#endif
}
//=======================================================================
@@ -371,15 +254,7 @@ Standard_Boolean AIS_Selection::IsSelected(const Handle(Standard_Transient)& anO
Handle(AIS_Selection) S;
AIS_Sel_CurrentSelection (S);
if(S.IsNull()) return Standard_False;
#ifndef USE_MAP
for(S->Init();S->More();S->Next()){
if(S->Value()==anObject)
return Standard_True;
}
return Standard_False;
#else
return S->myResultMap.IsBound( anObject );
#endif
}
//=======================================================================
@@ -407,12 +282,10 @@ void AIS_Selection::Remove(const Standard_CString aName)
{
Standard_Integer I = AIS_Selection::Index(aName);
if(I!=0) {
#ifdef OCC1039
Handle(AIS_Selection) selection = Handle(AIS_Selection)::DownCast( AIS_Sel_GetSelections().Value(I) );
Standard_Integer stored = selection->NbStored();
if ( stored )
selection->Select();
#endif
AIS_Sel_GetSelections().Remove(I);
}
}