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:
@@ -1 +1,2 @@
|
||||
SelectBasics_PickArgs.hxx
|
||||
SelectBasics_PickResult.hxx
|
||||
SelectBasics_SelectingVolumeManager.hxx
|
||||
|
@@ -16,12 +16,7 @@
|
||||
|
||||
package SelectBasics
|
||||
|
||||
---Purpose: kernel of dynamic selection:
|
||||
-- - contains the algorithm to sort the sensitive areas
|
||||
-- before the selection action;->quick selection of
|
||||
-- an item in a set of items...
|
||||
-- - contains the entities able to give the algorithm
|
||||
-- sensitive areas .
|
||||
---Purpose: interface class for dynamic selection
|
||||
|
||||
uses
|
||||
Bnd,
|
||||
@@ -31,37 +26,22 @@ uses
|
||||
MMgt,
|
||||
gp,
|
||||
TColgp,
|
||||
TopLoc
|
||||
|
||||
TopLoc,
|
||||
Select3D
|
||||
|
||||
is
|
||||
|
||||
|
||||
deferred class EntityOwner;
|
||||
|
||||
class SortAlgo;
|
||||
|
||||
class BasicTool;
|
||||
|
||||
class ListOfBox2d instantiates List from TCollection
|
||||
(Box2d from Bnd);
|
||||
|
||||
|
||||
class SequenceOfOwner instantiates Sequence from TCollection
|
||||
(EntityOwner);
|
||||
|
||||
|
||||
|
||||
deferred class SensitiveEntity;
|
||||
|
||||
|
||||
class ListOfSensitive instantiates List from TCollection
|
||||
(SensitiveEntity);
|
||||
|
||||
imported PickArgs;
|
||||
---Purpose: Structure to provide all-in-one information on picking arguments
|
||||
imported PickResult;
|
||||
---Purpose: Structure to provide all-in-one result of selection of sensitive
|
||||
-- for "Matches" method of SelectBasics_SensitiveEntity.
|
||||
|
||||
imported SelectingVolumeManager;
|
||||
|
||||
MaxOwnerPriority returns Integer;
|
||||
|
||||
MinOwnerPriority returns Integer;
|
||||
|
@@ -1,59 +0,0 @@
|
||||
-- Created on: 1995-06-08
|
||||
-- Created by: Robert COUBLANC
|
||||
-- Copyright (c) 1995-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class BasicTool from SelectBasics
|
||||
|
||||
---Purpose: give Tools for sorting Selection results
|
||||
-- (example : sensitive entities matching)
|
||||
|
||||
uses
|
||||
Pnt2d from gp,
|
||||
Array1OfPnt2d from TColgp
|
||||
is
|
||||
|
||||
MatchSegments(myclass;
|
||||
P1,P2 : Pnt2d from gp;
|
||||
P3,P4 : Pnt2d from gp)
|
||||
returns Boolean;
|
||||
---Purpose: returns True if The Segment {P1P2} is
|
||||
-- intersected by the segment {P3P4}
|
||||
|
||||
MatchSegment(myclass;
|
||||
pBegin,pEnd : Pnt2d from gp;
|
||||
X,Y,aTol : Real;
|
||||
DMin : in out Real) returns Boolean;
|
||||
---Level: Internal
|
||||
---Purpose: return True if Segment(pBegin, pEnd) is Selected
|
||||
|
||||
AutoInter(myclass; aPolyg2d: Array1OfPnt2d from TColgp)
|
||||
returns Boolean;
|
||||
|
||||
MatchPolyg2d (myclass;
|
||||
tabpoint: Array1OfPnt2d from TColgp;
|
||||
X,Y,aTol: Real;
|
||||
DMin : in out Real;
|
||||
Rank : in out Integer) returns Boolean;
|
||||
---Level: Internal
|
||||
---Purpose: package method used to find if a point
|
||||
-- is close enough to a polygon of 2D points
|
||||
-- to be Used by Primitives like curves or faces...
|
||||
-- Rank gives the index of the touched
|
||||
-- segment
|
||||
|
||||
|
||||
|
||||
|
||||
end BasicTool;
|
@@ -1,151 +0,0 @@
|
||||
// Created on: 1995-06-08
|
||||
// Created by: Robert COUBLANC
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <SelectBasics_BasicTool.ixx>
|
||||
#include <Precision.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function:
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
Standard_Boolean SelectBasics_BasicTool::
|
||||
MatchSegments(const gp_Pnt2d & A,
|
||||
const gp_Pnt2d & B,
|
||||
const gp_Pnt2d & C,
|
||||
const gp_Pnt2d & D)
|
||||
{
|
||||
|
||||
Standard_Real d[6],det,deta,detb;
|
||||
|
||||
if(Max(A.X(),B.X())<Min(C.X(),D.X())) return Standard_False;
|
||||
if(Min(A.X(),B.X())>Max(C.X(),D.X())) return Standard_False;
|
||||
if(Max(A.Y(),B.Y())<Min(C.Y(),D.Y())) return Standard_False;
|
||||
if(Min(A.Y(),B.Y())>Max(C.Y(),D.Y())) return Standard_False;
|
||||
|
||||
d[0] = B.X()-A.X();d[1]=C.X()-D.X();d[2]=C.X()-A.X();
|
||||
d[3] = B.Y()-A.Y();d[4]=C.Y()-D.Y();d[5]=C.Y()-A.Y();
|
||||
|
||||
det = d[0]*d[4]-d[3]*d[1];
|
||||
deta = d[4]*d[2]-d[5]*d[1];
|
||||
detb = d[0]*d[5]-d[3]*d[2];
|
||||
|
||||
if(Abs(det)<=Precision::Confusion()) return Standard_False;
|
||||
if(deta/det<Precision::Confusion()) return Standard_False;
|
||||
if(deta/det>1+Precision::Confusion()) return Standard_False;
|
||||
if(detb/det<Precision::Confusion()) return Standard_False;
|
||||
if(detb/det>1+Precision::Confusion()) return Standard_False;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: MatchSegment
|
||||
// Purpose : Return True if Segment(pBegin, pEnd) is Selected
|
||||
//==================================================
|
||||
Standard_Boolean SelectBasics_BasicTool::MatchSegment(const gp_Pnt2d& pBegin,const gp_Pnt2d& pEnd,
|
||||
const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Standard_Real aTol,
|
||||
Standard_Real& DMin)
|
||||
{
|
||||
const Standard_Real SqTol = aTol * aTol;
|
||||
gp_Vec2d AB, AC, BC;
|
||||
const gp_Pnt2d apoint(X,Y);
|
||||
|
||||
AB.SetCoord(pEnd.X()-pBegin.X(),pEnd.Y()-pBegin.Y());
|
||||
AC.SetCoord(X-pBegin.X(),Y-pBegin.Y());
|
||||
BC.SetCoord(pEnd.X()-X,pEnd.Y()-Y);
|
||||
|
||||
//1. Check the ends, do not estimate distance to the segment itself here
|
||||
if((apoint.SquareDistance(pBegin)<SqTol) ||
|
||||
(apoint.SquareDistance(pEnd)<SqTol)){
|
||||
DMin = 0.;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//2. Checking if the mouse point projection onto the segment`s line
|
||||
// falls inside the segment.
|
||||
if(AB.Dot(AC)>=0. && AB.Dot(BC)>=0.){
|
||||
//3. Estimate distance from the mouse point to the segment
|
||||
// if length of segment exceeds tolerance
|
||||
const Standard_Real aSegLen = AB.Magnitude();
|
||||
if (aSegLen>aTol){
|
||||
DMin=Abs(AB.Crossed(gp_Vec2d(pBegin,apoint))/aSegLen);
|
||||
if (DMin<aTol){
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function:
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
Standard_Boolean SelectBasics_BasicTool::
|
||||
AutoInter (const TColgp_Array1OfPnt2d& points)
|
||||
{
|
||||
for (Standard_Integer i=3;i<=points.Length()-1;i++)
|
||||
{
|
||||
for (Standard_Integer j=1;j<=i-2;j++)
|
||||
{
|
||||
if (MatchSegments (points(i),
|
||||
points(i+1),
|
||||
points(j),
|
||||
points(j+1))) return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function:
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
Standard_Boolean SelectBasics_BasicTool::
|
||||
MatchPolyg2d (const TColgp_Array1OfPnt2d& tabpoint,
|
||||
const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Standard_Real aTol,
|
||||
Standard_Real& DMin,
|
||||
Standard_Integer& Rank)
|
||||
{
|
||||
Rank =0;
|
||||
Standard_Boolean Found= Standard_False;
|
||||
|
||||
//In the cycle towarded enumeration of possibilities segment, which is selected from wire
|
||||
for(Standard_Integer i=tabpoint.Lower();i<=tabpoint.Upper()-1&& !Found;i++)
|
||||
{
|
||||
if(MatchSegment(tabpoint.Value(i),tabpoint.Value(i+1),X,Y,aTol,DMin))
|
||||
{
|
||||
Rank=i;
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
@@ -25,8 +25,3 @@ SelectBasics_EntityOwner
|
||||
::SelectBasics_EntityOwner (const Standard_Integer aPriority):
|
||||
mypriority(aPriority)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,75 +0,0 @@
|
||||
// Created on: 2013-09-04
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _SelectBasics_PickArgs_HeaderFile
|
||||
#define _SelectBasics_PickArgs_HeaderFile
|
||||
|
||||
#include <Standard_TypeDef.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
|
||||
//! Structure to provide all-in-one information on picking arguments
|
||||
//! for "Matches" method of SelectBasics_SensitiveEntity.
|
||||
struct SelectBasics_PickArgs
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
//! @param theX mouse picking coordinate on x-axis of selection coord space.
|
||||
//! @param theY mouse picking coordinate on y-axis of selection coord space.
|
||||
//! @param theTolerance x, y coordinate tolerance.
|
||||
//! @param theDepthMin minimum picking depth in selection coord space.
|
||||
//! @param theDepthMax maximum picking depth in selection coord space.
|
||||
//! @param thePickingLine line going through picking point.
|
||||
SelectBasics_PickArgs (const Standard_Real theX,
|
||||
const Standard_Real theY,
|
||||
const Standard_Real theTolerance,
|
||||
const Standard_Real theDepthMin,
|
||||
const Standard_Real theDepthMax,
|
||||
const gp_Lin& thePickingLine)
|
||||
: myX (theX), myY (theY), myTolerance (theTolerance),
|
||||
myDepthMin (theDepthMin), myDepthMax (theDepthMax),
|
||||
myPickingLine (thePickingLine) {}
|
||||
|
||||
public:
|
||||
|
||||
inline Standard_Real X() const { return myX; }
|
||||
|
||||
inline Standard_Real Y() const { return myY; }
|
||||
|
||||
inline Standard_Real Tolerance() const { return myTolerance; }
|
||||
|
||||
inline Standard_Real DepthMin() const { return myDepthMin; }
|
||||
|
||||
inline Standard_Real DepthMax() const { return myDepthMax; }
|
||||
|
||||
inline const gp_Lin& PickLine() const { return myPickingLine; }
|
||||
|
||||
//! @return True if passed depth lies outside valid depth range.
|
||||
inline Standard_Boolean IsClipped(const Standard_Real theDepth) const
|
||||
{
|
||||
return (theDepth <= myDepthMin || theDepth >= myDepthMax);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Standard_Real myX; //!< mouse picking coordinate on x-axis of selection coord space.
|
||||
Standard_Real myY; //!< mouse picking coordinate on y-axis of selection coord space.
|
||||
Standard_Real myTolerance; //!< x, y coordinate tolerance
|
||||
Standard_Real myDepthMin; //!< minimum picking depth in selection coord space.
|
||||
Standard_Real myDepthMax; //!< maximum picking depth in selection coord space.
|
||||
gp_Lin myPickingLine; //!< line going through picking point
|
||||
};
|
||||
|
||||
#endif
|
55
src/SelectBasics/SelectBasics_PickResult.hxx
Normal file
55
src/SelectBasics/SelectBasics_PickResult.hxx
Normal file
@@ -0,0 +1,55 @@
|
||||
// Created on: 2014-11-14
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _SelectBasics_PickResult_HeaderFile
|
||||
#define _SelectBasics_PickResult_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <NCollection_Vec4.hxx>
|
||||
|
||||
//! This structure provides unified access to the results of
|
||||
//! Matches() method in all sensitive entities.
|
||||
struct SelectBasics_PickResult
|
||||
{
|
||||
public:
|
||||
|
||||
SelectBasics_PickResult()
|
||||
: myDepth (DBL_MAX),
|
||||
myDistToCenter (DBL_MAX) {}
|
||||
|
||||
SelectBasics_PickResult (const Standard_Real theDepth,
|
||||
const Standard_Real theDistToCenter)
|
||||
: myDepth (theDepth),
|
||||
myDistToCenter (theDistToCenter) {}
|
||||
|
||||
public:
|
||||
inline const Standard_Real Depth() const
|
||||
{
|
||||
return myDepth;
|
||||
}
|
||||
|
||||
inline const Standard_Real DistToGeomCenter() const
|
||||
{
|
||||
return myDistToCenter;
|
||||
}
|
||||
|
||||
private:
|
||||
//!< Depth to detected point
|
||||
Standard_Real myDepth;
|
||||
//!< Distance from 3d projection user-picked selection point to entity's geometry center
|
||||
Standard_Real myDistToCenter;
|
||||
};
|
||||
|
||||
#endif // _SelectBasics_PickResult_HeaderFile
|
89
src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx
Normal file
89
src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx
Normal file
@@ -0,0 +1,89 @@
|
||||
// Created on: 2014-08-21
|
||||
// Created by: Varvara POSKONINA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _SelectBasics_SelectingVolumeManager_HeaderFile
|
||||
#define _SelectBasics_SelectingVolumeManager_HeaderFile
|
||||
|
||||
#include <BVH_Box.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <NCollection_Vec3.hxx>
|
||||
|
||||
class Bnd_Box;
|
||||
class gp_Pnt;
|
||||
class TColgp_Array1OfPnt;
|
||||
|
||||
//! This class provides an interface for selecting volume manager,
|
||||
//! which is responsible for all overlap detection methods and
|
||||
//! calculation of minimum depth, distance to center of geometry
|
||||
//! and detected closest point on entity.
|
||||
class SelectBasics_SelectingVolumeManager
|
||||
{
|
||||
public:
|
||||
|
||||
//! Available selection types
|
||||
enum SelectionType { Point, Box, Polyline, Unknown };
|
||||
|
||||
public:
|
||||
|
||||
SelectBasics_SelectingVolumeManager() {};
|
||||
|
||||
virtual ~SelectBasics_SelectingVolumeManager() {};
|
||||
|
||||
virtual const Standard_Integer GetActiveSelectionType() const = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by box theBox
|
||||
virtual const Standard_Boolean Overlaps (const BVH_Box<Standard_Real, 3>& theBox,
|
||||
Standard_Real& theDepth) = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by axis-aligned bounding box with minimum
|
||||
//! corner at point theMinPt and maximum at point theMaxPt
|
||||
virtual const Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theMinPt,
|
||||
const NCollection_Vec3<Standard_Real>& theMaxPt) = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by point thePt
|
||||
virtual const Standard_Boolean Overlaps (const gp_Pnt& thePt,
|
||||
Standard_Real& theDepth) = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by planar convex polygon, which points
|
||||
//! are stored in theArrayOfPts, taking into account sensitivity type theSensType
|
||||
virtual const Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
|
||||
Standard_Integer theSensType,
|
||||
Standard_Real& theDepth) = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by line segment with start point at thePt1
|
||||
//! and end point at thePt2
|
||||
virtual const Standard_Boolean Overlaps (const gp_Pnt& thePt1,
|
||||
const gp_Pnt& thePt2,
|
||||
Standard_Real& theDepth) = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by triangle with vertices thePt1,
|
||||
//! thePt2 and thePt3, taking into account sensitivity type theSensType
|
||||
virtual const Standard_Boolean Overlaps (const gp_Pnt& thePt1,
|
||||
const gp_Pnt& thePt2,
|
||||
const gp_Pnt& thePt3,
|
||||
Standard_Integer theSensType,
|
||||
Standard_Real& theDepth) = 0;
|
||||
|
||||
//! Calculates distance from 3d projection of user-defined selection point
|
||||
//! to the given point theCOG
|
||||
virtual const Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) = 0;
|
||||
|
||||
virtual NCollection_Vec3<Standard_Real> DetectedPoint (const Standard_Real theDepth) const = 0;
|
||||
|
||||
protected:
|
||||
SelectionType myActiveSelectionType; //!< Active selection type: point, box or polyline
|
||||
};
|
||||
|
||||
#endif // _SelectBasics_SelectingVolumeManager_HeaderFile
|
@@ -16,131 +16,76 @@
|
||||
|
||||
deferred class SensitiveEntity from SelectBasics inherits TShared from MMgt
|
||||
|
||||
---Purpose: root class ; the inheriting classes will be able to give
|
||||
-- sensitive Areas for the dynamic selection algorithms
|
||||
---Purpose: root class; the inheriting classes will be able to give
|
||||
-- sensitive Areas for the dynamic selection algorithms
|
||||
|
||||
uses
|
||||
EntityOwner,
|
||||
ListOfBox2d,
|
||||
PickArgs,
|
||||
Array1OfPnt2d from TColgp,
|
||||
Box2d from Bnd
|
||||
BndBox3d from Select3D,
|
||||
PickResult,
|
||||
SelectingVolumeManager
|
||||
|
||||
is
|
||||
|
||||
|
||||
Initialize (OwnerId : EntityOwner;
|
||||
aSensitivityFactor : ShortReal from Standard =1);
|
||||
|
||||
|
||||
Set (me:mutable ; TheOwnerId : EntityOwner) is virtual;
|
||||
---Level: Public
|
||||
|
||||
Initialize (theOwnerId : EntityOwner;
|
||||
theSensFactor : Real from Standard = 2.0);
|
||||
|
||||
OwnerId(me) returns any EntityOwner is static;
|
||||
Set (me : mutable;
|
||||
theOwnerId : EntityOwner)
|
||||
is virtual;
|
||||
---Level: Public
|
||||
---Purpose: Sets owner of the entity
|
||||
|
||||
|
||||
OwnerId (me)
|
||||
returns any EntityOwner
|
||||
is static;
|
||||
---Level: Public
|
||||
---C++: return const&
|
||||
|
||||
|
||||
Areas(me:mutable; aresult : in out ListOfBox2d ) is deferred;
|
||||
---Level: Public
|
||||
---Purpose: to be implemented specifically by each type of
|
||||
-- sensitive primitive .
|
||||
--
|
||||
---Purpose: Returns pointer to owner of the entity
|
||||
|
||||
Matches (me : mutable;
|
||||
thePickArgs : PickArgs from SelectBasics;
|
||||
theMatchDMin : out Real from Standard;
|
||||
theMatchDepth : out Real from Standard) returns Boolean is deferred;
|
||||
|
||||
Matches (me : mutable;
|
||||
theMgr : out SelectingVolumeManager from SelectBasics;
|
||||
thePickResult : out PickResult from SelectBasics)
|
||||
returns Boolean is deferred;
|
||||
---Level: Public
|
||||
---Purpose: Checks whether the sensitive entity matches the picking detection
|
||||
-- area (close to the picking line). This method takes into account depth
|
||||
-- limits produced by abstract view: far/near planes, clippings.
|
||||
-- Please port existing implementations of your picking detection, which
|
||||
-- were done at Matches (X, Y, Tol, DMin) method to this one, introducing
|
||||
-- the depth checks. Please note that the previous method is suppressed
|
||||
-- and the virtual implementations are not used by OCC selection framework.
|
||||
-- The porting procedure for simple sensitives (or if you are not interested
|
||||
-- in implementing full scale depth checks) can be simplified to writing the
|
||||
-- following code snippet:
|
||||
-- @code
|
||||
-- { // example code for porting descendants of Select3D_SensitiveEntity
|
||||
--
|
||||
-- // invoke implementation of obsolete matches method (if implemented)...
|
||||
-- if (!Matches (thePickArgs.X(), thePickArgs.Y(), thePickArgs.Tolerance(), theMatchDMin))
|
||||
-- return Standard_False;
|
||||
--
|
||||
-- // invoke your implementation of computing depth (if implemented)...
|
||||
-- Standard_Real aDetectDepth = ComputeDepth (thePickArgs.PickLine());
|
||||
--
|
||||
-- return !thePickArgs.IsClipped(aDetectDepth);
|
||||
-- }
|
||||
-- @endcode
|
||||
-- @param thePickArgs [in] the picking arguments.
|
||||
-- @param theMatchDMin [out] the minimum distance on xy plane from point
|
||||
-- of picking to center of gravity of the detected sub-part of sensitive
|
||||
-- entity or the whole sensitive (e.g. used for resolving selection of
|
||||
-- coinciding circles, selection will be set to the one whose center is
|
||||
-- closest to the picking point).
|
||||
-- @param theMatchDepth [out] the minimum detected depth: depth of the
|
||||
-- closest detected sub-part of sensitive entity (or the whole sensitive).
|
||||
-- @return True if the sensitive matches the detection area.
|
||||
-- This method is an entry point for picking detection framework.
|
||||
-- The method is triggered when it is required to compose list of
|
||||
-- detected sensitive entities. The sensitives are filtered out from
|
||||
-- detection result if returned value is False. The passed entities are
|
||||
-- then can be sorted by "theDetectDist", "theDetectDepth" parameters.
|
||||
---Purpose: Checks whether the sensitive entity is overlapped by
|
||||
-- current selecting volume
|
||||
|
||||
Matches (me :mutable;
|
||||
XMin,YMin,XMax,YMax : Real from Standard;
|
||||
aTol: Real from Standard)
|
||||
returns Boolean
|
||||
is deferred;
|
||||
---Level: Public
|
||||
---Purpose: returns True if the box (Xmin,YMin)------(Xmax,Ymax)
|
||||
-- contains the SensitiveEntity.
|
||||
-- Necessary for selection using elastic boxes,or segments.
|
||||
|
||||
|
||||
Matches (me :mutable;
|
||||
Polyline:Array1OfPnt2d from TColgp;
|
||||
aBox:Box2d from Bnd;
|
||||
aTol: Real from Standard)
|
||||
returns Boolean
|
||||
is deferred;
|
||||
---Level: Public
|
||||
---Purpose: returns True if the polyline xi,yi
|
||||
-- contains the SensitiveEntity.
|
||||
-- Necessary for selection using polyline selection
|
||||
|
||||
NeedsConversion(me) returns Boolean is deferred ;
|
||||
|
||||
Is3D(me) returns Boolean from Standard is deferred;
|
||||
---Purpose: returns True if able to give 3D information
|
||||
-- (Depth,...). See Select3D
|
||||
|
||||
MaxBoxes(me) returns Integer is deferred;
|
||||
---Purpose: returns the max number of boxes the entity is able to give
|
||||
-- at a time
|
||||
|
||||
|
||||
SetSensitivityFactor(me:mutable; aFactor:ShortReal from Standard);
|
||||
SetSensitivityFactor (me : mutable;
|
||||
theSensFactor :Real from Standard);
|
||||
---C++: inline
|
||||
---Purpose: Allows to manage the sensitivity of the entity
|
||||
|
||||
SensitivityFactor(me) returns ShortReal from Standard;
|
||||
SensitivityFactor (me)
|
||||
returns Real from Standard;
|
||||
---C++: inline
|
||||
---Purpose: allows a better sensitivity for
|
||||
-- a specific entity in selection algorithms
|
||||
-- useful for small sized entities.
|
||||
|
||||
NbSubElements (me : mutable) returns Integer from Standard
|
||||
is deferred;
|
||||
---Purpose: Returns the number of sub-entities or elements in
|
||||
-- sensitive entity. Is used to determine if entity is
|
||||
-- complex and needs to pre-build BVH at the creation of
|
||||
-- sensitive entity step or is light-weighted so the tree
|
||||
-- can be build on demand with unnoticeable delay
|
||||
|
||||
BoundingBox (me : mutable) returns BndBox3d from Select3D is deferred;
|
||||
---Purpose: Returns bounding box of sensitive entity
|
||||
|
||||
BVH (me : mutable) is deferred;
|
||||
---Purpose: Builds BVH tree for sensitive if it is needed
|
||||
|
||||
Clear (me : mutable) is deferred;
|
||||
---Purpose: Clears up all the resources and memory allocated
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myOwnerId : EntityOwner from SelectBasics is protected;
|
||||
mySFactor : ShortReal from Standard;
|
||||
mySFactor : Real from Standard;
|
||||
end SensitiveEntity;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -15,23 +15,31 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <SelectBasics_SensitiveEntity.ixx>
|
||||
#include <TColStd_HArray1OfBoolean.hxx>
|
||||
|
||||
//=======================================================================
|
||||
// function : SelectBasics_SensitiveEntity
|
||||
// purpose : Creates new empty sensitive entity instance
|
||||
//=======================================================================
|
||||
SelectBasics_SensitiveEntity::SelectBasics_SensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theSensFactor)
|
||||
: myOwnerId (theOwnerId),
|
||||
mySFactor (theSensFactor) {}
|
||||
|
||||
//=======================================================================
|
||||
// function : Set
|
||||
// purpose : Sets owner of the entity
|
||||
//=======================================================================
|
||||
void SelectBasics_SensitiveEntity::Set (const Handle(SelectBasics_EntityOwner)& theOwnerId)
|
||||
{
|
||||
myOwnerId = theOwnerId;
|
||||
}
|
||||
|
||||
//==================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//==================================
|
||||
SelectBasics_SensitiveEntity
|
||||
::SelectBasics_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId,
|
||||
const Standard_ShortReal aFactor):
|
||||
myOwnerId(OwnerId),
|
||||
mySFactor(aFactor)
|
||||
{}
|
||||
|
||||
|
||||
void SelectBasics_SensitiveEntity
|
||||
::Set (const Handle(SelectBasics_EntityOwner)& TheOwnerId) { myOwnerId = TheOwnerId;}
|
||||
|
||||
const Handle(SelectBasics_EntityOwner)& SelectBasics_SensitiveEntity
|
||||
::OwnerId() const {return myOwnerId;}
|
||||
//=======================================================================
|
||||
// function : OwnerId
|
||||
// purpose : Returns pointer to owner of the entity
|
||||
//=======================================================================
|
||||
const Handle(SelectBasics_EntityOwner)& SelectBasics_SensitiveEntity::OwnerId() const
|
||||
{
|
||||
return myOwnerId;
|
||||
}
|
||||
|
@@ -12,10 +12,20 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
inline void SelectBasics_SensitiveEntity::
|
||||
SetSensitivityFactor(const Standard_ShortReal F)
|
||||
{mySFactor = F;}
|
||||
//=======================================================================
|
||||
// function : SetSensitivityFactor
|
||||
// purpose : Allows to manage the sensitivity of the entity
|
||||
//=======================================================================
|
||||
inline void SelectBasics_SensitiveEntity::SetSensitivityFactor (const Standard_Real theSensFactor)
|
||||
{
|
||||
mySFactor = theSensFactor;
|
||||
}
|
||||
|
||||
inline Standard_ShortReal SelectBasics_SensitiveEntity::
|
||||
SensitivityFactor() const
|
||||
{return mySFactor;}
|
||||
//=======================================================================
|
||||
// function : SensitivityFactor
|
||||
// purpose : Gets sensitivity factor for the entity
|
||||
//=======================================================================
|
||||
inline Standard_Real SelectBasics_SensitiveEntity::SensitivityFactor() const
|
||||
{
|
||||
return mySFactor;
|
||||
}
|
||||
|
@@ -1,89 +0,0 @@
|
||||
-- Created on: 1995-01-23
|
||||
-- Created by: Didier Piffault
|
||||
-- Copyright (c) 1995-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
-- Full Copy of Select_Rectangle (Didier Piffault 94)
|
||||
|
||||
|
||||
class SortAlgo from SelectBasics
|
||||
|
||||
---Purpose: Quickly selection of a rectangle in a set of rectangles
|
||||
-- Sort algorithm for 2D rectangles.
|
||||
|
||||
|
||||
uses Integer from Standard,
|
||||
Real from Standard,
|
||||
MapIteratorOfMapOfInteger from TColStd,
|
||||
MapOfInteger from TColStd,
|
||||
ListIteratorOfListOfInteger from TColStd,
|
||||
Box2d from Bnd,
|
||||
HArray1OfBox2d from Bnd,
|
||||
BoundSortBox2d from Bnd
|
||||
|
||||
|
||||
is Create
|
||||
---Purpose: Empty rectangle selector.
|
||||
returns SortAlgo from SelectBasics;
|
||||
|
||||
Create (ClippingRectangle : Box2d from Bnd;
|
||||
sizeOfSensitiveArea : Real from Standard;
|
||||
theRectangles : HArray1OfBox2d from Bnd)
|
||||
---Purpose: Creates a initialized selector.
|
||||
returns SortAlgo from SelectBasics;
|
||||
|
||||
Initialize (me : in out;
|
||||
ClippingRectangle : Box2d from Bnd;
|
||||
sizeOfSensitiveArea : Real from Standard;
|
||||
theRectangles : HArray1OfBox2d from Bnd)
|
||||
---Purpose: Clears and initializes the selector.
|
||||
is static;
|
||||
|
||||
|
||||
InitSelect (me : in out;
|
||||
x, y : Real from Standard)
|
||||
---Purpose: Searchs the items on this position.
|
||||
is static;
|
||||
|
||||
|
||||
InitSelect (me : in out;
|
||||
rect : Box2d from Bnd)
|
||||
---Purpose: Searchs the items in this rectangle.
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
More(me)
|
||||
---Purpose: Returns true if there is something selected.
|
||||
returns Boolean from Standard is static;
|
||||
|
||||
Next(me : in out)
|
||||
---Purpose: Sets value on the next selected item.
|
||||
is static;
|
||||
|
||||
Value(me)
|
||||
---Purpose: Returns the index of the selected rectangle.
|
||||
returns Integer from Standard is static;
|
||||
|
||||
|
||||
fields clipRect : Box2d from Bnd;
|
||||
sizeArea : Real from Standard;
|
||||
sortedRect : BoundSortBox2d from Bnd;
|
||||
myMap : MapOfInteger from TColStd;
|
||||
curResult : MapIteratorOfMapOfInteger from TColStd;
|
||||
|
||||
end SortAlgo;
|
||||
|
||||
|
||||
|
@@ -1,116 +0,0 @@
|
||||
// Created on: 1994-04-18
|
||||
// Created by: Didier PIFFAULT
|
||||
// Copyright (c) 1994-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <SelectBasics_SortAlgo.ixx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : SelectBasics_SortAlgo
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SelectBasics_SortAlgo::SelectBasics_SortAlgo()
|
||||
: sizeArea(0.)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : SelectBasics_SortAlgo
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SelectBasics_SortAlgo::SelectBasics_SortAlgo
|
||||
(const Bnd_Box2d& ClippingRectangle,
|
||||
const Standard_Real sizeOfSensitiveArea,
|
||||
const Handle(Bnd_HArray1OfBox2d)& theRectangles)
|
||||
: clipRect(ClippingRectangle), sizeArea(sizeOfSensitiveArea)
|
||||
{
|
||||
sortedRect.Initialize(clipRect, theRectangles);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectBasics_SortAlgo::Initialize(const Bnd_Box2d& ClippingRectangle,
|
||||
const Standard_Real sizeOfSensitiveArea,
|
||||
const Handle(Bnd_HArray1OfBox2d)& theRectangles)
|
||||
{
|
||||
clipRect=ClippingRectangle;
|
||||
sizeArea=sizeOfSensitiveArea;
|
||||
sortedRect.Initialize(clipRect, theRectangles);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectBasics_SortAlgo::InitSelect(const Standard_Real x,
|
||||
const Standard_Real y)
|
||||
{
|
||||
Bnd_Box2d rep;
|
||||
rep.Set(gp_Pnt2d(x, y));
|
||||
rep.Enlarge(sizeArea);
|
||||
myMap.Clear() ;
|
||||
TColStd_ListIteratorOfListOfInteger It(sortedRect.Compare(rep));
|
||||
for(;It.More();It.Next()){
|
||||
myMap.Add(It.Value());
|
||||
}
|
||||
curResult.Initialize(myMap);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectBasics_SortAlgo::InitSelect(const Bnd_Box2d& rect)
|
||||
{
|
||||
myMap.Clear() ;
|
||||
TColStd_ListIteratorOfListOfInteger It(sortedRect.Compare(rect));
|
||||
for(;It.More();It.Next()){
|
||||
myMap.Add(It.Value());
|
||||
}
|
||||
curResult.Initialize(myMap);
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : More
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectBasics_SortAlgo::More() const
|
||||
{
|
||||
return curResult.More();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Next
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectBasics_SortAlgo::Next()
|
||||
{
|
||||
curResult.Next();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer SelectBasics_SortAlgo::Value() const
|
||||
{
|
||||
return curResult.Key();
|
||||
}
|
||||
|
Reference in New Issue
Block a user