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

0012121: Optimization of existing selection classes

This commit is contained in:
SAN, AAA
2011-12-29 12:48:06 +00:00
committed by bugmaster
parent dfc06d1f07
commit ac04d1012c
27 changed files with 1325 additions and 629 deletions

View File

@@ -15,7 +15,13 @@
-- selection or graphic structure. These are deduced
-- from your reference object.
-- The relation between the connected interactive object
-- and its source is generally one of geometric transformation.
-- and its source is generally one of geometric transformation.
-- AIS_ConnectedInteractive class doesn't support selection
-- modes different from 0. Descendants should redefine ComputeSelection()
-- method in order to handle other selection modes and generate connected
-- sensitive entities properly. Refer to AIS_ConnectedShape class
-- for exisiting implementation of a connected interactive object
-- for AIS_Shape that supports all standard sub-shape selection modes.
-- Warning
-- An Interactive entity which is view (or projector)
-- dependent requires recalculation of views in hidden
@@ -140,14 +146,9 @@ is
ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr;
aMode : Integer) is redefined virtual private;
---Level: Public
---Purpose: Recovers and calculates any sensitive primitive,
-- aSelection, available in Shape mode, specified by
-- aMode. As a rule, these are sensitive faces.
-- This method is defined as virtual. This enables you to
-- implement it in the creation of a new class of
-- Interactive Object. You need to do this and in so
-- doing, redefine this method, if you create a class
-- which enriches the list of signatures and types.
---Purpose: Generates sensitive entities by copying
-- them from myReference selection, creates and sets an entity
-- owner for this entities and adds them to aSelection
AcceptShapeDecomposition(me) returns Boolean from Standard is
redefined virtual;

View File

@@ -137,39 +137,39 @@ void AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
const Standard_Integer aMode)
void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
const Standard_Integer aMode)
{
if(!(HasLocation() ||HasConnection())) return;
aSel->Clear();
if(!myReference->HasSelection(aMode))
myReference->UpdateSelection(aMode);
// static OSD_Timer KronSel;
// cout<<"debut calcul connexion primitives pour le mode "<<aMode<<endl;
// KronSel.Reset();
// KronSel.Start();
const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode);
Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveEntity) SE3D,SNew;
Handle(Select3D_SensitiveEntity) SE3D, SNew;
if(TheRefSel->IsEmpty())
myReference->UpdateSelection(aMode);
for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next()){
SE3D = *((Handle(Select3D_SensitiveEntity)*) &(TheRefSel->Sensitive()));
if(!SE3D.IsNull()){
for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next())
{
SE3D = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive());
if(!SE3D.IsNull())
{
// Get the copy of SE3D
SNew = SE3D->GetConnected(myLocation);
if(aMode==0)
SNew->Set(OWN);
{
SNew->Set(OWN);
// In case if SE3D caches some location-dependent data
// that must be updated after setting OWN
SNew->SetLocation(myLocation);
}
aSel->Add(SNew);
}
}
// KronSel.Stop();
// cout<<"fin calcul connexion primitives pour le mode "<<aMode<<endl;
// KronSel.Show();
}
void AIS_ConnectedInteractive::UpdateLocation()

View File

@@ -98,45 +98,24 @@ is
aPresentation : mutable Presentation from Prs3d)
is redefined virtual private;
Compute(me : mutable;
aPresentationManager : PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard = 0)
---Level: Public
---Purpose: this method is redefined virtual;
-- when the instance is connected to another
-- InteractiveObject,this method doesn't
-- compute anything, but just uses the
-- presentation of this last object, with
-- a transformation if there's one stored.
is redefined;
ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined virtual private;
---Purpose:
-- Recovers and calculates any sensitive primitive,
-- aSelection, available in Shape mode, specified by
-- aMode . As a rule, these are sensitive faces.
-- This method is defined as virtual. This enables you to
-- implement it in the creation of a new class of
-- Interactive Object. You need to do this and in so
-- doing, redefine this method, if you create a class
-- which enriches the list of signatures and types.
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
raises NotImplemented from Standard
is redefined;
---Level: Internal
---Purpose: this method should fill the presentation according to the
-- enumerated mode of the application and to the display parameter
-- of the application.
raises NotImplemented from Standard
is redefined;
ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined virtual private;
---Purpose: Generates sensitive entities by copying
-- them from myReferense selection specified by aMode,
-- creates and sets an entity owner for this entities and adds
-- them to aSelection.
Shape(me:mutable) returns Shape from TopoDS;
---C++: return const&

View File

@@ -27,6 +27,8 @@
#include <SelectBasics_EntityOwner.hxx>
#include <AIS_MultipleConnectedShape.hxx>
#include <Precision.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_List.hxx>
//=======================================================================
//function : AIS_ConnectedShape
@@ -159,27 +161,22 @@ void AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d& aPre
AIS_ConnectedInteractive::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager3d& /*aPresentationManager3d*/,
const Handle_Prs3d_Presentation& /*aPresentation*/,
const int /*anInteger*/)
{
Standard_NotImplemented::Raise("AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager3d&, const Handle_Prs3d_Presentation&, const int)");
// AIS_ConnectedInteractive::Compute( aPresentationManager3d ,aPresentation,anInteger) ; not accessible
}
//=======================================================================
//function : ComputeSelection
//purpose : Attention fragile...
//=======================================================================
void AIS_ConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
static Standard_Boolean IsEqual( const TopoDS_Shape& theLeft,
const TopoDS_Shape& theRight )
{
return theLeft.IsEqual(theRight);
}
void AIS_ConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList;
typedef NCollection_DataMap<TopoDS_Shape, SensitiveList > Shapes2EntitiesMap;
UpdateShape();
aSelection->Clear();
// It is checked if there is nothing to do with the reference
@@ -187,79 +184,76 @@ void AIS_ConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aS
if(!myReference->HasSelection(aMode))
myReference->UpdateSelection(aMode);
const Handle(SelectMgr_Selection)& RefSel = myReference->Selection(aMode);
if(RefSel->IsEmpty())
myReference->UpdateSelection(aMode);
if(RefSel->UpdateStatus()==SelectMgr_TOU_Full)
const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection(aMode);
if(aRefSel->IsEmpty())
myReference->UpdateSelection(aMode);
// depending on the type of decomposition, connected primitives are subtracted
// it is necessary to follow the order of creation of StdSelect_BRepSelectionTool...
if(aRefSel->UpdateStatus()==SelectMgr_TOU_Full)
myReference->UpdateSelection(aMode);
TopAbs_ShapeEnum TheType = AIS_Shape::SelectionType(aMode);
Handle(StdSelect_BRepOwner) OWNR;
Handle(Select3D_SensitiveEntity) SE,NiouSE;
TopLoc_Location BidLoc;
Handle(StdSelect_BRepOwner) anOwner;
TopLoc_Location aBidLoc;
Handle(Select3D_SensitiveEntity) aSE, aNewSE;
Shapes2EntitiesMap aShapes2EntitiesMap;
SensitiveList aSEList;
TopoDS_Shape aSubShape;
switch(TheType){
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
case TopAbs_FACE:
case TopAbs_SHELL:
// Fill in the map of subshapes and corresponding
// sensitive entities associated with aMode
for(aRefSel->Init(); aRefSel->More(); aRefSel->Next())
{
aSE = Handle(Select3D_SensitiveEntity)::DownCast(aRefSel->Sensitive());
if(!aSE.IsNull())
{
TopTools_IndexedMapOfShape subshaps;
TopExp::MapShapes(myOwnSh,TheType,subshaps);
RefSel->Init();
for(Standard_Integer I=1;
I<=subshaps.Extent()&& RefSel->More();
RefSel->Next(),I++){
SE = *((Handle(Select3D_SensitiveEntity)*) &(RefSel->Sensitive()));
if(!SE.IsNull()){
OWNR = new StdSelect_BRepOwner(subshaps(I),this,SE->OwnerId()->Priority());
if(myLocation.IsIdentity())
NiouSE = SE->GetConnected(BidLoc);
else
NiouSE = SE->GetConnected(myLocation);
NiouSE->Set(OWNR);
aSelection->Add(NiouSE);
}
anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSE->OwnerId());
if(!anOwner.IsNull())
{
aSubShape = anOwner->Shape();
if(!aShapes2EntitiesMap.IsBound(aSubShape))
{
aShapes2EntitiesMap.Bind(aSubShape, aSEList);
}
aShapes2EntitiesMap(aSubShape).Append(aSE);
}
break;
}
case TopAbs_SHAPE:
default:
{
// In case if there is only one owner of the set of
// sensible primitives...
OWNR = new StdSelect_BRepOwner(myOwnSh,this);
Standard_Boolean FirstIncr(Standard_True);
for(RefSel->Init();RefSel->More();RefSel->Next()){
SE = *((Handle(Select3D_SensitiveEntity)*) &(RefSel->Sensitive()));
if(FirstIncr){
Standard_Integer Prior = SE->OwnerId()->Priority();
Handle(SelectBasics_EntityOwner)::DownCast(OWNR)->Set(Prior);
FirstIncr = Standard_False;}
if(myLocation.IsIdentity())
NiouSE = SE->GetConnected(BidLoc);
else
NiouSE = SE->GetConnected(myLocation);
NiouSE->Set(OWNR);
aSelection->Add(NiouSE);
}
break;
}
}
StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
// Fill in selection from aShapes2EntitiesMap
Shapes2EntitiesMap::Iterator aMapIt(aShapes2EntitiesMap);
for(; aMapIt.More(); aMapIt.Next())
{
aSEList = aMapIt.Value();
anOwner = new StdSelect_BRepOwner(aMapIt.Key(),
this,
aSEList.First()->OwnerId()->Priority(),
Standard_True);
SensitiveList::Iterator aListIt(aSEList);
for(; aListIt.More(); aListIt.Next())
{
aSE = aListIt.Value();
if(myLocation.IsIdentity())
{
aNewSE = aSE->GetConnected(aBidLoc);
aNewSE->Set(anOwner);
// In case if aSE caches some location-dependent data
// that must be updated after setting anOwner
aNewSE->SetLocation(aBidLoc);
}
else
{
aNewSE = aSE->GetConnected(myLocation);
aNewSE->Set(anOwner);
// In case if aSE caches some location-dependent data
// that must be updated after setting anOwner
aNewSE->SetLocation(myLocation);
}
aSelection->Add(aNewSE);
}
}
StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
}
//=======================================================================
//function : Shape