1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +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

@@ -20,11 +20,10 @@
//==================================================
Select3D_SensitiveBox::Select3D_SensitiveBox(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Bnd_Box& BBox):
const Bnd_Box& BBox):
Select3D_SensitiveEntity(OwnerId),
mybox3d(BBox){}
//==================================================
// Function: Constructor
// Purpose :
@@ -32,28 +31,29 @@ mybox3d(BBox){}
Select3D_SensitiveBox::
Select3D_SensitiveBox(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real ZMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real ZMax):
const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real ZMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real ZMax):
Select3D_SensitiveEntity(OwnerId)
{
mybox3d.Update(XMin,YMin,ZMin,XMax,YMax,ZMax);
}
//==================================================
// Function: Project
// Purpose :
//==================================================
void Select3D_SensitiveBox::
Project(const Handle(Select3D_Projector)& aProj)
{
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
if(HasLocation()){
if(HasLocation())
{
Bnd_Box B = mybox3d.Transformed(Location().Transformation());
ProjectBox(aProj,B);
}
@@ -62,14 +62,14 @@ Project(const Handle(Select3D_Projector)& aProj)
}
//==================================================
// Function:
// Function: Areas
// Purpose :
//==================================================
void Select3D_SensitiveBox::
Areas(SelectBasics_ListOfBox2d& aSeq)
{ aSeq.Append(mybox2d);}
//=======================================================================
//function : GetConnected
//purpose :
@@ -84,43 +84,39 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveBox::GetConnected(const TopLo
return NiouEnt;
}
//==================================================
// Function:
// Function: Matches
// Purpose :
//==================================================
Standard_Boolean Select3D_SensitiveBox::
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
DMin=0.;
return Standard_True;
}
//==================================================
// Function:
// Function: Matches
// Purpose :
//==================================================
Standard_Boolean Select3D_SensitiveBox::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
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);
return(!BoundBox.IsOut(mybox2d));
}
//=======================================================================
//function : Matches
//purpose :
@@ -128,13 +124,12 @@ Matches (const Standard_Real XMin,
Standard_Boolean Select3D_SensitiveBox::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
return(!aBox.IsOut(mybox2d));
}
//=======================================================================
//function : Dump
//purpose :
@@ -152,10 +147,11 @@ void Select3D_SensitiveBox::Dump(Standard_OStream& S,const Standard_Boolean Full
S<<"\t\t PMin [ "<<XMin<<" , "<<YMin<<" , "<<ZMin<<" ]";
S<<"\t\t PMax [ "<<XMax<<" , "<<YMax<<" , "<<ZMax<<" ]"<<endl;
if(FullDump){
if(FullDump)
{
// S<<"\t\t\tOwner:"<<myOwnerId<<endl;
Select3D_SensitiveEntity::DumpBox(S,mybox2d);}
Select3D_SensitiveEntity::DumpBox(S,mybox2d);
}
}
@@ -165,7 +161,7 @@ void Select3D_SensitiveBox::Dump(Standard_OStream& S,const Standard_Boolean Full
//=======================================================================
void Select3D_SensitiveBox::ProjectBox(const Handle(Select3D_Projector)& aPrj,
const Bnd_Box& aBox)
const Bnd_Box& aBox)
{
mybox2d.SetVoid();
gp_Pnt2d curp2d;

View File

@@ -25,7 +25,9 @@ uses
Location from TopLoc,
Pnt from Select3D,
Pnt2d from Select3D,
Projector from Select3D
Projector from Select3D,
SensitiveEntity from Select3D,
Circle from Geom
is
Create (OwnerId : EntityOwner from SelectBasics;
@@ -68,7 +70,7 @@ is
FilledCircle : Boolean from Standard = Standard_False)
returns mutable SensitiveCircle;
---Purpose: Constructs the sensitive circle object defined by the
-- owner OwnerId, the array of points apolyg3d, and the Boolean FilledCircle.
-- owner OwnerId, the array of points apolyg3d, and the Boolean FilledCircle.
-- If the length of apolyg3d is more then 1, the first point of apolyg3d
-- must be equal to the last point of apolyg3d.
@@ -102,7 +104,13 @@ is
GetPoint3d(me;rank:Integer) returns Pnt from gp;
---Level: Internal
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
GetConnected(me: mutable; theLocation : Location from TopLoc)
returns SensitiveEntity from Select3D
is redefined virtual;
---Level: Public
---Purpose: Returns the copy of this.
Project(me: mutable;aProjector: Projector from Select3D) is redefined virtual;
@@ -116,6 +124,9 @@ fields
myDetectedIndex : Integer from Standard; -- used for depth...
myCenter2D : Pnt2d from Select3D; -- used for Matches()
myCenter3D : Pnt from Select3D; -- used for Matches()
myCircle : Circle from Geom;
mystart : Real from Standard; -- used for GetConnected()
myend : Real from Standard; -- used for GetConnected()
end SensitiveCircle;

View File

@@ -15,10 +15,7 @@
#include <Select3D_Pnt2d.hxx>
#include <Select3D_Projector.hxx>
//=======================================================================
//function : Select3D_SensitiveCircle (constructeur)
//purpose : Definition of a sensitive circle
//=======================================================================
static Standard_Integer S3D_GetCircleNBPoints(const Handle(Geom_Circle)& C,
const Standard_Integer anInputNumber)
{
@@ -26,6 +23,7 @@ static Standard_Integer S3D_GetCircleNBPoints(const Handle(Geom_Circle)& C,
return 2*anInputNumber+1;
return 1;
}
static Standard_Integer S3D_GetArcNBPoints(const Handle(Geom_Circle)& C,
const Standard_Integer anInputNumber)
{
@@ -33,19 +31,28 @@ static Standard_Integer S3D_GetArcNBPoints(const Handle(Geom_Circle)& C,
return 2*anInputNumber-1;
return 1;
}
//=======================================================================
//function : Select3D_SensitiveCircle (constructor)
//purpose : Definition of a sensitive circle
//=======================================================================
Select3D_SensitiveCircle::
Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom_Circle)& TheCircle,
const Standard_Boolean FilledCircle,
const Standard_Integer NbPoints):
const Handle(Geom_Circle)& TheCircle,
const Standard_Boolean FilledCircle,
const Standard_Integer NbPoints):
Select3D_SensitivePoly(OwnerId, S3D_GetCircleNBPoints(TheCircle,NbPoints)),
myFillStatus(FilledCircle),
myDetectedIndex(-1)
myDetectedIndex(-1),
myCircle(TheCircle),
mystart(0),
myend(0)
{
if(mynbpoints!=1){
gp_Pnt p1,p2;//,pmid;
gp_Vec v1;//,v2;
if(mynbpoints!=1)
{
gp_Pnt p1,p2;
gp_Vec v1;
Standard_Real ustart = TheCircle->FirstParameter(),uend = TheCircle->LastParameter();
Standard_Real du = (uend-ustart)/NbPoints;
Standard_Real R = TheCircle->Radius();
@@ -76,40 +83,42 @@ myDetectedIndex(-1)
// Get myCenter3D
myCenter3D = ((Select3D_Pnt*)mypolyg3d)[0];
}
}
//=======================================================================
//function : Select3D_SensitiveCircle (constructeur)
//function : Select3D_SensitiveCircle (constructor)
//purpose : Definition of a sensitive arc
//=======================================================================
Select3D_SensitiveCircle::
Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom_Circle)& TheCircle,
const Standard_Real u1,
const Standard_Real u2,
const Standard_Boolean FilledCircle,
const Standard_Integer NbPoints):
const Handle(Geom_Circle)& TheCircle,
const Standard_Real u1,
const Standard_Real u2,
const Standard_Boolean FilledCircle,
const Standard_Integer NbPoints):
Select3D_SensitivePoly(OwnerId, S3D_GetArcNBPoints(TheCircle,NbPoints)),
myFillStatus(FilledCircle),
myDetectedIndex(-1)
myDetectedIndex(-1),
myCircle(TheCircle),
mystart(u1),
myend(u2)
{
if(mynbpoints > 1){
gp_Pnt p1,p2;//,pmid;
gp_Vec v1;//,v2;
if(mynbpoints > 1)
{
gp_Pnt p1,p2;
gp_Vec v1;
Standard_Real ustart = u1;
Standard_Real uend = u2;
if (u1 > u2)
{
mystart = u2;
myend = u1;
}
if (u1 > u2) {ustart=u1;uend=u2;}
Standard_Real du = (uend-ustart)/(NbPoints-1);
Standard_Real du = (myend-mystart)/(NbPoints-1);
Standard_Real R = TheCircle->Radius();
Standard_Integer rank = 1;
Standard_Real curu =ustart;
Standard_Real curu = mystart;
for(Standard_Integer i=1;i<=NbPoints-1;i++)
{
@@ -124,7 +133,7 @@ myDetectedIndex(-1)
rank++;
curu+=du;
}
TheCircle->D0(uend,p1);
TheCircle->D0(myend,p1);
((Select3D_Pnt*)mypolyg3d)[NbPoints*2-2] = p1;
// Get myCenter3D
myCenter3D = TheCircle->Location();
@@ -141,12 +150,15 @@ myDetectedIndex(-1)
//function : Select3D_SensitiveCircle
//purpose :
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(TColgp_HArray1OfPnt)& Thepolyg3d,
const Standard_Boolean FilledCircle):
const Handle(TColgp_HArray1OfPnt)& Thepolyg3d,
const Standard_Boolean FilledCircle):
Select3D_SensitivePoly(OwnerId, Thepolyg3d),
myFillStatus(FilledCircle),
myDetectedIndex(-1)
myDetectedIndex(-1),
mystart(0),
myend(0)
{
if (mynbpoints > 1)
ComputeCenter3D();
@@ -154,12 +166,19 @@ myDetectedIndex(-1)
myCenter3D = ((Select3D_Pnt*)mypolyg3d)[0];
}
//=======================================================================
//function : Select3D_SensitiveCircle
//purpose :
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
const TColgp_Array1OfPnt& Thepolyg3d,
const Standard_Boolean FilledCircle):
const TColgp_Array1OfPnt& Thepolyg3d,
const Standard_Boolean FilledCircle):
Select3D_SensitivePoly(OwnerId, Thepolyg3d),
myFillStatus(FilledCircle),
myDetectedIndex(-1)
myDetectedIndex(-1),
mystart(0),
myend(0)
{
if (mynbpoints > 1)
ComputeCenter3D();
@@ -167,13 +186,17 @@ myDetectedIndex(-1)
myCenter3D = ((Select3D_Pnt*)mypolyg3d)[0];
}
//=======================================================================
//function : Matches
//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveCircle::
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
if(mynbpoints>1)
{
Standard_Boolean Found = Standard_False;
@@ -229,15 +252,19 @@ Matches(const Standard_Real X,
return Found;
}
return Standard_True;
}
//=======================================================================
//function : Matches
//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveCircle::
Matches(const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
myDetectedIndex =-1;
Bnd_Box2d abox;
@@ -249,7 +276,6 @@ Matches(const Standard_Real XMin,
return Standard_True;
}
//=======================================================================
//function : Matches
//purpose :
@@ -257,8 +283,8 @@ Matches(const Standard_Real XMin,
Standard_Boolean Select3D_SensitiveCircle::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
@@ -267,24 +293,31 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer j=1;j<=mynbpoints;j++){
for(Standard_Integer j=1;j<=mynbpoints;j++)
{
Standard_Integer RES = aClassifier2d.SiDans(((Select3D_Pnt2d*)mypolyg2d)[j-1]);
if(RES!=1) return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : ArrayBounds
//purpose :
//=======================================================================
void Select3D_SensitiveCircle::
ArrayBounds(Standard_Integer & Low,
Standard_Integer & Up) const
Standard_Integer & Up) const
{
Low = 0;
Up = mynbpoints-1;
}
//=======================================================================
//function : GetPoint3d
//purpose :
//=======================================================================
gp_Pnt Select3D_SensitiveCircle::
GetPoint3d(const Standard_Integer Rank) const
@@ -317,9 +350,11 @@ void Select3D_SensitiveCircle::Dump(Standard_OStream& S,const Standard_Boolean F
S<<"\t\tExisting Location"<<endl;
if(FullDump){
if(FullDump)
{
Standard_Integer EndIndex = isclosed? mynbpoints-2 : mynbpoints-1, nbpt(0);
for(Standard_Integer i=0;i<EndIndex;i+=2){
for(Standard_Integer i=0;i<EndIndex;i+=2)
{
CDG +=((Select3D_Pnt*)mypolyg3d)[i];
nbpt++;
}
@@ -333,30 +368,85 @@ void Select3D_SensitiveCircle::Dump(Standard_OStream& S,const Standard_Boolean F
}
}
//=======================================================================
//function : ComputeDepth
//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveCircle::ComputeDepth(const gp_Lin& EyeLine) const
{
gp_Pnt CDG;
if(myDetectedIndex==-1){
if(myDetectedIndex==-1)
{
gp_XYZ CurCoord(((Select3D_Pnt*)mypolyg3d)[0]);
Standard_Boolean isclosed = 1==mynbpoints;
Standard_Integer EndIndex = isclosed ? mynbpoints-2 : mynbpoints-1, nbpt(0);
for(Standard_Integer i=1;i<EndIndex;i+=2){
for(Standard_Integer i=1;i<EndIndex;i+=2)
{
CurCoord +=((Select3D_Pnt*)mypolyg3d)[i];
nbpt++;
}
CDG.SetXYZ(CurCoord);
}
else{
else
{
gp_XYZ CurCoord(((Select3D_Pnt*)mypolyg3d)[myDetectedIndex]);
CurCoord+=((Select3D_Pnt*)mypolyg3d)[myDetectedIndex+1];
CurCoord+=((Select3D_Pnt*)mypolyg3d)[myDetectedIndex+2];
CDG.SetXYZ(CurCoord);
}
return ElCLib::Parameter(EyeLine,CDG);
return ElCLib::Parameter(EyeLine,CDG);
}
//=======================================================================
//function : GetConnected
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected(const TopLoc_Location& theLocation)
{
// Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity;
// this was constructed using Handle(Geom_Circle)
if(!myCircle.IsNull())
{
if((myend-mystart) > Precision::Confusion())
{
// Arc
aNewEntity = new Select3D_SensitiveCircle(myOwnerId, myCircle, mystart, myend, myFillStatus);
}
else
{
// Circle
aNewEntity = new Select3D_SensitiveCircle(myOwnerId, myCircle, myFillStatus);
}
}
// this was constructed using TColgp_Array1OfPnt
else
{
TColgp_Array1OfPnt aPolyg(1, mynbpoints);
for(Standard_Integer i = 1; i <= mynbpoints; ++i)
{
aPolyg.SetValue(i, ((Select3D_Pnt*)mypolyg3d)[i-1]);
}
aNewEntity = new Select3D_SensitiveCircle(myOwnerId, aPolyg, myFillStatus);
}
if(HasLocation())
aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation);
return aNewEntity;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void Select3D_SensitiveCircle::Project(const Handle_Select3D_Projector &aProjector)
{
Select3D_SensitivePoly::Project(aProjector);
@@ -366,21 +456,26 @@ void Select3D_SensitiveCircle::Project(const Handle_Select3D_Projector &aProject
myCenter2D = aCenter;
}
//=======================================================================
//function : ComputeCenter3D
//purpose :
//=======================================================================
void Select3D_SensitiveCircle::ComputeCenter3D()
{
gp_XYZ aCenter(0., 0., 0.);
if (mynbpoints > 1)
if(mynbpoints > 1)
{
// The mass of points system
Standard_Integer aMass = mynbpoints - 1;
// Find the circle barycenter
for (Standard_Integer i = 0; i < mynbpoints-1; ++i)
for(Standard_Integer i = 0; i < mynbpoints-1; ++i)
{
aCenter += ((Select3D_Pnt*)mypolyg3d)[i];
}
myCenter3D = aCenter / aMass;
}
else if (mynbpoints == 1)
else if (mynbpoints == 1)
{
myCenter3D = ((Select3D_Pnt*)mypolyg3d)[0];
}
@@ -388,8 +483,8 @@ void Select3D_SensitiveCircle::ComputeCenter3D()
// It can lead to incorrect computation of
// parameter DMin in method Matches.
// In spite of this myCenter3D isn't left uninitialized
else
{
else
{
myCenter3D = aCenter;
}
}

View File

@@ -24,7 +24,8 @@ uses
Array1OfPnt2d from TColgp,
HArray1OfPnt from TColgp,
Box2d from Bnd,
Location from TopLoc
Location from TopLoc,
SensitiveEntity from Select3D
is
@@ -50,7 +51,7 @@ is
---Level: Public
---Purpose: Creation of Sensitive Curve from Points.
-- Warning : This Method should disappear in the next version...
Matches(me :mutable;
X,Y : Real from Standard;
aTol: Real from Standard;
@@ -85,9 +86,16 @@ is
---Category: Internal Methods
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
LoadPoints(me:mutable;aCurve:Curve from Geom;NbPoints: Integer) is static private;
LoadPoints(me:mutable;aCurve:Curve from Geom;NbPoints: Integer) is static private;
GetConnected(me: mutable; theLocation : Location from TopLoc)
returns SensitiveEntity from Select3D
is redefined virtual;
---Level: Public
---Purpose: Returns the copy of this
fields
mylastseg : Integer from Standard;
myCurve : Curve from Geom;
end SensitiveCurve;

View File

@@ -15,39 +15,44 @@
//==================================================
// Function:
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitiveCurve
::Select3D_SensitiveCurve(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom_Curve)& C,
const Standard_Integer NbPoints):
const Handle(Geom_Curve)& C,
const Standard_Integer NbPoints):
Select3D_SensitivePoly(OwnerId, NbPoints),
mylastseg(0)
mylastseg(0),
myCurve(C)
{
LoadPoints(C,NbPoints);
}
//==================================================
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitiveCurve
::Select3D_SensitiveCurve(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(TColgp_HArray1OfPnt)& ThePoints):
const Handle(TColgp_HArray1OfPnt)& ThePoints):
Select3D_SensitivePoly(OwnerId, ThePoints),
mylastseg(0)
mylastseg(0)
{
}
//==================================================
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitiveCurve
::Select3D_SensitiveCurve(const Handle(SelectBasics_EntityOwner)& OwnerId,
const TColgp_Array1OfPnt& ThePoints):
const TColgp_Array1OfPnt& ThePoints):
Select3D_SensitivePoly(OwnerId, ThePoints),
mylastseg(0)
mylastseg(0)
{
}
@@ -55,11 +60,12 @@ mylastseg(0)
// Function: Matches
// Purpose :
//==================================================
Standard_Boolean Select3D_SensitiveCurve
::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
Standard_Integer Rank;
TColgp_Array1OfPnt2d aArrayOf2dPnt(1, mynbpoints);
@@ -73,11 +79,10 @@ Standard_Boolean Select3D_SensitiveCurve
mylastseg = Rank;
// compute and validate the depth (::Depth()) along the eyeline
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin);
}
return Standard_False;
}
//==================================================
// Function: Matches
// Purpose : know if a box touches the projected polygon
@@ -86,11 +91,11 @@ Standard_Boolean Select3D_SensitiveCurve
Standard_Boolean Select3D_SensitiveCurve::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
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);
@@ -108,9 +113,9 @@ Matches (const Standard_Real XMin,
Standard_Boolean Select3D_SensitiveCurve::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
Standard_Real Tolu,Tolv;
@@ -118,17 +123,16 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer j=0;j<mynbpoints;j++){
for(Standard_Integer j=0;j<mynbpoints;j++)
{
Standard_Integer RES = aClassifier2d.SiDans(((Select3D_Pnt2d*)mypolyg2d)[j]);
if(RES!=1) return Standard_False;
}
return Standard_True;
}
//==================================================
// Function:
// Function: LoadPoints
// Purpose :
//==================================================
@@ -160,11 +164,13 @@ void Select3D_SensitiveCurve::Dump(Standard_OStream& S,const Standard_Boolean Fu
S<<"\t\tNumber Of Points :"<<mynbpoints<<endl;
if(FullDump){
if(FullDump)
{
// S<<"\t\t\tOwner:"<<myOwnerId<<endl;
Select3D_SensitiveEntity::DumpBox(S,mybox2d);
}
}
//=======================================================================
//function : ComputeDepth
//purpose :
@@ -172,10 +178,43 @@ void Select3D_SensitiveCurve::Dump(Standard_OStream& S,const Standard_Boolean Fu
Standard_Real Select3D_SensitiveCurve::ComputeDepth(const gp_Lin& EyeLine) const
{
if(mylastseg==0) return Precision::Infinite(); // non implemente actuellement...
gp_XYZ TheCDG(((Select3D_Pnt*)mypolyg3d)[mylastseg]);
TheCDG+=((Select3D_Pnt*)mypolyg3d)[mylastseg+1];
TheCDG/=2.;
return ElCLib::Parameter(EyeLine,gp_Pnt(TheCDG));
}
//=======================================================================
//function : GetConnected
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveCurve::GetConnected(const TopLoc_Location &theLocation)
{
// Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity;
// this was constructed using Handle(Geom_Curve)
if (!myCurve.IsNull())
{
aNewEntity = new Select3D_SensitiveCurve(myOwnerId, myCurve);
}
// this was constructed using TColgp_HArray1OfPnt
else
{
Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt(1, mynbpoints);
// Fill the array with points from mypolyg3d
for (Standard_Integer i = 1; i <= mynbpoints; ++i)
{
aPoints->SetValue(i, ((Select3D_Pnt*)mypolyg3d)[i-1]);
}
aNewEntity = new Select3D_SensitiveCurve(myOwnerId, aPoints);
}
if (HasLocation())
aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation);
return aNewEntity;
}

View File

@@ -62,7 +62,12 @@ is
GetConnected(me:mutable;aLocation: Location from TopLoc)
returns SensitiveEntity from Select3D is virtual;
---Purpose: Returns the sensitive entity found at the location aLocation.
---Purpose: Originally this method intended to return sensitive
-- entity with new location aLocation, but currently sensitive
-- entities do not hold a location, instead HasLocation() and
-- Location() methods call corresponding entity owner's methods.
-- Thus all entities returned by GetConnected() share the same
-- location propagated from corresponding selectable object.
-- You must redefine this function for any type of
-- sensitive entity which can accept another connected
-- sensitive entity.//can be connected to another sensitive entity.

View File

@@ -39,9 +39,9 @@ void Select3D_SensitiveEntity::Project(const Handle(Select3D_Projector)& aPrj)
//=======================================================================
Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
if (!mylastprj.IsNull())
{
@@ -62,10 +62,10 @@ Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
//=======================================================================
Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
return Standard_False;
}
@@ -76,8 +76,8 @@ Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real XMin,
//=======================================================================
Standard_Boolean Select3D_SensitiveEntity::Matches(const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
return Standard_False;
}
@@ -99,13 +99,13 @@ void Select3D_SensitiveEntity::Dump(Standard_OStream& S,const Standard_Boolean F
void Select3D_SensitiveEntity::DumpBox(Standard_OStream& S,const Bnd_Box2d& b2d)
{
if(!b2d.IsVoid()){
if(!b2d.IsVoid())
{
Standard_Real xmin,ymin,xmax,ymax;
b2d.Get(xmin,ymin,xmax,ymax);
S<<"\t\t\tBox2d: PMIN ["<<xmin<<" , "<<ymin<<"]"<<endl;
S<<"\t\t\t PMAX ["<<xmax<<" , "<<ymax<<"]"<<endl;
}
}
//=======================================================================
@@ -136,9 +136,11 @@ void Select3D_SensitiveEntity::UpdateLocation(const TopLoc_Location& aLoc)
if(aLoc.IsIdentity() || aLoc == Location()) return;
if(!HasLocation())
SetLocation(aLoc);
else {
else
{
TopLoc_Location compLoc = aLoc * Location();
SetLocation(compLoc);}
SetLocation(compLoc);
}
}
//=======================================================================
@@ -186,7 +188,7 @@ Standard_Real Select3D_SensitiveEntity::Depth() const
//=======================================================================
gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
const Standard_Real Y) const
const Standard_Real Y) const
{
gp_Lin L;
if (!mylastprj.IsNull())
@@ -225,7 +227,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveEntity::GetConnected(const To
}
//=======================================================================
//function : GetConnected
//function : SetLastDepth
//purpose :
//=======================================================================
void Select3D_SensitiveEntity::SetLastDepth(const Standard_Real aDepth)

View File

@@ -20,7 +20,8 @@ uses
Array1OfPnt2d from TColgp,
Box2d from Bnd,
TypeOfSensitivity from Select3D,
Location from TopLoc
Location from TopLoc,
SensitiveEntity from Select3D
is
@@ -43,7 +44,7 @@ is
-- owner OwnerId, the array of points ThePoints, and
-- the sensitivity type Sensitivity.
-- The array of points is the outer polygon of the geometric face.
Matches(me :mutable;
X,Y : Real from Standard;
aTol: Real from Standard;
@@ -76,7 +77,13 @@ is
-- in some particular case, a custom sensitive face class can be implemented at application level
-- that overrides default ComputeDepth() behavior.
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
GetConnected(me: mutable; theLocation : Location from TopLoc)
returns SensitiveEntity from Select3D
is redefined virtual;
---Level: Public
---Purpose: Returns the copy of this
fields

View File

@@ -36,8 +36,8 @@
Select3D_SensitiveFace::
Select3D_SensitiveFace(const Handle(SelectBasics_EntityOwner)& OwnerId,
const TColgp_Array1OfPnt& ThePoints,
const Select3D_TypeOfSensitivity aType):
const TColgp_Array1OfPnt& ThePoints,
const Select3D_TypeOfSensitivity aType):
Select3D_SensitivePoly(OwnerId, ThePoints),
mytype (aType),
myDetectedIndex(-1)
@@ -46,14 +46,14 @@ myDetectedIndex(-1)
}
//==================================================
// Function:
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitiveFace::
Select3D_SensitiveFace(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(TColgp_HArray1OfPnt)& ThePoints,
const Select3D_TypeOfSensitivity aType):
const Handle(TColgp_HArray1OfPnt)& ThePoints,
const Select3D_TypeOfSensitivity aType):
Select3D_SensitivePoly(OwnerId, ThePoints),
mytype (aType),
myDetectedIndex(-1)
@@ -62,15 +62,15 @@ myDetectedIndex(-1)
}
//==================================================
// Function:
// Function: Matches
// Purpose :
//==================================================
Standard_Boolean Select3D_SensitiveFace::
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
#ifndef DEB
Standard_Real DMin2 = 0.;
@@ -78,7 +78,8 @@ Matches(const Standard_Real X,
Standard_Real DMin2;
#endif
Standard_Real Xmin,Ymin,Xmax,Ymax;
if(!Bnd_Box2d(mybox2d).IsVoid()){
if(!Bnd_Box2d(mybox2d).IsVoid())
{
Bnd_Box2d(mybox2d).Get(Xmin,Ymin,Xmax,Ymax);
DMin2 = gp_XY(Xmax-Xmin,Ymax-Ymin).SquareModulus();
}
@@ -90,20 +91,22 @@ Matches(const Standard_Real X,
gp_XY CDG(0.,0.);
// for(Standard_Integer I=1;I<=Nbp-1;I++){
Standard_Integer I;
for(I=1;I<mynbpoints-1;I++){
for(I=1;I<mynbpoints-1;I++)
{
CDG+=((Select3D_Pnt2d*)mypolyg2d)[I-1];
}
if(mynbpoints>1){
if(mynbpoints>1)
{
CDG/= (mynbpoints-1);
}
DMin2=Min(DMin2,gp_XY(CDG.X()-X,CDG.Y()-Y).SquareModulus());
DMin = Sqrt(DMin2);
Standard_Boolean isplane2d(Standard_True);
for( I=1;I<mynbpoints-1;I++){
for( I=1;I<mynbpoints-1;I++)
{
gp_XY V1(((Select3D_Pnt2d*)mypolyg2d)[I]),V(X,Y);
V1-=((Select3D_Pnt2d*)mypolyg2d)[I-1];
V-=((Select3D_Pnt2d*)mypolyg2d)[I-1];
@@ -122,17 +125,6 @@ Matches(const Standard_Real X,
{
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
}
//detection d'une auto - intersection dans le polygon 2D; si oui on sort
// if (!AutoComputeFlag(myautointer)) {
// if(mypolyg2d.Length()>4) {
// if (SelectBasics_BasicTool::AutoInter(mypolyg2d)) {
// SetAutoInterFlag(myautointer);
// }
// }
// SetAutoComputeFlag(myautointer);
// }
// if (AutoInterFlag(myautointer)) return Standard_True;
// //
//otherwise it is checked if the point is in the face...
TColgp_Array1OfPnt2d aArrayOf2dPnt(1, mynbpoints);
@@ -141,13 +133,14 @@ Matches(const Standard_Real X,
Standard_Integer TheStat = TheInOutTool.SiDans(gp_Pnt2d(X,Y));
Standard_Boolean res(Standard_False);
switch(TheStat){
switch(TheStat)
{
case 0:
res = Standard_True;
case 1:
{
if(mytype!=Select3D_TOS_BOUNDARY)
res = Standard_True;
if(mytype!=Select3D_TOS_BOUNDARY)
res = Standard_True;
}
}
if (res)
@@ -164,15 +157,16 @@ Matches(const Standard_Real X,
Standard_Boolean Select3D_SensitiveFace::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
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<=mynbpoints-1;j++){
for(Standard_Integer j=1;j<=mynbpoints-1;j++)
{
if(BoundBox.IsOut(((Select3D_Pnt2d*)mypolyg2d)[j-1])) return Standard_False;
}
return Standard_True;
@@ -185,9 +179,9 @@ Matches (const Standard_Real XMin,
Standard_Boolean Select3D_SensitiveFace::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
Standard_Real Tolu,Tolv;
@@ -195,18 +189,19 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer j=1;j<=mynbpoints;j++){
for(Standard_Integer j=1;j<=mynbpoints;j++)
{
Standard_Integer RES = aClassifier2d.SiDans(((Select3D_Pnt2d*)mypolyg2d)[j-1]);
if(RES!=1) return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
{
S<<"\tSensitiveFace 3D :"<<endl;;
@@ -216,7 +211,8 @@ void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean Ful
if(mytype==Select3D_TOS_BOUNDARY)
S<<"\t\tSelection Of Bounding Polyline Only"<<endl;
if(FullDump){
if(FullDump)
{
S<<"\t\tNumber Of Points :"<<mynbpoints<<endl;
// S<<"\t\t\tOwner:"<<myOwnerId<<endl;
@@ -228,6 +224,7 @@ void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean Ful
//function : ComputeDepth
//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const
{
Standard_Real aDepth = Precision::Infinite();
@@ -244,3 +241,28 @@ Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const
}
return aDepth;
}
//=======================================================================
//function : GetConnected
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected(const TopLoc_Location &theLocation)
{
// Create a copy of this
TColgp_Array1OfPnt aPoints(1, mynbpoints);
for (Standard_Integer i = 1; i <= mynbpoints; ++i)
{
aPoints.SetValue(i, ((Select3D_Pnt*)mypolyg3d)[i-1]);
}
Handle(Select3D_SensitiveEntity) aNewEntity =
new Select3D_SensitiveFace(myOwnerId, aPoints, mytype);
if (HasLocation())
aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation);
return aNewEntity;
}

View File

@@ -130,7 +130,10 @@ is
---Purpose: returns the depth of the touched entity
SetLastPrj(me:mutable;aPrj:Projector from Select3D) is redefined virtual;
SetLastPrj(me:mutable;aPrj:Projector from Select3D) is redefined virtual;
Set(me:mutable;TheOwnerId: EntityOwner from SelectBasics) is redefined static;
---Purpose: Sets the owner for all entities in group
GetEntities(me)
returns ListOfSensitive from Select3D;

View File

@@ -8,8 +8,12 @@
#include <Select3D_ListIteratorOfListOfSensitive.hxx>
#include <Precision.hxx>
//=======================================================================
//function : Creation
//purpose :
//=======================================================================
Select3D_SensitiveGroup::Select3D_SensitiveGroup(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Standard_Boolean MatchAll):
const Standard_Boolean MatchAll):
Select3D_SensitiveEntity(OwnerId),
myMustMatchAll(MatchAll),
myLastRank(0),
@@ -18,10 +22,14 @@ myY(0.)
{
}
Select3D_SensitiveGroup::Select3D_SensitiveGroup(const Handle(SelectBasics_EntityOwner)& OwnerId,
Select3D_ListOfSensitive& TheList,
const Standard_Boolean MatchAll):
//=======================================================================
//function : Creation
//purpose :
//=======================================================================
Select3D_SensitiveGroup::Select3D_SensitiveGroup(const Handle(SelectBasics_EntityOwner)& OwnerId,
Select3D_ListOfSensitive& TheList,
const Standard_Boolean MatchAll):
Select3D_SensitiveEntity(OwnerId),
myMustMatchAll(MatchAll),
myLastRank(0),
@@ -35,6 +43,7 @@ myY(0.)
//function : Add
//purpose : No control of entities inside
//=======================================================================
void Select3D_SensitiveGroup::Add(Select3D_ListOfSensitive& LL)
{myList.Append(LL);}
@@ -42,9 +51,11 @@ void Select3D_SensitiveGroup::Add(Select3D_ListOfSensitive& LL)
//function : Add
//purpose :
//=======================================================================
void Select3D_SensitiveGroup::Add(const Handle(Select3D_SensitiveEntity)& aSensitive)
{
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
if(It.Value()==aSensitive) return;
}
myList.Append(aSensitive);
@@ -54,10 +65,13 @@ void Select3D_SensitiveGroup::Add(const Handle(Select3D_SensitiveEntity)& aSensi
//function : Remove
//purpose :
//=======================================================================
void Select3D_SensitiveGroup::Remove(const Handle(Select3D_SensitiveEntity)& aSensitive)
{
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
if(It.Value()==aSensitive){
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
if(It.Value()==aSensitive)
{
myList.Remove(It);
return;
}
@@ -68,19 +82,22 @@ void Select3D_SensitiveGroup::Remove(const Handle(Select3D_SensitiveEntity)& aSe
//function : IsIn
//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveGroup::IsIn(const Handle(Select3D_SensitiveEntity)& aSensitive) const
{
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
if(It.Value()==aSensitive)
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void Select3D_SensitiveGroup::Clear()
{myList.Clear();}
@@ -93,7 +110,8 @@ void Select3D_SensitiveGroup::Project(const Handle(Select3D_Projector)& aProject
{
Select3D_SensitiveEntity::Project(aProjector); // to set the field last proj...
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
It.Value()->Project(aProjector);
}
}
@@ -105,7 +123,8 @@ void Select3D_SensitiveGroup::Project(const Handle(Select3D_Projector)& aProject
void Select3D_SensitiveGroup::Areas(SelectBasics_ListOfBox2d& boxes)
{
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
It.Value()->Areas(boxes);
}
}
@@ -119,7 +138,8 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveGroup::GetConnected(const Top
{
Handle(Select3D_SensitiveGroup) newgroup = new Select3D_SensitiveGroup(myOwnerId,myMustMatchAll);
Select3D_ListOfSensitive LL;
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
LL.Append(It.Value()->GetConnected(aLocation));
}
newgroup->Add(LL);
@@ -135,18 +155,24 @@ void Select3D_SensitiveGroup::SetLocation(const TopLoc_Location& aLoc)
{
if(aLoc.IsIdentity()) return;
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
It.Value()->SetLocation(aLoc);
}
if(HasLocation())
if(aLoc == Location()) return;
Select3D_SensitiveEntity::SetLocation(aLoc);
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
if(It.Value()->HasLocation()){
if(It.Value()->Location()!=aLoc)
It.Value()->SetLocation(It.Value()->Location()*aLoc);
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
if(It.Value()->HasLocation())
{
if(It.Value()->Location()!=aLoc)
It.Value()->SetLocation(It.Value()->Location()*aLoc);
}
else
It.Value()->SetLocation(aLoc);
}
}
@@ -154,15 +180,16 @@ void Select3D_SensitiveGroup::SetLocation(const TopLoc_Location& aLoc)
//function : ResetLocation
//purpose :
//=======================================================================
void Select3D_SensitiveGroup::ResetLocation()
{
if(!HasLocation()) return;
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
if(It.Value()->HasLocation() && It.Value()->Location()!=Location())
It.Value()->SetLocation(It.Value()->Location()*Location().Inverted());
else
It.Value()->ResetLocation();
}
Select3D_SensitiveEntity::ResetLocation();
}
@@ -171,10 +198,11 @@ void Select3D_SensitiveGroup::ResetLocation()
//function : Matches
//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
myLastRank = 0;
myLastTol = aTol;
@@ -198,25 +226,28 @@ Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real X,
//purpose : si on doit tout matcher, on ne repond oui que si toutes
// les primitives repondent oui
//=======================================================================
Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
Standard_Boolean result(Standard_True);
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
if(It.Value()->Matches(XMin,YMin,XMax,YMax,aTol)){
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
if(It.Value()->Matches(XMin,YMin,XMax,YMax,aTol))
{
if(!myMustMatchAll)
return Standard_True;
return Standard_True;
}
// ca ne matches pas..
else {
if(myMustMatchAll)
return Standard_False;
else
result = Standard_False;
else
{
if(myMustMatchAll)
return Standard_False;
else
result = Standard_False;
}
}
return result;
@@ -229,27 +260,29 @@ Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real XMin,
Standard_Boolean Select3D_SensitiveGroup::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Boolean result(Standard_True);
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
if(It.Value()->Matches(aPoly, aBox, aTol)){
if(!myMustMatchAll)
return Standard_True;
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
if(It.Value()->Matches(aPoly, aBox, aTol))
{
if(!myMustMatchAll)
return Standard_True;
}
else {
if(myMustMatchAll)
return Standard_False;
else
result = Standard_False;
else
{
if(myMustMatchAll)
return Standard_False;
else
result = Standard_False;
}
}
return result;
}
//=======================================================================
//function : ComputeDepth
//purpose : to optimise, the minimum depth for
@@ -285,6 +318,7 @@ Standard_Real Select3D_SensitiveGroup::ComputeDepth(const gp_Lin& EyeLine) const
//function : MaxBoxes
//purpose :
//=======================================================================
Standard_Integer Select3D_SensitiveGroup::MaxBoxes() const
{
Standard_Integer nbboxes(0);
@@ -294,9 +328,28 @@ Standard_Integer Select3D_SensitiveGroup::MaxBoxes() const
return nbboxes;
}
//=======================================================================
//function : SetLastPrj
//purpose :
//=======================================================================
void Select3D_SensitiveGroup::SetLastPrj(const Handle(Select3D_Projector)& Prj)
{
Select3D_SensitiveEntity::SetLastPrj(Prj);
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
It.Value()->SetLastPrj(Prj);
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void Select3D_SensitiveGroup::Set
(const Handle(SelectBasics_EntityOwner)& TheOwnerId)
{
Select3D_SensitiveEntity::Set(TheOwnerId);
// set TheOwnerId for each element of sensitive group
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
It.Value()->Set(TheOwnerId);
}

View File

@@ -14,13 +14,13 @@
#include <CSLib_Class2d.hxx>
//==================================================
// Function:
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitivePoint
::Select3D_SensitivePoint(const Handle(SelectBasics_EntityOwner)& anOwner,
const gp_Pnt& aPoint):
const gp_Pnt& aPoint):
Select3D_SensitiveEntity(anOwner)
{
SetSensitivityFactor(4.);
@@ -28,9 +28,10 @@ Select3D_SensitiveEntity(anOwner)
}
//==================================================
// Function:
// Function: Project
// Purpose :
//==================================================
void Select3D_SensitivePoint
::Project (const Handle(Select3D_Projector)& aProj)
{
@@ -38,7 +39,8 @@ void Select3D_SensitivePoint
gp_Pnt2d aPoint2d;
if(!HasLocation())
aProj->Project(mypoint, aPoint2d);
else{
else
{
gp_Pnt aP(mypoint.x, mypoint.y, mypoint.z);
aProj->Project(aP.Transformed(Location().Transformation()), aPoint2d);
}
@@ -46,9 +48,10 @@ void Select3D_SensitivePoint
}
//==================================================
// Function:
// Function: Areas
// Purpose :
//==================================================
void Select3D_SensitivePoint
::Areas(SelectBasics_ListOfBox2d& boxes)
{
@@ -57,16 +60,16 @@ void Select3D_SensitivePoint
boxes.Append(abox);
}
//==================================================
// Function:
// Function: Matches
// Purpose :
//==================================================
Standard_Boolean Select3D_SensitivePoint
::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
DMin = gp_Pnt2d(X,Y).Distance(myprojpt);
if(DMin<=aTol*SensitivityFactor())
@@ -77,12 +80,17 @@ Standard_Boolean Select3D_SensitivePoint
return Standard_False;
}
//==================================================
// Function: Matches
// Purpose :
//==================================================
Standard_Boolean Select3D_SensitivePoint::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
Bnd_Box2d B;
B.Update(Min(XMin,XMax),Min(YMin,YMax),Max(XMin,XMax),Max(YMin,YMax));
@@ -90,7 +98,6 @@ Matches (const Standard_Real XMin,
return !B.IsOut(myprojpt);
}
//=======================================================================
//function : Matches
//purpose :
@@ -98,8 +105,8 @@ Matches (const Standard_Real XMin,
Standard_Boolean Select3D_SensitivePoint::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
@@ -114,12 +121,11 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
return Standard_False;
}
//=======================================================================
//function : Point
//purpose :
//=======================================================================
gp_Pnt Select3D_SensitivePoint::Point() const
{return mypoint;}
@@ -136,7 +142,6 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitivePoint::GetConnected(const Top
return NiouEnt;
}
//=======================================================================
//function : Dump
//purpose :
@@ -161,5 +166,3 @@ Standard_Real Select3D_SensitivePoint::ComputeDepth(const gp_Lin& EyeLine) const
{
return ElCLib::Parameter(EyeLine,mypoint);
}

View File

@@ -38,7 +38,7 @@ is
---Level: Public
---Purpose: Constructs the sensitive circle object defined by the
-- owner OwnerId, the circle Circle, the Boolean
-- FilledCircle and the number of points NbOfPoints.
-- FilledCircle and the number of points NbOfPoints.
Project (me:mutable;aProjector : Projector from Select3D) is redefined virtual;
---Level: Public
@@ -69,4 +69,4 @@ fields
mypolyg2d : Address from Standard is protected;
mybox2d : Box2d from Select3D is protected;
mynbpoints : Integer from Standard is protected;
end SensitiveFace;
end SensitivePoly;

View File

@@ -14,7 +14,7 @@
Select3D_SensitivePoly::
Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
const TColgp_Array1OfPnt& ThePoints):
const TColgp_Array1OfPnt& ThePoints):
Select3D_SensitiveEntity(OwnerId)
{
mynbpoints = ThePoints.Upper()-ThePoints.Lower()+1;
@@ -25,13 +25,13 @@ Select3D_SensitiveEntity(OwnerId)
}
//==================================================
// Function:
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitivePoly::
Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(TColgp_HArray1OfPnt)& ThePoints):
const Handle(TColgp_HArray1OfPnt)& ThePoints):
Select3D_SensitiveEntity(OwnerId)
{
mynbpoints = ThePoints->Upper()-ThePoints->Lower()+1;
@@ -42,13 +42,13 @@ Select3D_SensitiveEntity(OwnerId)
}
//==================================================
// Function:
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitivePoly::
Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Standard_Integer NbPoints):
const Standard_Integer NbPoints):
Select3D_SensitiveEntity(OwnerId)
{
mynbpoints = NbPoints;
@@ -57,7 +57,7 @@ Select3D_SensitiveEntity(OwnerId)
}
//==================================================
// Function:
// Function: Project
// Purpose :
//==================================================
@@ -85,7 +85,7 @@ void Select3D_SensitivePoly::Project(const Handle(Select3D_Projector)& aProj)
}
//==================================================
// Function:
// Function: Areas
// Purpose :
//==================================================
void Select3D_SensitivePoly
@@ -95,7 +95,7 @@ void Select3D_SensitivePoly
}
//==================================================
// Function:
// Function: Destroy
// Purpose :
//==================================================
void Select3D_SensitivePoly::Destroy()

View File

@@ -27,12 +27,11 @@
// Purpose :Constructor
//=====================================================
Select3D_SensitiveSegment::
Select3D_SensitiveSegment(const Handle(SelectBasics_EntityOwner)& OwnerId,
const gp_Pnt& FirstP,
const gp_Pnt& LastP,
const Standard_Integer MaxRect):
Select3D_SensitiveSegment(const Handle(SelectBasics_EntityOwner)& OwnerId,
const gp_Pnt& FirstP,
const gp_Pnt& LastP,
const Standard_Integer MaxRect):
Select3D_SensitiveEntity(OwnerId),
mymaxrect(MaxRect)
{
@@ -44,6 +43,7 @@ mymaxrect(MaxRect)
// Function :
// Purpose :
//=====================================================
void Select3D_SensitiveSegment
::Project(const Handle(Select3D_Projector)& aProj)
{
@@ -51,13 +51,15 @@ void Select3D_SensitiveSegment
gp_Pnt2d aPoint2dStart;
gp_Pnt2d aPoint2dEnd;
if(HasLocation()){
if(HasLocation())
{
gp_Pnt aStart(mystart.x, mystart.y, mystart.z);
gp_Pnt aEnd(myend.x, myend.y, myend.z);
aProj->Project(aStart.Transformed(Location().Transformation()),aPoint2dStart);
aProj->Project(aEnd.Transformed(Location().Transformation()),aPoint2dEnd);
}
else{
else
{
aProj->Project(mystart,aPoint2dStart);
aProj->Project(myend,aPoint2dEnd);
}
@@ -69,43 +71,48 @@ void Select3D_SensitiveSegment
// Function : Areas
// Purpose :
//=====================================================
void Select3D_SensitiveSegment
::Areas(SelectBasics_ListOfBox2d& theareas)
{
// gp_Dir2d dy (0.,1.);
gp_Pnt2d aPStart(myprojstart.x,myprojstart.y);
if(aPStart.Distance(myprojend)<=Precision::Confusion()){
if(aPStart.Distance(myprojend)<=Precision::Confusion())
{
Bnd_Box2d curbox;
curbox.Set(myprojstart);
theareas.Append(curbox);
}
else {
}
else
{
gp_Vec2d MyVec(myprojstart,myprojend);//,VAxx(gp_Dir2d(0.,1.));
Standard_Real theangle = Abs(gp_Dir2d(0.,1.).Angle(gp_Vec2d(myprojstart,myprojend)));
if(theangle>=M_PI/2.) theangle-=M_PI/2;
if(theangle>=M_PI/12. && theangle <=5*M_PI/12.)
{
TColgp_Array1OfPnt2d BoxPoint (1,mymaxrect+1);
BoxPoint (1) = myprojstart;
BoxPoint(mymaxrect+1)=myprojend;
gp_Vec2d Vtr = MyVec/mymaxrect;
// for (Standard_Integer i=2;i<=mymaxrect;i++)
Standard_Integer i;
for ( i=2;i<=mymaxrect;i++)
{BoxPoint (i) = BoxPoint (i-1).Translated(Vtr);}
for (i=2;i<=mymaxrect+1;i++)
{ Bnd_Box2d curbox;
curbox.Set(BoxPoint(i-1));
curbox.Add(BoxPoint(i));
theareas.Append(curbox);
}
{
TColgp_Array1OfPnt2d BoxPoint (1,mymaxrect+1);
BoxPoint (1) = myprojstart;
BoxPoint(mymaxrect+1)=myprojend;
gp_Vec2d Vtr = MyVec/mymaxrect;
Standard_Integer i;
for ( i=2;i<=mymaxrect;i++)
{
BoxPoint (i) = BoxPoint (i-1).Translated(Vtr);
}
for (i=2;i<=mymaxrect+1;i++)
{
Bnd_Box2d curbox;
curbox.Set(BoxPoint(i-1));
curbox.Add(BoxPoint(i));
theareas.Append(curbox);
}
}
else
{
Bnd_Box2d curbox;
curbox.Set(myprojstart);
curbox.Add(myprojend);
theareas.Append(curbox);
{
Bnd_Box2d curbox;
curbox.Set(myprojstart);
curbox.Add(myprojend);
theareas.Append(curbox);
}
}
}
@@ -114,11 +121,12 @@ void Select3D_SensitiveSegment
// Function : Matches
// Purpose :
//=====================================================
Standard_Boolean Select3D_SensitiveSegment
::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
gp_Pnt2d aPStart(myprojstart.x,myprojstart.y);
gp_Pnt2d aPEnd(myprojend.x,myprojend.y);
@@ -127,12 +135,17 @@ Standard_Boolean Select3D_SensitiveSegment
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin); // compute and validate depth
}
//=====================================================
// Function : Matches
// Purpose :
//=====================================================
Standard_Boolean Select3D_SensitiveSegment::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
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);
@@ -141,7 +154,6 @@ Matches (const Standard_Real XMin,
return Standard_True;
}
//=======================================================================
//function : Matches
//purpose :
@@ -149,8 +161,8 @@ Matches (const Standard_Real XMin,
Standard_Boolean Select3D_SensitiveSegment::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
@@ -173,9 +185,13 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
//function : GetConnected
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveSegment::GetConnected(const TopLoc_Location& aLoc)
Handle(Select3D_SensitiveEntity) Select3D_SensitiveSegment::
GetConnected(const TopLoc_Location& aLoc)
{
Handle(Select3D_SensitiveSegment) NiouEnt = new Select3D_SensitiveSegment(myOwnerId,mystart,myend,mymaxrect);
Handle(Select3D_SensitiveSegment) NiouEnt =
new Select3D_SensitiveSegment(myOwnerId,mystart,myend,mymaxrect);
if(HasLocation()) NiouEnt->SetLocation(Location());
NiouEnt->UpdateLocation(aLoc);
return NiouEnt;

View File

@@ -21,7 +21,8 @@ uses
XY from gp,
Pnt from gp,
TypeOfSensitivity from Select3D,
Location from TopLoc
Location from TopLoc,
SensitiveEntity from Select3D
is
Create (OwnerId : EntityOwner from SelectBasics;
@@ -30,7 +31,7 @@ is
returns mutable SensitiveTriangle;
---Level: Public
---Purpose: Constructs a sensitive triangle object defined by the
-- owner OwnerId, the points P1, P2, P3, and the type of sensitivity Sensitivity.
-- owner OwnerId, the points P1, P2, P3, and the type of sensitivity Sensitivity.
Matches(me :mutable;
X,Y : Real from Standard;
@@ -85,7 +86,13 @@ is
Dmin : out Real from Standard) returns Integer from Standard;
---Purpose: Dmin gives the distance between the cdg and aPoint return
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
GetConnected(me: mutable; theLocation : Location from TopLoc)
returns SensitiveEntity from Select3D
is redefined virtual;
---Level: Public
---Purpose: Returns the copy of this
fields

View File

@@ -43,16 +43,16 @@ static Standard_Boolean S3D_Str_NearSegment (const gp_XY& p0, const gp_XY& p1, c
}
//==================================================
// Function:
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitiveTriangle::
Select3D_SensitiveTriangle(const Handle(SelectBasics_EntityOwner)& OwnerId,
const gp_Pnt& P0,
const gp_Pnt& P1,
const gp_Pnt& P2,
const Select3D_TypeOfSensitivity aType):
const gp_Pnt& P0,
const gp_Pnt& P1,
const gp_Pnt& P2,
const Select3D_TypeOfSensitivity aType):
Select3D_SensitivePoly(OwnerId,3),
mytype (aType)
{
@@ -62,21 +62,22 @@ mytype (aType)
}
//==================================================
// Function:
// Function: Matches
// Purpose :
//==================================================
Standard_Boolean Select3D_SensitiveTriangle::
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
if(Bnd_Box2d(mybox2d).IsOut(gp_Pnt2d(X,Y))) return Standard_False;
Standard_Integer Res;
switch (mytype){
switch (mytype)
{
case Select3D_TOS_BOUNDARY:
Res = Status(X,Y,aTol,DMin);
return Res== 1;
@@ -92,25 +93,31 @@ Matches(const Standard_Real X,
return Standard_True;
}
//==================================================
// Function: Matches
// Purpose :
//==================================================
Standard_Boolean Select3D_SensitiveTriangle::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
Bnd_Box2d B;
B.Update(Min(XMin,XMax)-aTol,
Min(YMin,YMax)-aTol,
Max(XMin,XMax)+aTol,
Max(YMin,YMax)+aTol);
for(Standard_Integer i=0;i<=2;i++){
Min(YMin,YMax)-aTol,
Max(XMin,XMax)+aTol,
Max(YMin,YMax)+aTol);
for(Standard_Integer i=0;i<=2;i++)
{
if(B.IsOut(((Select3D_Pnt2d*)mypolyg2d)[i]))
return Standard_False;}
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : Matches
//purpose :
@@ -118,8 +125,8 @@ Matches (const Standard_Real XMin,
Standard_Boolean Select3D_SensitiveTriangle::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
@@ -128,20 +135,31 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer i=0;i<=2;i++){
for(Standard_Integer i=0;i<=2;i++)
{
Standard_Integer RES = aClassifier2d.SiDans(((Select3D_Pnt2d*)mypolyg2d)[i]);
if(RES!=1) return Standard_False;
}
return Standard_True;
}
//==================================================
// Function: Points3D
// Purpose :
//==================================================
void Select3D_SensitiveTriangle::Points3D(gp_Pnt& P0,gp_Pnt& P1,gp_Pnt& P2) const
{
P0 = ((Select3D_Pnt*)mypolyg3d)[0]; P1 = ((Select3D_Pnt*)mypolyg3d)[1]; P2 = ((Select3D_Pnt*)mypolyg3d)[2];
P0 = ((Select3D_Pnt*)mypolyg3d)[0];
P1 = ((Select3D_Pnt*)mypolyg3d)[1];
P2 = ((Select3D_Pnt*)mypolyg3d)[2];
}
//==================================================
// Function: Center3D
// Purpose :
//==================================================
gp_Pnt Select3D_SensitiveTriangle::Center3D() const
{
gp_XYZ CDG(((Select3D_Pnt*)mypolyg3d)[0]);
@@ -149,7 +167,12 @@ gp_Pnt Select3D_SensitiveTriangle::Center3D() const
CDG += ((Select3D_Pnt*)mypolyg3d)[2];
CDG /=3.;
return gp_Pnt(CDG);;
}
}
//==================================================
// Function: Center2D
// Purpose :
//==================================================
gp_XY Select3D_SensitiveTriangle::Center2D() const
{
@@ -163,30 +186,26 @@ gp_XY Select3D_SensitiveTriangle::Center2D() const
//=======================================================================
Standard_Integer Select3D_SensitiveTriangle::Status(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin) const
{
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin) const
{
return Status(((Select3D_Pnt2d*)mypolyg2d)[0],((Select3D_Pnt2d*)mypolyg2d)[1],
((Select3D_Pnt2d*)mypolyg2d)[2],gp_XY(X,Y),aTol,DMin);
}
//=======================================================================
//function : Status
//purpose :
//=======================================================================
Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
const gp_XY& p1,
const gp_XY& p2,
const gp_XY& TheP,
const Standard_Real aTol,
Standard_Real& DMin)
const gp_XY& p1,
const gp_XY& p2,
const gp_XY& TheP,
const Standard_Real aTol,
Standard_Real& DMin)
{
Bnd_Box2d B;
B.Update(p0.X(),p0.Y());B.Update(p1.X(),p1.Y());B.Update(p2.X(),p2.Y());
B.Enlarge(aTol);
@@ -277,7 +296,7 @@ Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
DMin = ( aD < 0 ? -aD : 0. );
return 0;
}
//=======================================================================
//function : Dump
//purpose :
@@ -295,7 +314,8 @@ void Select3D_SensitiveTriangle::Dump(Standard_OStream& S,const Standard_Boolean
S<<"\t\t P1 [ "<<COORD(1,x)<<" , "<<COORD(1,y) <<" , "<<COORD(1,z)<<" ]"<<endl;
S<<"\t\t P2 [ "<<COORD(2,x)<<" , "<<COORD(2,y) <<" , "<<COORD(2,z)<<" ]"<<endl;
if(FullDump){
if(FullDump)
{
S<<"\t\tProjected Points"<<endl;
S<<"\t\t 0.[ "<<COORD2d(0,x)<<" , "<<COORD2d(0,y)<<" ]"<<endl;
@@ -303,24 +323,26 @@ void Select3D_SensitiveTriangle::Dump(Standard_OStream& S,const Standard_Boolean
S<<"\t\t 2.[ "<<COORD2d(2,x)<<" , "<<COORD2d(2,y)<<" ]"<<endl;
// S<<"\t\t\tOwner:"<<myOwnerId<<endl;
Select3D_SensitiveEntity::DumpBox(S,mybox2d);
}
}
//=======================================================================
//function : ComputeDepth
//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveTriangle::ComputeDepth(const gp_Lin& EyeLine) const
{
gp_Pnt P1(((Select3D_Pnt*)mypolyg3d)[0].x, ((Select3D_Pnt*)mypolyg3d)[0].y, ((Select3D_Pnt*)mypolyg3d)[0].z);
gp_Pnt P2(((Select3D_Pnt*)mypolyg3d)[1].x, ((Select3D_Pnt*)mypolyg3d)[1].y, ((Select3D_Pnt*)mypolyg3d)[1].z);
gp_Pnt P3(((Select3D_Pnt*)mypolyg3d)[2].x, ((Select3D_Pnt*)mypolyg3d)[2].y, ((Select3D_Pnt*)mypolyg3d)[2].z);
gp_Pnt P1 = ((Select3D_Pnt*)mypolyg3d)[0];
gp_Pnt P2 = ((Select3D_Pnt*)mypolyg3d)[1];
gp_Pnt P3 = ((Select3D_Pnt*)mypolyg3d)[2];
gp_Trsf TheTrsf ;
if(HasLocation())
TheTrsf = Location().Transformation();
if(TheTrsf.Form()!=gp_Identity){
if(TheTrsf.Form()!=gp_Identity)
{
P1.Transform(TheTrsf);
P2.Transform(TheTrsf);
P3.Transform(TheTrsf);
@@ -344,12 +366,35 @@ Standard_Real Select3D_SensitiveTriangle::ComputeDepth(const gp_Lin& EyeLine) co
if(Abs(val2)>Precision::Confusion())
prof =val1/val2;
if (prof==Precision::Infinite()){
if (prof==Precision::Infinite())
{
prof= ElCLib::Parameter(EyeLine,P1);
prof = Min (prof, ElCLib::Parameter(EyeLine,P2));
prof = Min (prof, ElCLib::Parameter(EyeLine,P3));
}
return prof;
}
//==================================================
// Function: GetConnected
// Purpose :
//==================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangle::
GetConnected(const TopLoc_Location &theLocation)
{
// Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity =
new Select3D_SensitiveTriangle(myOwnerId,
((Select3D_Pnt*)mypolyg3d)[0],
((Select3D_Pnt*)mypolyg3d)[1],
((Select3D_Pnt*)mypolyg3d)[2],
mytype);
if (HasLocation())
aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation);
return aNewEntity;
}

View File

@@ -78,10 +78,10 @@ static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY&
// }
static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
const Standard_Integer e2,
const Standard_Integer N1,
const Standard_Integer N2,
const Standard_Integer N3)
const Standard_Integer e2,
const Standard_Integer N1,
const Standard_Integer N2,
const Standard_Integer N3)
{
Standard_Integer bid1 = (e1 == N1) ? N1 : ((e1 == N2) ? N2 : ( e1==N3 ? N3 : 0));
if(bid1==0) return Standard_False;
@@ -91,19 +91,17 @@ static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
return Standard_True;
}
//=======================================================================
//function : Select3D_SensitiveTriangulation
//purpose :
//=======================================================================
Select3D_SensitiveTriangulation::
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Poly_Triangulation)& Trg,
const TopLoc_Location& Loc,
const Standard_Boolean InteriorFlag):
Select3D_SensitiveEntity(OwnerId),
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Poly_Triangulation)& Trg,
const TopLoc_Location& Loc,
const Standard_Boolean InteriorFlag):
Select3D_SensitiveEntity(OwnerId),
myTriangul(Trg),
myiniloc(Loc),
myIntFlag(InteriorFlag),
@@ -121,34 +119,38 @@ myDetectedTr(-1)
Standard_Integer n[3];
// to find connections in case when the border is not concerned...
if(!myIntFlag){
if(!myIntFlag)
{
myFreeEdges = new TColStd_HArray1OfInteger(1,2*S3D_NumberOfFreeEdges(Trg));
TColStd_Array1OfInteger& FreeE = myFreeEdges->ChangeArray1();
Poly_Connect pc(myTriangul);
Standard_Integer t[3];
Standard_Integer i,j;
for ( i = 1; i <= nbTriangles; i++) {
for ( i = 1; i <= nbTriangles; i++)
{
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(n[0],n[1],n[2]);
cdg += (Nodes(n[0]).XYZ() + Nodes(n[1]).XYZ()+ Nodes(n[2]).XYZ())/3.;
for (j = 0; j < 3; j++) {
Standard_Integer k = (j+1) % 3;
if (t[j] == 0) {
FreeE(fr) = n[j];
FreeE(fr+1)= n[k];
fr += 2;
}
for (j = 0; j < 3; j++)
{
Standard_Integer k = (j+1) % 3;
if (t[j] == 0)
{
FreeE(fr) = n[j];
FreeE(fr+1)= n[k];
fr += 2;
}
}
}
}
else{
for (Standard_Integer i = 1; i <= nbTriangles; i++) {
for (Standard_Integer i = 1; i <= nbTriangles; i++)
{
triangles(i).Get(n[0],n[1],n[2]);
cdg += (Nodes(n[0]).XYZ() + Nodes(n[1]).XYZ()+ Nodes(n[2]).XYZ())/3.;
}
}
if(nbTriangles!=0) cdg /= nbTriangles;
myCDG3D = gp_Pnt(cdg);
@@ -163,13 +165,14 @@ myDetectedTr(-1)
//function : Select3D_SensitiveTriangulation
//purpose :
//=======================================================================
Select3D_SensitiveTriangulation::
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Poly_Triangulation)& Trg,
const TopLoc_Location& Loc,
const Handle(TColStd_HArray1OfInteger)& FreeEdges,
const gp_Pnt& TheCDG,
const Standard_Boolean InteriorFlag):
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Poly_Triangulation)& Trg,
const TopLoc_Location& Loc,
const Handle(TColStd_HArray1OfInteger)& FreeEdges,
const gp_Pnt& TheCDG,
const Standard_Boolean InteriorFlag):
Select3D_SensitiveEntity(OwnerId),
myTriangul(Trg),
myiniloc(Loc),
@@ -180,6 +183,7 @@ myNodes2d(1,Trg->NbNodes()),
myDetectedTr(-1)
{
}
//=======================================================================
//function : Project
//purpose :
@@ -221,10 +225,11 @@ void Select3D_SensitiveTriangulation::Areas(SelectBasics_ListOfBox2d& boxes)
//function : Matches
//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
Standard_Boolean Select3D_SensitiveTriangulation::
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
// get view direction (necessary for calculation of depth) from field mylastprj of the base class
if (mylastprj.IsNull())
@@ -319,26 +324,27 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
Standard_Boolean Select3D_SensitiveTriangulation::
Matches(const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
Bnd_Box2d B;
B.Update(Min(XMin,XMax)-aTol,
Min(YMin,YMax)-aTol,
Max(XMin,XMax)+aTol,
Max(YMin,YMax)+aTol);
Min(YMin,YMax)-aTol,
Max(XMin,XMax)+aTol,
Max(YMin,YMax)+aTol);
for(Standard_Integer i=myNodes2d.Lower();i<=myNodes2d.Upper();i++){
for(Standard_Integer i=myNodes2d.Lower();i<=myNodes2d.Upper();i++)
{
if(B.IsOut(myNodes2d(i)))
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : Matches
//purpose :
@@ -346,8 +352,8 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real XM
Standard_Boolean Select3D_SensitiveTriangulation::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
@@ -356,21 +362,26 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer j=1;j<=myNodes2d.Length();j++){
for(Standard_Integer j=1;j<=myNodes2d.Length();j++)
{
Standard_Integer RES = aClassifier2d.SiDans(myNodes2d(j));
if(RES!=1) return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : Status
//purpose :
//=======================================================================
Standard_Integer Select3D_SensitiveTriangulation::Status (const gp_XY& TheP,
const gp_XY& Proj0,
const gp_XY& Proj1,
const gp_XY& Proj2,
const Standard_Real aTol,
Standard_Real& DD) const
Standard_Integer Select3D_SensitiveTriangulation::
Status (const gp_XY& TheP,
const gp_XY& Proj0,
const gp_XY& Proj1,
const gp_XY& Proj2,
const Standard_Real aTol,
Standard_Real& DD) const
{
return Select3D_SensitiveTriangle::Status(Proj0,Proj1,Proj2,TheP,aTol,DD);
}
@@ -381,24 +392,31 @@ Standard_Integer Select3D_SensitiveTriangulation::Status (const gp_XY& TheP,
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer IndexOfTriangle,
Standard_Integer& FoundIndex) const
Standard_Integer& FoundIndex) const
{
FoundIndex=-1;
Standard_Integer n[3];
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
triangles(IndexOfTriangle).Get(n[0],n[1],n[2]);
TColStd_Array1OfInteger& FreeE = myFreeEdges->ChangeArray1();
TColStd_Array1OfInteger& FreeE = myFreeEdges->ChangeArray1();
for(Standard_Integer I=1;I<=FreeE.Length() && FoundIndex==-1;I+=2){
if(FreeE(I) == n[0]){
if(FreeE(I+1)== n[1] || FreeE(I+1)== n[2]) FoundIndex=I;}
else if(FreeE(I) == n[1]){
if(FreeE(I+1)== n[0] || FreeE(I+1)== n[2]) FoundIndex=I;}
else if(FreeE(I) == n[2]){
if(FreeE(I+1)== n[0] || FreeE(I+1)== n[1]) FoundIndex=I;}
for(Standard_Integer I=1;I<=FreeE.Length() && FoundIndex==-1;I+=2)
{
if(FreeE(I) == n[0])
{
if(FreeE(I+1)== n[1] || FreeE(I+1)== n[2])
FoundIndex=I;
}
else if(FreeE(I) == n[1])
{
if(FreeE(I+1)== n[0] || FreeE(I+1)== n[2])
FoundIndex=I;
}
else if(FreeE(I) == n[2])
{
if(FreeE(I+1)== n[0] || FreeE(I+1)== n[1])
FoundIndex=I;
}
}
return FoundIndex!=-1;
@@ -409,32 +427,38 @@ Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer
//function : GetConnected
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangulation::
GetConnected(const TopLoc_Location& aLoc)
{
Handle(Select3D_SensitiveTriangulation) NiouEnt =
new Select3D_SensitiveTriangulation(myOwnerId,myTriangul,myiniloc,myFreeEdges,myCDG3D,myIntFlag);
if(HasLocation()) NiouEnt->SetLocation(Location());
if(HasLocation())
NiouEnt->SetLocation(Location());
// TopLoc_Location TheLocToApply = HasLocation() ? Location()*aLoc : aLoc;
// if(!TheLocToApply.IsIdentity())
NiouEnt->UpdateLocation(aLoc);
return NiouEnt;
}
//=======================================================================
//function : ResetLocation
//purpose :
//=======================================================================
void Select3D_SensitiveTriangulation::ResetLocation()
{
Select3D_SensitiveEntity::ResetLocation();
ComputeTotalTrsf();
}
//=======================================================================
//function : SetLocation
//purpose :
//=======================================================================
void Select3D_SensitiveTriangulation::SetLocation(const TopLoc_Location& aLoc)
{
Select3D_SensitiveEntity::SetLocation(aLoc);
@@ -460,7 +484,8 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
S<<"\t\tNb Nodes : "<<myTriangul->NbNodes()<<endl;
S<<"\t\tNb Free Edges: "<<myFreeEdges->Length()/2<<endl;
if(FullDump){
if(FullDump)
{
// S<<"\t\t\tOwner:"<<myOwnerId<<endl;
Select3D_SensitiveEntity::DumpBox(S,mybox2d);
}
@@ -470,6 +495,7 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
//function : ComputeDepth
//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLine) const
{
if(myDetectedTr==-1) return Precision::Infinite(); // currently not implemented...
@@ -480,8 +506,10 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
triangles(myDetectedTr).Get(n1,n2,n3);
gp_Pnt P[3]={Nodes(n1),Nodes(n2),Nodes(n3)};
if(myTrsf.Form()!=gp_Identity){
for(Standard_Integer i =0;i<=2;i++){
if(myTrsf.Form()!=gp_Identity)
{
for(Standard_Integer i =0;i<=2;i++)
{
P[i].Transform(myTrsf);
}
}
@@ -509,7 +537,8 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
#endif
// 3 pts mixed...
if(SingularCase ==2){
if(SingularCase ==2)
{
prof= ElCLib::Parameter(EyeLine,P[0]);
return prof;
}
@@ -522,7 +551,8 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
gp_Vec OPo(Oye,P[0]);
// 2 points mixed... the intersection between the segment and the target line eye/point.
//
if(SingularCase!=-1){
if(SingularCase!=-1)
{
gp_Vec V = SingularCase==0 ? Vtr[2] : Vtr[0];
gp_Vec Det = Dir^V;
gp_Vec VSM = OPo^V;
@@ -533,15 +563,16 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
else if(Det.Z()> Precision::Confusion())
prof = VSM.Z()/Det.Z();
}
else{
else
{
Standard_Real val1 = OPo.DotCross(Vtr[0],Vtr[2]);
Standard_Real val2 = Dir.DotCross(Vtr[0],Vtr[2]);
if(Abs(val2)>Precision::Confusion())
prof =val1/val2;
}
if (prof==Precision::Infinite()){
if (prof==Precision::Infinite())
{
prof= ElCLib::Parameter(EyeLine,P[0]);
prof = Min (prof, ElCLib::Parameter(EyeLine,P[1]));
prof = Min (prof, ElCLib::Parameter(EyeLine,P[2]));
@@ -554,9 +585,11 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
//function : DetectedTriangle
//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
gp_Pnt& P2,
gp_Pnt& P3) const
Standard_Boolean Select3D_SensitiveTriangulation::
DetectedTriangle(gp_Pnt& P1,
gp_Pnt& P2,
gp_Pnt& P3) const
{
if(myDetectedTr==-1) return Standard_False; // currently not implemented...
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
@@ -567,7 +600,8 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
P1 = Nodes(n1);
P2 = Nodes(n2);
P3 = Nodes(n3);
if(myTrsf.Form()!=gp_Identity){
if(myTrsf.Form()!=gp_Identity)
{
P1.Transform(myTrsf);
P2.Transform(myTrsf);
P3.Transform(myTrsf);
@@ -580,8 +614,11 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
// Function : DetectedTriangle2d
// Purpose :
//=============================================================================
Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
gp_Pnt2d& P1, gp_Pnt2d& P2, gp_Pnt2d& P3) const
Standard_Boolean Select3D_SensitiveTriangulation::
DetectedTriangle2d(gp_Pnt2d& P1,
gp_Pnt2d& P2,
gp_Pnt2d& P3) const
{
if(myDetectedTr==-1)
return Standard_False; // currently not implemented...
@@ -603,23 +640,30 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
}
else
return Standard_False;
}
//=============================================================================
// Function : ComputeTotalTrsf
// Purpose :
//=============================================================================
void Select3D_SensitiveTriangulation::ComputeTotalTrsf()
{
Standard_Boolean hasloc = (HasLocation() || !myiniloc.IsIdentity());
if(hasloc){
if(hasloc)
{
if(myiniloc.IsIdentity())
myTrsf = Location().Transformation();
else if(HasLocation()){
else if(HasLocation())
{
myTrsf = (Location()*myiniloc).Transformation();
}
else
myTrsf = myiniloc.Transformation();
}
else{
else
{
gp_Trsf TheId;
myTrsf = TheId;
}

View File

@@ -95,7 +95,10 @@ is
---Purpose:returns <mymaxrect>
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
Dump(me; S: in out OStream;FullDump : Boolean from Standard = Standard_True) is redefined virtual;
Set(me:mutable;TheOwnerId: EntityOwner from SelectBasics) is redefined static;
---Purpose: Sets the owner for all entities in wire
SetLastPrj(me:mutable;aPrj: Projector from Select3D) is redefined virtual;

View File

@@ -22,10 +22,9 @@
// Purpose :Constructor
//=====================================================
Select3D_SensitiveWire::
Select3D_SensitiveWire(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Standard_Integer MaxRect):
const Standard_Integer MaxRect):
Select3D_SensitiveEntity(OwnerId),
mymaxrect(MaxRect),
myDetectedIndex(-1)
@@ -35,16 +34,12 @@ myDetectedIndex(-1)
// Function : Add
// Purpose :
//=====================================================
void Select3D_SensitiveWire
::Add(const Handle(Select3D_SensitiveEntity)& aSensitive)
{
if ( !aSensitive .IsNull()) {
if(!HasLocation())
mysensitive.Append(aSensitive);
else
mysensitive.Append(aSensitive->GetConnected(Location()));
}
if(!aSensitive.IsNull())
mysensitive.Append(aSensitive);
}
//=======================================================================
@@ -64,14 +59,15 @@ void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
Select3D_SensitiveEntity::SetLocation(aLoc);
for(Standard_Integer i=1;i<=mysensitive.Length();i++){
if(mysensitive(i)->HasLocation()){
if(mysensitive(i)->Location()!=aLoc)
mysensitive(i)->SetLocation(mysensitive(i)->Location()*aLoc);
if(mysensitive(i)->Location()!=aLoc)
mysensitive(i)->SetLocation(mysensitive(i)->Location()*aLoc);
}
else
mysensitive(i)->SetLocation(aLoc);
}
}
//=======================================================================
//function : ResetLocation
//purpose :
@@ -89,6 +85,7 @@ void Select3D_SensitiveWire::ResetLocation()
}
Select3D_SensitiveEntity::ResetLocation();
}
//=====================================================
// Function : Project
// Purpose :
@@ -96,7 +93,7 @@ void Select3D_SensitiveWire::ResetLocation()
void Select3D_SensitiveWire
::Project(const Handle(Select3D_Projector)& aProj)
{
for ( Standard_Integer i=1; i<=mysensitive.Length(); i++)
for(Standard_Integer i=1; i<=mysensitive.Length(); i++)
mysensitive(i)->Project(aProj);
Select3D_SensitiveEntity::Project(aProj);
}
@@ -105,6 +102,7 @@ void Select3D_SensitiveWire
// Function : Areas
// Purpose :
//=====================================================
void Select3D_SensitiveWire
::Areas(SelectBasics_ListOfBox2d& theareas)
{
@@ -118,7 +116,6 @@ void Select3D_SensitiveWire
BB.Add(it.Value());
theareas.Append(BB);
}
//=====================================================
@@ -127,20 +124,23 @@ void Select3D_SensitiveWire
//=====================================================
Standard_Boolean Select3D_SensitiveWire
::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
Standard_Integer i;
Standard_Real Dcur;
DMin = Precision::Infinite();
Standard_Boolean IsTouched = Standard_False;
for (i=1; i<=mysensitive.Length(); i++) {
if (mysensitive.Value(i)->Matches(X,Y,aTol,Dcur)) {
for (i=1; i<=mysensitive.Length(); i++)
{
if (mysensitive.Value(i)->Matches(X,Y,aTol,Dcur))
{
IsTouched = Standard_True;
if(Dcur<=DMin){
myDetectedIndex = i;
DMin = Dcur;
if(Dcur<=DMin)
{
myDetectedIndex = i;
DMin = Dcur;
}
}
}
@@ -155,15 +155,17 @@ Standard_Boolean Select3D_SensitiveWire
// Function : Matches
// Purpose :
//=====================================================
Standard_Boolean Select3D_SensitiveWire::
Standard_Boolean Select3D_SensitiveWire::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
Standard_Integer i;
for (i=1; i<=mysensitive.Length(); i++) {
for (i=1; i<=mysensitive.Length(); i++)
{
if (!(mysensitive.Value(i)->Matches(XMin,YMin,XMax,YMax,aTol)))
return Standard_False;
}
@@ -177,11 +179,12 @@ Matches (const Standard_Real XMin,
Standard_Boolean Select3D_SensitiveWire::
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Standard_Integer i;
for (i=1; i<=mysensitive.Length(); i++) {
for (i=1; i<=mysensitive.Length(); i++)
{
if (!(mysensitive.Value(i)->Matches(aPoly, aBox, aTol)))
return Standard_False;
}
@@ -193,6 +196,7 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
// Function : MaxBoxes
// Purpose :
//=====================================================
Standard_Integer Select3D_SensitiveWire::
MaxBoxes () const
{
@@ -203,11 +207,12 @@ MaxBoxes () const
//function : GetConnected
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetConnected(const TopLoc_Location& aLoc)
{
Handle(Select3D_SensitiveWire) SWIR = new Select3D_SensitiveWire(myOwnerId);
for(Standard_Integer i=1;i<=mysensitive.Length();i++)
SWIR->Add(mysensitive(i));
SWIR->Add(mysensitive(i)->GetConnected(aLoc));
if(HasLocation())
SWIR->SetLocation(Location()*aLoc);
@@ -241,6 +246,7 @@ void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean Ful
//function : ComputeDepth
//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveWire::ComputeDepth(const gp_Lin& EyeLine) const
{
@@ -255,6 +261,7 @@ Standard_Real Select3D_SensitiveWire::ComputeDepth(const gp_Lin& EyeLine) const
//function : SetLastPrj
//purpose :
//=======================================================================
void Select3D_SensitiveWire::SetLastPrj(const Handle(Select3D_Projector)& Prj)
{
Select3D_SensitiveEntity::SetLastPrj(Prj);
@@ -267,6 +274,7 @@ void Select3D_SensitiveWire::SetLastPrj(const Handle(Select3D_Projector)& Prj)
//function : GetEdges
//purpose : returns the sensitive edges stored in this wire
//=======================================================================
void Select3D_SensitiveWire::GetEdges( Select3D_SensitiveEntitySequence& theEdges )
{
theEdges.Clear();
@@ -277,6 +285,7 @@ void Select3D_SensitiveWire::GetEdges( Select3D_SensitiveEntitySequence& theEdge
// Function : GetLastDetected
// Purpose :
//=============================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetLastDetected() const
{
Handle(Select3D_SensitiveEntity) aRes;
@@ -286,3 +295,19 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetLastDetected() const
return aRes;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void Select3D_SensitiveWire::Set(const Handle_SelectBasics_EntityOwner &TheOwnerId)
{
Select3D_SensitiveEntity::Set(TheOwnerId);
// Set TheOwnerId for each element of sensitive wire
for (Standard_Integer i = 1; i <= mysensitive.Length(); ++i)
{
mysensitive.Value(i)->Set(TheOwnerId);
}
}