mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
63
src/SelectBasics/SelectBasics.cdl
Executable file
63
src/SelectBasics/SelectBasics.cdl
Executable file
@@ -0,0 +1,63 @@
|
||||
-- File: SelectBasics.cdl
|
||||
-- Created: Mon Jan 23 10:57:48 1995
|
||||
-- Author: Mister rmi
|
||||
-- <rmi@photon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
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 .
|
||||
|
||||
uses
|
||||
Bnd,
|
||||
TCollection,
|
||||
TColStd,
|
||||
Standard,
|
||||
MMgt,
|
||||
gp,
|
||||
TColgp,
|
||||
TopLoc
|
||||
|
||||
|
||||
is
|
||||
|
||||
|
||||
deferred class EntityOwner;
|
||||
---Purpose: entity able to set multiple owners for a SensitiveEntity;
|
||||
|
||||
class SortAlgo;
|
||||
---Purpose: sort algorithm for 2D rectangles.
|
||||
|
||||
class BasicTool;
|
||||
---Purpose: give Tools for sorting Selection results
|
||||
-- (example : sensitive entities matching)
|
||||
|
||||
class ListOfBox2d instantiates List from TCollection
|
||||
(Box2d from Bnd);
|
||||
|
||||
|
||||
class SequenceOfOwner instantiates Sequence from TCollection
|
||||
(EntityOwner);
|
||||
|
||||
|
||||
|
||||
deferred class SensitiveEntity;
|
||||
---Purpose: general entity able to give sensitive areas
|
||||
|
||||
|
||||
class ListOfSensitive instantiates List from TCollection
|
||||
(SensitiveEntity);
|
||||
|
||||
|
||||
MaxOwnerPriority returns Integer;
|
||||
|
||||
MinOwnerPriority returns Integer;
|
||||
|
||||
|
||||
end SelectBasics;
|
17
src/SelectBasics/SelectBasics.cxx
Executable file
17
src/SelectBasics/SelectBasics.cxx
Executable file
@@ -0,0 +1,17 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectBasics.cxx
|
||||
// Created: Thu Feb 23 15:02:41 1995
|
||||
// Author: Mister rmi
|
||||
// <rmi>
|
||||
|
||||
|
||||
|
||||
#include <SelectBasics.ixx>
|
||||
|
||||
|
||||
Standard_Integer SelectBasics::MaxOwnerPriority()
|
||||
{return 9;}
|
||||
|
||||
Standard_Integer SelectBasics::MinOwnerPriority()
|
||||
{return 0;}
|
||||
|
50
src/SelectBasics/SelectBasics_BasicTool.cdl
Executable file
50
src/SelectBasics/SelectBasics_BasicTool.cdl
Executable file
@@ -0,0 +1,50 @@
|
||||
-- File: SelectBasics_BasicTool.cdl
|
||||
-- Created: Thu Jun 8 11:04:56 1995
|
||||
-- Author: Robert COUBLANC
|
||||
-- <rob@photon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
class BasicTool from SelectBasics
|
||||
|
||||
---Purpose:
|
||||
|
||||
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;
|
143
src/SelectBasics/SelectBasics_BasicTool.cxx
Executable file
143
src/SelectBasics/SelectBasics_BasicTool.cxx
Executable file
@@ -0,0 +1,143 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectBasics_BasicTool.cxx
|
||||
// Created: Thu Jun 8 11:08:55 1995
|
||||
// Author: Robert COUBLANC
|
||||
// <rob>
|
||||
|
||||
|
||||
#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)
|
||||
{
|
||||
Standard_Boolean Found= Standard_False;
|
||||
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;
|
||||
}
|
67
src/SelectBasics/SelectBasics_EntityOwner.cdl
Executable file
67
src/SelectBasics/SelectBasics_EntityOwner.cdl
Executable file
@@ -0,0 +1,67 @@
|
||||
-- File: SelectBasics_EntityOwner.cdl
|
||||
-- Created: Thu Feb 9 14:58:14 1995
|
||||
-- Author: Mister rmi
|
||||
-- <rmi@photon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
|
||||
deferred class EntityOwner from SelectBasics inherits TShared from MMgt
|
||||
|
||||
---Purpose: defines an abstract owner of sensitive primitives.
|
||||
-- Owners are typically used to establish a connection
|
||||
-- between sensitive entities and high-level objects (e.g. presentations).
|
||||
--
|
||||
-- Priority : It's possible to give a priority:
|
||||
-- the scale : [0-9] ; the default priority is 0
|
||||
-- it allows the predominance of one selected object upon
|
||||
-- another one if many objects are selected at the same time
|
||||
--
|
||||
--
|
||||
-- example : Selection of shapes : the owners are
|
||||
-- selectable objects (presentations)
|
||||
--
|
||||
-- a user can give vertex priority [3], edges [2] faces [1] shape [0],
|
||||
-- so that if during selection one vertex one edge and one face are
|
||||
-- simultaneously detected, the vertex will only be hilighted.
|
||||
|
||||
|
||||
uses
|
||||
Location from TopLoc
|
||||
|
||||
is
|
||||
|
||||
Initialize (aPriority: Integer = 0) ;
|
||||
---Level: Public
|
||||
|
||||
Set (me:mutable; aPriority :Integer) is static;
|
||||
---Level: Public
|
||||
---Purpose: sets the selectable priority of the owner
|
||||
---C++: inline
|
||||
|
||||
Priority(me) returns Integer is static;
|
||||
---Level: Public
|
||||
---C++: inline
|
||||
|
||||
-- Deferred methods dealing with locations.
|
||||
-- Used in Select3D package.
|
||||
HasLocation(me) returns Boolean from Standard is deferred;
|
||||
|
||||
SetLocation(me:mutable; aLoc : Location from TopLoc) is deferred;
|
||||
|
||||
ResetLocation(me:mutable) is deferred;
|
||||
|
||||
Location(me) returns Location from TopLoc is deferred;
|
||||
---C++: return const&
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
mypriority : Integer is protected;
|
||||
|
||||
end EntityOwner;
|
||||
|
||||
|
||||
|
23
src/SelectBasics/SelectBasics_EntityOwner.cxx
Executable file
23
src/SelectBasics/SelectBasics_EntityOwner.cxx
Executable file
@@ -0,0 +1,23 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectBasics_EntityOwner.cxx
|
||||
// Created: Thu Feb 9 15:19:46 1995
|
||||
// Author: Mister rmi
|
||||
// <rmi>
|
||||
|
||||
|
||||
#include <SelectBasics_EntityOwner.ixx>
|
||||
|
||||
|
||||
//========================================
|
||||
// Function : Create
|
||||
// Purpose :
|
||||
//========================================
|
||||
SelectBasics_EntityOwner
|
||||
::SelectBasics_EntityOwner (const Standard_Integer aPriority):
|
||||
mypriority(aPriority)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
||||
|
12
src/SelectBasics/SelectBasics_EntityOwner.lxx
Executable file
12
src/SelectBasics/SelectBasics_EntityOwner.lxx
Executable file
@@ -0,0 +1,12 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectBasics_EntityOwner.lxx
|
||||
// Created: Thu Feb 23 11:50:49 1995
|
||||
// Author: Mister rmi
|
||||
// <rmi>
|
||||
|
||||
|
||||
inline void SelectBasics_EntityOwner::Set (const Standard_Integer aPriority)
|
||||
{mypriority = aPriority;}
|
||||
|
||||
inline Standard_Integer SelectBasics_EntityOwner::Priority() const
|
||||
{return mypriority;}
|
112
src/SelectBasics/SelectBasics_SensitiveEntity.cdl
Executable file
112
src/SelectBasics/SelectBasics_SensitiveEntity.cdl
Executable file
@@ -0,0 +1,112 @@
|
||||
-- File: SelectBasics_SensitiveEntity.cdl
|
||||
-- Created: Mon Jan 23 11:05:19 1995
|
||||
-- Author: Mister rmi
|
||||
-- <rmi@photon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
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
|
||||
|
||||
uses
|
||||
EntityOwner,
|
||||
ListOfBox2d,
|
||||
Array1OfPnt2d from TColgp,
|
||||
Box2d from Bnd
|
||||
|
||||
is
|
||||
|
||||
|
||||
Initialize (OwnerId : EntityOwner;
|
||||
aSensitivityFactor : ShortReal from Standard =1);
|
||||
|
||||
|
||||
Set (me:mutable ; TheOwnerId : EntityOwner) is static;
|
||||
---Level: Public
|
||||
|
||||
|
||||
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 .
|
||||
--
|
||||
|
||||
Matches (me :mutable;
|
||||
X,Y : Real from Standard;
|
||||
aTol: Real from Standard;
|
||||
DMin: out Real from Standard)
|
||||
returns Boolean
|
||||
is deferred;
|
||||
---Level: Public
|
||||
---Purpose: returns True if the object is very close to the
|
||||
-- sensitive areas it gave to the selector...
|
||||
-- returns the minimum distance found if no match;
|
||||
--
|
||||
-- to be implemented specifically by each type of
|
||||
-- sensitive primitive .
|
||||
|
||||
|
||||
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
|
||||
|
||||
Depth(me) returns Real from Standard is virtual;
|
||||
---Level: Internal
|
||||
---Purpose: Sort Selected entities according to depth...
|
||||
|
||||
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);
|
||||
---C++: inline
|
||||
|
||||
SensitivityFactor(me) returns ShortReal from Standard;
|
||||
---C++: inline
|
||||
---Purpose: allows a better sensitivity for
|
||||
-- a specific entity in selection algorithms
|
||||
-- useful for small sized entities.
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myOwnerId : EntityOwner from SelectBasics is protected;
|
||||
mySFactor : ShortReal from Standard;
|
||||
end SensitiveEntity;
|
||||
|
||||
|
||||
|
||||
|
||||
|
32
src/SelectBasics/SelectBasics_SensitiveEntity.cxx
Executable file
32
src/SelectBasics/SelectBasics_SensitiveEntity.cxx
Executable file
@@ -0,0 +1,32 @@
|
||||
//--- File: SelectBasics_SensitiveEntity.cxx
|
||||
//-- Created: Mon Jan 23 11:05:19 1995
|
||||
//-- Author: Mister rmi
|
||||
//-- <rmi@photon>
|
||||
//---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
#include <SelectBasics_SensitiveEntity.ixx>
|
||||
|
||||
|
||||
|
||||
//==================================
|
||||
//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;}
|
||||
|
||||
Standard_Real SelectBasics_SensitiveEntity::Depth() const
|
||||
{return 0.0;}
|
||||
|
8
src/SelectBasics/SelectBasics_SensitiveEntity.lxx
Executable file
8
src/SelectBasics/SelectBasics_SensitiveEntity.lxx
Executable file
@@ -0,0 +1,8 @@
|
||||
|
||||
inline void SelectBasics_SensitiveEntity::
|
||||
SetSensitivityFactor(const Standard_ShortReal F)
|
||||
{mySFactor = F;}
|
||||
|
||||
inline Standard_ShortReal SelectBasics_SensitiveEntity::
|
||||
SensitivityFactor() const
|
||||
{return mySFactor;}
|
77
src/SelectBasics/SelectBasics_SortAlgo.cdl
Executable file
77
src/SelectBasics/SelectBasics_SortAlgo.cdl
Executable file
@@ -0,0 +1,77 @@
|
||||
-- File: SelectBasics_SortAlgo.cdl
|
||||
-- Created: Mon Jan 23 17:15:55 1995
|
||||
-- Author: Didier Piffault
|
||||
-- <rmi@photon>
|
||||
-- Full Copy of Select_Rectangle (Didier Piffault 94)
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class SortAlgo from SelectBasics
|
||||
|
||||
---Purpose: Quickly selection of a rectangle in a set of 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;
|
||||
|
||||
|
||||
|
105
src/SelectBasics/SelectBasics_SortAlgo.cxx
Executable file
105
src/SelectBasics/SelectBasics_SortAlgo.cxx
Executable file
@@ -0,0 +1,105 @@
|
||||
// File: SelectBasics_SortAlgo.cxx
|
||||
// Created: Mon Apr 18 14:30:38 1994
|
||||
// Author: Didier PIFFAULT
|
||||
// <dpf@zerox>
|
||||
|
||||
#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