mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0024023: Revamp the OCCT Handle -- ambiguity
Code corrected to avoid ambiguous situations due to changed implementation of Handle (overloaded methods accepting handles of different types). In Adaptor3d_CurveOnSurface added method Load() with two parameters, allowing to avoid ambiguity of cast of handles when calling separate methods Load() for curve and surface, replacing by single call. In DrawTrSurf and IGESData_IGESWriter, template variants of methods Set() and Send(), respectively, are added to avoid ambiguity when these methods are called with handles to derived types (using SFINAE). In NCollection_DefineHSequence, method Append() accepting handle to another HSequence is made template, to be available only if argument has compatible type.
This commit is contained in:
@@ -423,7 +423,7 @@ void AIS_IdenticRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aS
|
||||
Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv1);
|
||||
Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),myFAttach);
|
||||
Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),mySAttach);
|
||||
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
|
||||
Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
|
||||
|
||||
Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecu);
|
||||
aSelection->Add(scurv);
|
||||
@@ -437,7 +437,7 @@ void AIS_IdenticRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aS
|
||||
|
||||
Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),myFAttach);
|
||||
Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),mySAttach);
|
||||
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
|
||||
Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
|
||||
|
||||
Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecu);
|
||||
aSelection->Add(scurv);
|
||||
|
@@ -124,7 +124,8 @@ void AIS_InteractiveContext::Delete() const
|
||||
|
||||
// let's remove one reference explicitly. this operation's supposed to
|
||||
// be performed when mgrSelector will be destroyed but anyway...
|
||||
mgrSelector->Remove (myMainSel);
|
||||
const Handle(SelectMgr_ViewerSelector)& aSelector = myMainSel; // to avoid ambiguity
|
||||
mgrSelector->Remove (aSelector);
|
||||
|
||||
Handle(AIS_InteractiveContext) aNullContext;
|
||||
for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
|
||||
@@ -458,7 +459,8 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO
|
||||
myMainPM->Display(theIObj, theDispMode);
|
||||
if (theSelectionMode != -1)
|
||||
{
|
||||
if (!mgrSelector->Contains (theIObj))
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
|
||||
if (!mgrSelector->Contains (anObj))
|
||||
{
|
||||
mgrSelector->Load (theIObj);
|
||||
}
|
||||
@@ -510,7 +512,8 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO
|
||||
}
|
||||
if (theSelectionMode != -1)
|
||||
{
|
||||
if (!mgrSelector->Contains (theIObj))
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
|
||||
if (!mgrSelector->Contains (anObj))
|
||||
{
|
||||
mgrSelector->Load (theIObj);
|
||||
}
|
||||
@@ -563,7 +566,8 @@ void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
|
||||
}
|
||||
|
||||
// Register theIObj in the selection manager to prepare further activation of selection
|
||||
if (!mgrSelector->Contains (theIObj))
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
|
||||
if (!mgrSelector->Contains (anObj))
|
||||
{
|
||||
mgrSelector->Load (theIObj);
|
||||
}
|
||||
@@ -2380,7 +2384,8 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
|
||||
{
|
||||
// for cases when reference shape of connected interactives was not displayed
|
||||
// but its selection primitives were calculated
|
||||
mgrSelector->Remove (theIObj);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
|
||||
mgrSelector->Remove (anObj);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2429,7 +2434,8 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
|
||||
}
|
||||
|
||||
// remove IO from the selection manager to avoid memory leaks
|
||||
mgrSelector->Remove (theIObj);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
|
||||
mgrSelector->Remove (anObj);
|
||||
|
||||
myObjects.UnBind (theIObj);
|
||||
myMainVwr->Viewer()->UnregisterObject (theIObj);
|
||||
@@ -2823,13 +2829,15 @@ void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& th
|
||||
{
|
||||
Handle(AIS_MultipleConnectedInteractive) theObj (Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly));
|
||||
theObj->Disconnect (theObjToDisconnect);
|
||||
mgrSelector->Remove (theObjToDisconnect);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = theObjToDisconnect; // to avoid ambiguity
|
||||
mgrSelector->Remove (anObj);
|
||||
}
|
||||
else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect.IsNull())
|
||||
{
|
||||
Handle(AIS_ConnectedInteractive) theObj (Handle(AIS_ConnectedInteractive)::DownCast (theAssembly));
|
||||
theObj->Disconnect();
|
||||
mgrSelector->Remove (theObj);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = theObj; // to avoid ambiguity
|
||||
mgrSelector->Remove (anObj);
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
@@ -308,7 +308,8 @@ Erase(const Handle(AIS_InteractiveObject)& anInteractive)
|
||||
}
|
||||
|
||||
// Deactivate selectable entities of interactive object
|
||||
if (mySM->Contains (anInteractive))
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = anInteractive; // to avoid ambiguity
|
||||
if (mySM->Contains (anObj))
|
||||
{
|
||||
TColStd_ListIteratorOfListOfInteger aModeIter (STAT->SelectionModes());
|
||||
for (; aModeIter.More(); aModeIter.Next())
|
||||
@@ -475,9 +476,10 @@ Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& a
|
||||
}
|
||||
|
||||
// Remove the interactive object from selection manager
|
||||
if (mySM->Contains (aSelectable))
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = aSelectable; // to avoid ambiguity
|
||||
if (mySM->Contains (anObj))
|
||||
{
|
||||
mySM->Remove (aSelectable);
|
||||
mySM->Remove (anObj);
|
||||
}
|
||||
ClearOutdatedSelection (aSelectable, Standard_True);
|
||||
|
||||
|
@@ -1020,7 +1020,7 @@ void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,
|
||||
}
|
||||
}
|
||||
if(EO.IsNull())
|
||||
EO = new SelectMgr_EntityOwner(anIObj);
|
||||
EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
|
||||
}
|
||||
|
||||
ClearSelected(Standard_False);
|
||||
@@ -1059,7 +1059,7 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)&
|
||||
}
|
||||
if(EO.IsNull())
|
||||
{
|
||||
EO = new SelectMgr_EntityOwner(anIObj);
|
||||
EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1315,7 +1315,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));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -189,7 +189,7 @@ void AIS_MidPointRelation::ComputeSelection(const Handle(SelectMgr_Selection)& a
|
||||
ax.SetLocation(myMidPoint);
|
||||
Standard_Real rad = myFAttach.Distance(myMidPoint)/20.0;
|
||||
gp_Circ aCircleM (ax,rad);
|
||||
Handle(Geom_Circle) thecir = new Geom_Circle(aCircleM);
|
||||
Handle(Geom_Curve) thecir = new Geom_Circle(aCircleM);
|
||||
Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecir);
|
||||
aSel->Add(scurv);
|
||||
|
||||
@@ -215,7 +215,7 @@ void AIS_MidPointRelation::ComputeSelection(const Handle(SelectMgr_Selection)& a
|
||||
Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv);
|
||||
Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),myFirstPnt1);
|
||||
Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),myFirstPnt2);
|
||||
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
|
||||
Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
|
||||
|
||||
scurv = new Select3D_SensitiveCurve(own, thecu);
|
||||
aSel->Add(scurv);
|
||||
@@ -226,7 +226,7 @@ void AIS_MidPointRelation::ComputeSelection(const Handle(SelectMgr_Selection)& a
|
||||
Handle(Geom_Ellipse) theEll = Handle(Geom_Ellipse)::DownCast (curv);
|
||||
Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),myFirstPnt1);
|
||||
Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),myFirstPnt2);
|
||||
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
|
||||
Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
|
||||
|
||||
scurv = new Select3D_SensitiveCurve(own, thecu);
|
||||
aSel->Add(scurv);
|
||||
@@ -250,7 +250,7 @@ void AIS_MidPointRelation::ComputeSelection(const Handle(SelectMgr_Selection)& a
|
||||
Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv);
|
||||
Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),mySecondPnt1);
|
||||
Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),mySecondPnt2);
|
||||
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
|
||||
Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
|
||||
|
||||
scurv = new Select3D_SensitiveCurve(own, thecu);
|
||||
aSel->Add(scurv);
|
||||
@@ -261,7 +261,7 @@ void AIS_MidPointRelation::ComputeSelection(const Handle(SelectMgr_Selection)& a
|
||||
Handle(Geom_Ellipse) theEll = Handle(Geom_Ellipse)::DownCast (curv);
|
||||
Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),mySecondPnt1);
|
||||
Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),mySecondPnt2);
|
||||
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
|
||||
Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
|
||||
|
||||
scurv = new Select3D_SensitiveCurve(own, thecu);
|
||||
aSel->Add(scurv);
|
||||
|
@@ -210,7 +210,8 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe
|
||||
case 1:
|
||||
{ //origine
|
||||
Prior = 8;
|
||||
eown= new SelectMgr_EntityOwner(myShapes[0],Prior);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[0]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj,Prior);
|
||||
aSelection->Add(new Select3D_SensitivePoint(eown,myPlane->Location()));
|
||||
|
||||
break;
|
||||
@@ -219,7 +220,8 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe
|
||||
{ //axes ... priorite 7
|
||||
Prior = 7;
|
||||
for (Standard_Integer i=1; i<=2;i++){
|
||||
eown= new SelectMgr_EntityOwner(myShapes[i],Prior);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[i]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj,Prior);
|
||||
aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1)));
|
||||
|
||||
}
|
||||
|
@@ -324,7 +324,8 @@ void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelecti
|
||||
case 1:
|
||||
{ //origin :
|
||||
Prior = 8;
|
||||
eown= new SelectMgr_EntityOwner(myShapes[0],Prior);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[0]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj,Prior);
|
||||
|
||||
aSelection->Add(new Select3D_SensitivePoint (eown,myComponent->Location()));
|
||||
// If the trihedron's shapes display and selection modes are the same
|
||||
@@ -342,7 +343,8 @@ void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelecti
|
||||
{ //axes ... priority 7
|
||||
Prior = 7;
|
||||
for (Standard_Integer i=1; i<=3;i++){
|
||||
eown= new SelectMgr_EntityOwner(myShapes[i],Prior);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[i]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj,Prior);
|
||||
aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1)));
|
||||
|
||||
}
|
||||
@@ -379,15 +381,18 @@ void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelecti
|
||||
Prior =5;
|
||||
|
||||
|
||||
eown= new SelectMgr_EntityOwner(myShapes[4],Prior);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj4 = myShapes[4]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj4,Prior);
|
||||
// PO(2) = PP(2);PO(3) = PP(3);
|
||||
aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(2),PP(3)));
|
||||
|
||||
eown= new SelectMgr_EntityOwner(myShapes[5],Prior);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj5 = myShapes[5]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj5,Prior);
|
||||
// PO(2) = PP(3);PO(3) = PP(4);
|
||||
aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(2),PP(4)));
|
||||
|
||||
eown= new SelectMgr_EntityOwner(myShapes[6],Prior);
|
||||
const Handle(SelectMgr_SelectableObject)& anObj6 = myShapes[6]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj6,Prior);
|
||||
// PO(2) = PP(4);PO(3) = PP(2);
|
||||
aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(3),PP(4)));
|
||||
|
||||
|
Reference in New Issue
Block a user