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

0024623: Visualization - improve selection mechanism

Redesign of selection mechanism:
- implemented 3-level BVH tree for selection;
- selection now calculates in 3D space;
- intersection tests were moved to SelectMgr_BaseFrustum descendants;
- removed .cdl files in Select3D and .cdl related to selection in MeshVS;
- SelectMgr_ViewerSelectors are now shared between local and global contexts;
- transformations of sensitive entities are now stored in SelectMgr_SelectableObject only. Sensitive entities are independent from transformations, it is applied to SelectMgr_SelectingVolumeManager instance only;
- connected and multiple connected interactive objects are now represented by their child objects only for SelectMgr_SelectionManager;
- if interactive object has child objects, they will be stored as separate objects in SelectMgr_SelectionManager now.
- test cases bugs/vis/bug24623_1, bug24623_2, bug24623_3, bug24623_4 to test performance and memory issues.
This commit is contained in:
vpa
2015-04-06 12:31:00 +03:00
committed by bugmaster
parent 7a91ad6e81
commit f751596e46
269 changed files with 12626 additions and 11723 deletions

View File

@@ -1,138 +0,0 @@
// Copyright: Matra-Datavision 1995
#include "stdafx.h"
#include <ISession2D_SensitiveCurve.h>
#include <GCPnts_TangentialDeflection.hxx>
#include <SelectBasics_BasicTool.hxx>
IMPLEMENT_STANDARD_HANDLE(ISession2D_SensitiveCurve,Select3D_SensitiveEntity)
IMPLEMENT_STANDARD_RTTIEXT(ISession2D_SensitiveCurve,Select3D_SensitiveEntity)
//=====================================================
// Function : Create
// Purpose :Constructor
//=====================================================
ISession2D_SensitiveCurve::
ISession2D_SensitiveCurve(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom2d_Curve)& C,
const Standard_Real CDeflect,
const Standard_Integer MaxRect):
Select3D_SensitiveEntity(OwnerId),
myMaxRect(MaxRect),
myCurve(C),
myCDeflect(CDeflect)
{
Compute();
}
void ISession2D_SensitiveCurve::Compute()
{
Geom2dAdaptor_Curve Curve (myCurve);
Standard_Real ADeflect = 180; //Angular deflection
GCPnts_TangentialDeflection PointsOnCurve;
PointsOnCurve.Initialize (Curve, ADeflect, myCDeflect,myMaxRect,1.0e-9);
myPolyP2d = new TColgp_HArray1OfPnt2d(1,PointsOnCurve.NbPoints());
gp_Pnt P;
for (Standard_Integer i=1; i<=PointsOnCurve.NbPoints();i++) {
P = PointsOnCurve.Value (i);
myPolyP2d->SetValue(i,gp_Pnt2d(P.X(),P.Y()));
}
}
//=====================================================
// Function : Areas
// Purpose : return the bounding boxes
//=====================================================
void ISession2D_SensitiveCurve::Areas(SelectBasics_ListOfBox2d& boxes)
{
// calcul des Areas --> le nombre voulu est myMaxRect
// mais il y a myPolyP2d->Length() segments
Standard_Integer NbSeg = myPolyP2d->Length()-1;
Standard_Integer nbPerBoxes= NbSeg/myMaxRect;
Standard_Integer CurrentPoint =1;
for (Standard_Integer i=1;i<=myMaxRect-1;i++)
{
Bnd_Box2d abox;
abox.Set(myPolyP2d->Value(CurrentPoint));
for(Standard_Integer j=1;j<=nbPerBoxes;j++)
{
CurrentPoint++;
abox.Add(myPolyP2d->Value(CurrentPoint));
}
boxes.Append(abox);
}
Bnd_Box2d abox;
abox.Set(myPolyP2d->Value(CurrentPoint));
for(Standard_Integer j=CurrentPoint;j<=myPolyP2d->Length()-1;j++)
{
CurrentPoint++;
abox.Add(myPolyP2d->Value(CurrentPoint));
}
boxes.Append(abox);
}
//=======================================================
// Function : Matches
// Purpose : test : segments in the bounding boxe
//=======================================================
Standard_Boolean ISession2D_SensitiveCurve::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
Bnd_Box2d BoundBox;
BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol);
for(Standard_Integer j=1;j<=myPolyP2d->Length()-1;j++)
{
if(BoundBox.IsOut(myPolyP2d->Value(j))) return Standard_False;
}
return Standard_True;
}
//====================================================
// Function : Matches
// Purpose : test the real dist to the segments
//====================================================
Standard_Boolean ISession2D_SensitiveCurve::
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
// VERY VERY IMPORTANT : set the selector sensibility !!! ( it's aTol !! )
Standard_Integer Rank=0; // New in 2.0
if (aTol == 0) {TRACE0("VERY VERY IMPORTANT : set the selector sensibility !!! ( it's aTol !! )");}
Standard_Boolean Result = SelectBasics_BasicTool::MatchPolyg2d(myPolyP2d->Array1(),
X,Y,
aTol,
DMin,
Rank); // new in 2.0
return Result;
}
Handle(TColgp_HArray1OfPnt2d) ISession2D_SensitiveCurve::
SensitivePolygon()
{
return myPolyP2d;
}

View File

@@ -1,86 +0,0 @@
// File generated by CPPExt (Transient)
//
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#ifndef _ISession2D_SensitiveCurve_HeaderFile
#define _ISession2D_SensitiveCurve_HeaderFile
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Integer.hxx>
#include <gp_Pnt2d.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
class SelectBasics_EntityOwner;
class gp_Pnt2d;
#include <SelectBasics_ListOfBox2d.hxx>
#include "TColgp_HArray1OfPnt2d.hxx"
#include <Geom2d_Curve.hxx>
DEFINE_STANDARD_HANDLE(ISession2D_SensitiveCurve,Select3D_SensitiveEntity)
class ISession2D_SensitiveCurve : public Select3D_SensitiveEntity {
public:
// Methods PUBLIC
//
Standard_EXPORT ISession2D_SensitiveCurve(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom2d_Curve)& C,
const Standard_Real CDeflect,
const Standard_Integer MaxRect = 3);
inline void SetMaxBoxes(const Standard_Integer MaxRect) ;
inline virtual Standard_Integer MaxBoxes() const;
inline void SetCurve(const Handle(Geom2d_Curve) aCurve) ;
inline Handle(Geom2d_Curve) GetCurve() ;
void Compute();
Standard_EXPORT void Areas(SelectBasics_ListOfBox2d& aSeq) ;
Standard_EXPORT Standard_Boolean Matches(const Standard_Real XMin,const Standard_Real YMin,const Standard_Real XMax,const Standard_Real YMax,const Standard_Real aTol) ;
Standard_EXPORT Standard_Boolean Matches(const Standard_Real X,const Standard_Real Y,const Standard_Real aTol,Standard_Real& DMin) ;
Handle(TColgp_HArray1OfPnt2d) SensitivePolygon();
DEFINE_STANDARD_RTTI(ISession2D_SensitiveCurve)
private:
// Fields PRIVATE
//
Standard_Real myCDeflect;
Standard_Integer myMaxRect;
Handle(Geom2d_Curve) myCurve;
Handle(TColgp_HArray1OfPnt2d) myPolyP2d;
};
inline Standard_Integer ISession2D_SensitiveCurve::
MaxBoxes() const {return myMaxRect;}
inline void ISession2D_SensitiveCurve::
SetMaxBoxes(const Standard_Integer nbrect)
{myMaxRect = nbrect;}
inline void ISession2D_SensitiveCurve::
SetCurve(const Handle(Geom2d_Curve) aCurve)
{myCurve = aCurve;}
inline Handle(Geom2d_Curve) ISession2D_SensitiveCurve::
GetCurve()
{return myCurve;}
#endif

View File

@@ -229,7 +229,6 @@
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_SelectionManager.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <ShapeFix_Shape.hxx>
#include <StdSelect_ViewerSelector3d.hxx>