mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
OCC22357 Hidden face selection
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
-- File: Select3D_Projector.cdl
|
||||
-- Created: Thu Mar 12 13:32:28 1992
|
||||
-- Author: Christophe MARION
|
||||
-- <cma@sdsun2> copie quasi exacte de HLRAlgo_Projector
|
||||
---Copyright: Matra Datavision 1992
|
||||
-- File: Select3D_Projector.cdl
|
||||
-- Created: Thu Mar 12 13:32:28 1992
|
||||
-- Author: Christophe MARION
|
||||
-- <cma@sdsun2> copie quasi exacte de HLRAlgo_Projector
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
class Projector from Select3D
|
||||
---Purpose: A framework to define 3D projectors.
|
||||
class Projector from Select3D inherits Transient from Standard
|
||||
---Purpose: A framework to define 3D projectors.
|
||||
uses
|
||||
Real from Standard,
|
||||
Boolean from Standard,
|
||||
Trsf from gp,
|
||||
Trsf from gp,
|
||||
GTrsf from gp,
|
||||
Lin from gp,
|
||||
Pnt from gp,
|
||||
@@ -19,155 +19,169 @@ uses
|
||||
Pnt2d from gp,
|
||||
Box from Bnd,
|
||||
View from V3d
|
||||
|
||||
|
||||
raises
|
||||
NoSuchObject from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(aView:View from V3d) returns Projector from Select3D;
|
||||
--- Purpose: Constructs the 3D projector object defined by the 3D view aView.
|
||||
--- Purpose: Constructs the 3D projector object defined by the 3D view aView.
|
||||
Create returns Projector from Select3D;
|
||||
|
||||
Create(CS : Ax2 from gp)
|
||||
---Purpose: Creates an axonometric projector. <CS> is the
|
||||
-- viewing coordinate system.
|
||||
---Purpose: Creates an axonometric projector. <CS> is the
|
||||
-- viewing coordinate system.
|
||||
returns Projector from Select3D;
|
||||
|
||||
Create(CS : Ax2 from gp;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: Creates a perspective projector. <CS> is the
|
||||
-- viewing coordinate system.
|
||||
Focus : Real from Standard)
|
||||
---Purpose: Creates a perspective projector. <CS> is the
|
||||
-- viewing coordinate system.
|
||||
returns Projector from Select3D;
|
||||
|
||||
Create(T : Trsf from gp;
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: build a Projector with automatic minmax directions.
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: build a Projector with automatic minmax directions.
|
||||
returns Projector from Select3D;
|
||||
|
||||
Create(T : Trsf from gp;
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard;
|
||||
v1,v2,v3 : Vec2d from gp)
|
||||
---Purpose: build a Projector with given minmax directions.
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard;
|
||||
v1,v2,v3 : Vec2d from gp)
|
||||
---Purpose: build a Projector with given minmax directions.
|
||||
returns Projector from Select3D;
|
||||
|
||||
|
||||
Create(GT : GTrsf from gp;
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: build a Projector with automatic minmax directions.
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: build a Projector with automatic minmax directions.
|
||||
returns Projector from Select3D;
|
||||
|
||||
Delete(me:out) is virtual;
|
||||
---C++: alias "Standard_EXPORT virtual ~Select3D_Projector(){Delete() ; }"
|
||||
|
||||
Set (me: in out ;
|
||||
T : Trsf from gp;
|
||||
Set (me : mutable;
|
||||
T : Trsf from gp;
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
Focus : Real from Standard)
|
||||
is static;
|
||||
|
||||
|
||||
SetView(me:in out ; V : View from V3d);
|
||||
---Purpose: Sets the 3D view V used at the time of construction.
|
||||
|
||||
SetView(me : mutable; V : View from V3d);
|
||||
---Purpose: Sets the 3D view V used at the time of construction.
|
||||
|
||||
View(me) returns any View from V3d;
|
||||
---Purpose: Returns the 3D view used at the time of construction.
|
||||
---C++: return const&
|
||||
---C++: inline
|
||||
---Purpose: Returns the 3D view used at the time of construction.
|
||||
---C++: return const&
|
||||
---C++: inline
|
||||
|
||||
|
||||
Directions(me; D1 , D2 , D3 : out Vec2d from gp)
|
||||
---C++: inline
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Scaled(me : in out; On : Boolean from Standard = Standard_False)
|
||||
---Purpose: to compute with the given scale and translation.
|
||||
Scaled(me : mutable; On : Boolean from Standard = Standard_False)
|
||||
---Purpose: to compute with the given scale and translation.
|
||||
is virtual;
|
||||
|
||||
Perspective(me) returns Boolean
|
||||
---Purpose: Returns True if there is a perspective transformation.
|
||||
---C++: inline
|
||||
---Purpose: Returns True if there is a perspective transformation.
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Transformation(me) returns GTrsf from gp
|
||||
---Purpose: Returns the active transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose: Returns the active transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
is virtual;
|
||||
|
||||
InvertedTransformation(me) returns GTrsf from gp
|
||||
---Purpose: Returns the active inverted transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose: Returns the active inverted transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
is virtual;
|
||||
|
||||
FullTransformation(me) returns Trsf from gp
|
||||
---Purpose: Returns the original transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose: Returns the original transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
is virtual;
|
||||
|
||||
Focus(me) returns Real from Standard
|
||||
---Purpose: Returns the focal length.
|
||||
---C++: inline
|
||||
---Purpose: Returns the focal length.
|
||||
---C++: inline
|
||||
raises
|
||||
NoSuchObject from Standard -- if there is no perspective
|
||||
NoSuchObject from Standard -- if there is no perspective
|
||||
is virtual;
|
||||
|
||||
|
||||
Transform(me; D : in out Vec from gp)
|
||||
---C++: inline
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Transform(me; Pnt : in out Pnt from gp)
|
||||
---C++: inline
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
|
||||
Project(me; P : Pnt from gp;
|
||||
Pout : out Pnt2d from gp)
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
is virtual;
|
||||
|
||||
|
||||
Project(me; P : Pnt from gp;
|
||||
X,Y,Z : out Real from Standard)
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
is static;
|
||||
|
||||
|
||||
Project(me; P : Pnt from gp;
|
||||
D1 : Vec from gp;
|
||||
Pout : out Pnt2d from gp;
|
||||
D1out : out Vec2d from gp)
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
Pout : out Pnt2d from gp;
|
||||
D1out : out Vec2d from gp)
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
is virtual;
|
||||
|
||||
|
||||
BoxAdd(me; P : Pnt2d from gp;
|
||||
B : out Box from Bnd)
|
||||
---Purpose: Adds to the box <B> the min-max of the point <P>.
|
||||
---Purpose: Adds to the box <B> the min-max of the point <P>.
|
||||
is virtual;
|
||||
|
||||
Shoot(me; X , Y : Real from Standard)
|
||||
returns Lin from gp
|
||||
---Purpose: return a line going through the eye towards the
|
||||
-- 2d point <X,Y>.
|
||||
---Purpose: return a line going through the eye towards the
|
||||
-- 2d point <X,Y>.
|
||||
is virtual;
|
||||
|
||||
SetDirection(me: in out)
|
||||
is static private;
|
||||
|
||||
Transform(me; P : in out Pnt from gp;
|
||||
T : GTrsf from gp)
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Transform(me; D : in out Lin from gp;
|
||||
T : GTrsf from gp)
|
||||
---C++: inline
|
||||
DepthMin(me) returns Real from Standard;
|
||||
---Purpose: Returns the minimum depth value (if clipping plane defined).
|
||||
--- Should be used when call ::Shoot() to compute eyeline.
|
||||
---C++: inline
|
||||
|
||||
DepthMax(me) returns Real from Standard;
|
||||
---Purpose: Returns the maximum depth value (if clipping plane defined).
|
||||
--- Should be used when call ::Shoot() to compute eyeline.
|
||||
---C++: inline
|
||||
|
||||
DepthMinMax(me : mutable;
|
||||
theDepthMin : in Real from Standard;
|
||||
theDepthMax : in Real from Standard);
|
||||
---Purpose: Setup the min/max depth values (doesn't affect
|
||||
--- projection functionality itself).
|
||||
--- Should be used when call ::Shoot() to compute eyeline.
|
||||
|
||||
SetDirection(me : mutable)
|
||||
is static private;
|
||||
|
||||
Transform(me; P : in out Pnt from gp;
|
||||
T : GTrsf from gp)
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Transform(me; D : in out Lin from gp;
|
||||
T : GTrsf from gp)
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
fields
|
||||
myType : Integer from Standard;
|
||||
|
||||
myType : Integer from Standard;
|
||||
|
||||
myPersp : Boolean from Standard is protected;
|
||||
myFocus : Real from Standard is protected;
|
||||
myScaledTrsf : Trsf from gp is protected;
|
||||
@@ -177,7 +191,8 @@ fields
|
||||
myD2 : Vec2d from gp is protected;
|
||||
myD3 : Vec2d from gp is protected;
|
||||
|
||||
|
||||
myView : View from V3d;
|
||||
myView : View from V3d;
|
||||
myDepthMin : Real from Standard;
|
||||
myDepthMax : Real from Standard;
|
||||
|
||||
end Projector;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun2>
|
||||
|
||||
#define IMP240100 //GG
|
||||
#define IMP240100 //GG
|
||||
// Change RefToPix()/Convert() to Project() method.
|
||||
|
||||
#include <Select3D_Projector.ixx>
|
||||
@@ -14,33 +14,34 @@
|
||||
|
||||
// formula for derivating a perspective, from Mathematica
|
||||
|
||||
// X'[t] X[t] Z'[t]
|
||||
// D1 = -------- + -------------
|
||||
// Z[t] Z[t] 2
|
||||
// 1 - ---- f (1 - ----)
|
||||
// f f
|
||||
// X'[t] X[t] Z'[t]
|
||||
// D1 = -------- + -------------
|
||||
// Z[t] Z[t] 2
|
||||
// 1 - ---- f (1 - ----)
|
||||
// f f
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
Select3D_Projector::Select3D_Projector(const Handle(V3d_View)& aViou):
|
||||
myPersp(aViou->Type()==V3d_PERSPECTIVE),
|
||||
myFocus(aViou->Focale()),
|
||||
myD1(1,0),
|
||||
myD2(0,1),
|
||||
myD3(1,1),
|
||||
myView(aViou)
|
||||
Select3D_Projector::Select3D_Projector(const Handle(V3d_View)& aViou)
|
||||
: myPersp(aViou->Type()==V3d_PERSPECTIVE),
|
||||
myFocus(aViou->Focale()),
|
||||
myD1(1,0),
|
||||
myD2(0,1),
|
||||
myD3(1,1),
|
||||
myView(aViou),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
Standard_Real Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
|
||||
//Standard_Boolean Pers=Standard_False;
|
||||
|
||||
|
||||
aViou->At(Xat,Yat,Zat);
|
||||
aViou->Up(XUp,YUp,ZUp);
|
||||
aViou->Proj(DX,DY,DZ);
|
||||
gp_Pnt At (Xat,Yat,Zat);
|
||||
gp_Pnt At (Xat,Yat,Zat);
|
||||
gp_Dir Zpers (DX,DY,DZ);
|
||||
gp_Dir Ypers (XUp,YUp,ZUp);
|
||||
gp_Dir Xpers = Ypers.Crossed(Zpers);
|
||||
@@ -48,24 +49,37 @@ myView(aViou)
|
||||
myScaledTrsf.SetTransformation(Axe);
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
|
||||
}
|
||||
|
||||
Select3D_Projector::Select3D_Projector () :
|
||||
myPersp(Standard_False),myFocus(0),myD1(1,0),myD2(0,1),myD3(1,1)
|
||||
{
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_Ax2& CS) :
|
||||
myPersp(Standard_False), myFocus(0)
|
||||
Select3D_Projector::Select3D_Projector()
|
||||
: myPersp(Standard_False),
|
||||
myFocus(0),
|
||||
myD1(1,0),
|
||||
myD2(0,1),
|
||||
myD3(1,1),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector (const gp_Ax2& CS)
|
||||
: myPersp(Standard_False),
|
||||
myFocus(0),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
myScaledTrsf.SetTransformation(CS);
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
@@ -75,32 +89,35 @@ Select3D_Projector::Select3D_Projector
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_Ax2& CS,
|
||||
const Standard_Real Focus) :
|
||||
myPersp(Standard_True), myFocus(Focus)
|
||||
{
|
||||
myScaledTrsf.SetTransformation(CS);
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus) :
|
||||
myPersp(Persp),
|
||||
Select3D_Projector::Select3D_Projector (const gp_Ax2& CS,
|
||||
const Standard_Real Focus)
|
||||
: myPersp(Standard_True),
|
||||
myFocus(Focus),
|
||||
myScaledTrsf(T)
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
myScaledTrsf.SetTransformation(CS);
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector (const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus)
|
||||
: myPersp(Persp),
|
||||
myFocus(Focus),
|
||||
myScaledTrsf(T),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
@@ -109,22 +126,23 @@ Select3D_Projector::Select3D_Projector
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus,
|
||||
const gp_Vec2d& v1,
|
||||
const gp_Vec2d& v2,
|
||||
const gp_Vec2d& v3) :
|
||||
myPersp(Persp),
|
||||
Select3D_Projector::Select3D_Projector (const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus,
|
||||
const gp_Vec2d& v1,
|
||||
const gp_Vec2d& v2,
|
||||
const gp_Vec2d& v3)
|
||||
: myPersp(Persp),
|
||||
myFocus(Focus),
|
||||
myScaledTrsf(T),
|
||||
myD1(v1),
|
||||
myD2(v2),
|
||||
myD3(v3)
|
||||
myD3(v3),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
@@ -132,33 +150,31 @@ Select3D_Projector::Select3D_Projector
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_GTrsf& GT,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus) :
|
||||
myPersp(Persp),
|
||||
Select3D_Projector::Select3D_Projector (const gp_GTrsf& GT,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus)
|
||||
: myPersp(Persp),
|
||||
myFocus(Focus),
|
||||
myGTrsf(GT)
|
||||
myGTrsf(GT),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
|
||||
void Select3D_Projector::Delete()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::Set
|
||||
(const gp_Trsf& T,
|
||||
(const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus)
|
||||
const Standard_Real Focus)
|
||||
{
|
||||
myPersp = Persp;
|
||||
myFocus = Focus;
|
||||
@@ -169,59 +185,59 @@ void Select3D_Projector::Set
|
||||
|
||||
//=======================================================================
|
||||
//function : Scaled
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
#include <gp_Mat.hxx>
|
||||
|
||||
static Standard_Integer TrsfType(const gp_GTrsf& Trsf) {
|
||||
static Standard_Integer TrsfType(const gp_GTrsf& Trsf) {
|
||||
const gp_Mat& Mat = Trsf.VectorialPart();
|
||||
if( (Abs(Mat.Value(1,1)-1.0) < 1e-15)
|
||||
if( (Abs(Mat.Value(1,1)-1.0) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,2)-1.0) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,3)-1.0) < 1e-15)) {
|
||||
&& (Abs(Mat.Value(3,3)-1.0) < 1e-15)) {
|
||||
return(1); //-- top
|
||||
}
|
||||
else if( (Abs(Mat.Value(1,1)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(1,2)+0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(1,3)-0.5) < 1e-15)
|
||||
|
||||
|
||||
&& (Abs(Mat.Value(2,1)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,2)-0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,3)+0.5) < 1e-15)
|
||||
|
||||
&& (Abs(Mat.Value(3,1)) < 1e-15)
|
||||
|
||||
&& (Abs(Mat.Value(3,1)) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,2)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,3)-0.7071067811865476) < 1e-15)) {
|
||||
return(0); //--
|
||||
&& (Abs(Mat.Value(3,3)-0.7071067811865476) < 1e-15)) {
|
||||
return(0); //--
|
||||
}
|
||||
else if( (Abs(Mat.Value(1,1)-1.0) < 1e-15)
|
||||
else if( (Abs(Mat.Value(1,1)-1.0) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,3)-1.0) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,2)+1.0) < 1e-15)) {
|
||||
&& (Abs(Mat.Value(3,2)+1.0) < 1e-15)) {
|
||||
return(2); //-- front
|
||||
}
|
||||
else if( (Abs(Mat.Value(1,1)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(1,2)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(1,3)) < 1e-15)
|
||||
|
||||
|
||||
&& (Abs(Mat.Value(2,1)+0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,2)-0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,3)-0.7071067811865476) < 1e-15)
|
||||
|
||||
&& (Abs(Mat.Value(3,1)-0.5) < 1e-15)
|
||||
|
||||
&& (Abs(Mat.Value(3,1)-0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,2)+0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,3)-0.7071067811865476) < 1e-15)) {
|
||||
&& (Abs(Mat.Value(3,3)-0.7071067811865476) < 1e-15)) {
|
||||
return(3); //-- axo
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void Select3D_Projector::Scaled (const Standard_Boolean On)
|
||||
{
|
||||
{
|
||||
myType=-1;
|
||||
if (!On) {
|
||||
if (!myPersp) {
|
||||
if (!myPersp) {
|
||||
//myGTrsf.SetTranslationPart(gp_XYZ(0.,0.,0.));
|
||||
myType=TrsfType(myGTrsf);
|
||||
myType=TrsfType(myGTrsf);
|
||||
}
|
||||
}
|
||||
myInvTrsf = myGTrsf;
|
||||
@@ -230,7 +246,7 @@ void Select3D_Projector::Scaled (const Standard_Boolean On)
|
||||
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
@@ -249,9 +265,9 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
Pout.SetCoord(Xout,Yout);
|
||||
}
|
||||
else{
|
||||
if(myType!=-1) {
|
||||
if(myType!=-1) {
|
||||
Standard_Real X,Y;
|
||||
switch (myType) {
|
||||
switch (myType) {
|
||||
case 0: { //-- axono standard
|
||||
Standard_Real x07 = P.X()*0.7071067811865475;
|
||||
Standard_Real y05 = P.Y()*0.5;
|
||||
@@ -266,12 +282,12 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
Pout.SetCoord(X,Y);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
case 2: {
|
||||
X=P.X(); Y=P.Z(); //-- Z=-P.Y();
|
||||
Pout.SetCoord(X,Y);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
case 3: {
|
||||
Standard_Real xmy05 = (P.X()-P.Y())*0.5;
|
||||
Standard_Real z07 = P.Z()*0.7071067811865476;
|
||||
X=0.7071067811865476*(P.X()+P.Y());
|
||||
@@ -280,37 +296,37 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
//-- Z= xmy05+z07;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default: {
|
||||
gp_Pnt P2 = P;
|
||||
Transform(P2);
|
||||
if (myPersp) {
|
||||
Standard_Real R = 1.-P2.Z()/myFocus;
|
||||
Pout.SetCoord(P2.X()/R,P2.Y()/R);
|
||||
}
|
||||
else
|
||||
Pout.SetCoord(P2.X(),P2.Y());
|
||||
else
|
||||
Pout.SetCoord(P2.X(),P2.Y());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else {
|
||||
gp_Pnt P2 = P;
|
||||
Transform(P2);
|
||||
if (myPersp) {
|
||||
Standard_Real R = 1.-P2.Z()/myFocus;
|
||||
Pout.SetCoord(P2.X()/R,P2.Y()/R);
|
||||
}
|
||||
else
|
||||
Pout.SetCoord(P2.X(),P2.Y());
|
||||
else
|
||||
Pout.SetCoord(P2.X(),P2.Y());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
/* ====== TYPE 0 (??)
|
||||
(0.7071067811865476, -0.5 , 0.4999999999999999)
|
||||
@@ -327,7 +343,7 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
(0.0, 1.110223024625157e-16 , 1.0)
|
||||
(0.0, -1.0 , 1.110223024625157e-16)
|
||||
|
||||
======= TYPE 3
|
||||
======= TYPE 3
|
||||
( 0.7071067811865476, 0.7071067811865475, 0.0)
|
||||
(-0.5 , 0.5000000000000001, 0.7071067811865475)
|
||||
( 0.4999999999999999, -0.5 , 0.7071067811865476)
|
||||
@@ -349,8 +365,8 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
if(myType!=-1) {
|
||||
switch (myType) {
|
||||
if(myType!=-1) {
|
||||
switch (myType) {
|
||||
case 0: { //-- axono standard
|
||||
Standard_Real x07 = P.X()*0.7071067811865475;
|
||||
Standard_Real y05 = P.Y()*0.5;
|
||||
@@ -364,11 +380,11 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
X=P.X(); Y=P.Y(); Z=P.Z();
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
case 2: {
|
||||
X=P.X(); Y=P.Z(); Z=-P.Y();
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
case 3: {
|
||||
Standard_Real xmy05 = (P.X()-P.Y())*0.5;
|
||||
Standard_Real z07 = P.Z()*0.7071067811865476;
|
||||
X=0.7071067811865476*(P.X()+P.Y());
|
||||
@@ -376,7 +392,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
Z= xmy05+z07;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default: {
|
||||
gp_Pnt P2 = P;
|
||||
Transform(P2);
|
||||
P2.Coord(X,Y,Z);
|
||||
@@ -384,7 +400,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else {
|
||||
gp_Pnt P2 = P;
|
||||
Transform(P2);
|
||||
P2.Coord(X,Y,Z);
|
||||
@@ -398,7 +414,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
@@ -424,7 +440,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
|
||||
//=======================================================================
|
||||
//function : BoxAdd
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::BoxAdd
|
||||
@@ -438,7 +454,7 @@ void Select3D_Projector::BoxAdd
|
||||
|
||||
//=======================================================================
|
||||
//function : Shoot
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Lin Select3D_Projector::Shoot
|
||||
@@ -446,7 +462,7 @@ gp_Lin Select3D_Projector::Shoot
|
||||
const Standard_Real Y) const
|
||||
{
|
||||
gp_Lin L;
|
||||
|
||||
|
||||
if (myPersp) {
|
||||
L = gp_Lin(gp_Pnt(0,0, myFocus),
|
||||
gp_Dir(X,Y,-myFocus));
|
||||
@@ -462,10 +478,10 @@ gp_Lin Select3D_Projector::Shoot
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDirection
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::SetDirection ()
|
||||
void Select3D_Projector::SetDirection ()
|
||||
{
|
||||
gp_Vec V1(1,0,0);
|
||||
Transform(V1);
|
||||
@@ -491,16 +507,23 @@ void Select3D_Projector::SetView(const Handle(V3d_View)& aViou)
|
||||
myFocus= aViou->Focale();
|
||||
Standard_Real Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
|
||||
//Standard_Boolean Pers=Standard_False;
|
||||
|
||||
|
||||
aViou->At(Xat,Yat,Zat);
|
||||
aViou->Up(XUp,YUp,ZUp);
|
||||
aViou->Proj(DX,DY,DZ);
|
||||
gp_Pnt At (Xat,Yat,Zat);
|
||||
gp_Pnt At (Xat,Yat,Zat);
|
||||
gp_Dir Zpers (DX,DY,DZ);
|
||||
gp_Dir Ypers (XUp,YUp,ZUp);
|
||||
gp_Dir Xpers = Ypers.Crossed(Zpers);
|
||||
gp_Ax3 Axe (At, Zpers, Xpers);
|
||||
myScaledTrsf.SetTransformation(Axe);
|
||||
Scaled();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Select3D_Projector::DepthMinMax (const Standard_Real theDepthMin,
|
||||
const Standard_Real theDepthMax)
|
||||
{
|
||||
myDepthMin = theDepthMin;
|
||||
myDepthMax = theDepthMax;
|
||||
}
|
||||
|
@@ -12,10 +12,10 @@
|
||||
|
||||
//=======================================================================
|
||||
//function : Directions
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void Select3D_Projector::Directions
|
||||
inline void Select3D_Projector::Directions
|
||||
(gp_Vec2d& D1, gp_Vec2d& D2, gp_Vec2d& D3) const
|
||||
{
|
||||
D1 = myD1;
|
||||
@@ -25,7 +25,7 @@ inline void Select3D_Projector::Directions
|
||||
|
||||
//=======================================================================
|
||||
//function : Perspective
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean Select3D_Projector::Perspective() const
|
||||
@@ -33,7 +33,7 @@ inline Standard_Boolean Select3D_Projector::Perspective() const
|
||||
|
||||
//=======================================================================
|
||||
//function : Transformation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const gp_GTrsf& Select3D_Projector::Transformation() const
|
||||
@@ -41,7 +41,7 @@ inline const gp_GTrsf& Select3D_Projector::Transformation() const
|
||||
|
||||
//=======================================================================
|
||||
//function : InvertedTransformation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
|
||||
@@ -49,7 +49,7 @@ inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
|
||||
|
||||
//=======================================================================
|
||||
//function : FullTransformation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const gp_Trsf& Select3D_Projector::FullTransformation() const
|
||||
@@ -57,7 +57,7 @@ inline const gp_Trsf& Select3D_Projector::FullTransformation() const
|
||||
|
||||
//=======================================================================
|
||||
//function : Focus
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real Select3D_Projector::Focus() const
|
||||
@@ -69,7 +69,7 @@ inline Standard_Real Select3D_Projector::Focus() const
|
||||
|
||||
//=======================================================================
|
||||
//function : Transform
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void Select3D_Projector::Transform (gp_Vec& D) const
|
||||
@@ -83,11 +83,11 @@ inline void Select3D_Projector::Transform (gp_Vec& D) const
|
||||
|
||||
//=======================================================================
|
||||
//function : Transform
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void Select3D_Projector::Transform (gp_Pnt& Pnt) const
|
||||
{
|
||||
{
|
||||
gp_XYZ xyz = Pnt.XYZ();
|
||||
myGTrsf.Transforms(xyz);
|
||||
Pnt = gp_Pnt(xyz);
|
||||
@@ -98,7 +98,7 @@ inline const Handle(V3d_View)& Select3D_Projector::View() const
|
||||
{return myView;}
|
||||
|
||||
inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const
|
||||
{
|
||||
{
|
||||
gp_Ax1 ax1 = Lin.Position();
|
||||
gp_XYZ xyz = ax1.Location().XYZ();
|
||||
T.Transforms(xyz);
|
||||
@@ -118,10 +118,18 @@ inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const
|
||||
}
|
||||
|
||||
inline void Select3D_Projector::Transform (gp_Pnt& Pnt, const gp_GTrsf& T) const
|
||||
{
|
||||
{
|
||||
gp_XYZ xyz = Pnt.XYZ();
|
||||
T.Transforms(xyz);
|
||||
Pnt = gp_Pnt(xyz);
|
||||
}
|
||||
|
||||
inline Standard_Real Select3D_Projector::DepthMin() const
|
||||
{
|
||||
return myDepthMin;
|
||||
}
|
||||
|
||||
inline Standard_Real Select3D_Projector::DepthMax() const
|
||||
{
|
||||
return myDepthMax;
|
||||
}
|
||||
|
@@ -49,10 +49,10 @@ Select3D_SensitiveEntity(OwnerId)
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void Select3D_SensitiveBox::
|
||||
Project(const Select3D_Projector& aProj)
|
||||
Project(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
|
||||
|
||||
if(HasLocation()){
|
||||
Bnd_Box B = mybox3d.Transformed(Location().Transformation());
|
||||
ProjectBox(aProj,B);
|
||||
@@ -164,29 +164,29 @@ void Select3D_SensitiveBox::Dump(Standard_OStream& S,const Standard_Boolean Full
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveBox::ProjectBox(const Select3D_Projector& aPrj,
|
||||
void Select3D_SensitiveBox::ProjectBox(const Handle(Select3D_Projector)& aPrj,
|
||||
const Bnd_Box& aBox)
|
||||
{
|
||||
mybox2d.SetVoid();
|
||||
gp_Pnt2d curp2d;
|
||||
Standard_Real XMin,YMin,ZMin,XMax,YMax,ZMax;
|
||||
aBox.Get(XMin,YMin,ZMin,XMax,YMax,ZMax);
|
||||
|
||||
aPrj.Project(gp_Pnt(XMin,YMin,ZMin),curp2d);
|
||||
|
||||
aPrj->Project(gp_Pnt(XMin,YMin,ZMin),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMax,YMin,ZMin),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMax,YMin,ZMin),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMax,YMax,ZMin),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMax,YMax,ZMin),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMin,YMax,ZMin),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMin,YMax,ZMin),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMin,YMin,ZMax),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMin,YMin,ZMax),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMax,YMin,ZMax),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMax,YMin,ZMax),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMax,YMax,ZMax),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMax,YMax,ZMax),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMin,YMax,ZMax),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMin,YMax,ZMax),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
}
|
||||
|
||||
|
@@ -64,16 +64,18 @@ Standard_Boolean Select3D_SensitiveCurve
|
||||
Standard_Integer Rank;
|
||||
TColgp_Array1OfPnt2d aArrayOf2dPnt(1, mynbpoints);
|
||||
Points2D(aArrayOf2dPnt);
|
||||
Standard_Boolean KK = SelectBasics_BasicTool::MatchPolyg2d(aArrayOf2dPnt,
|
||||
X,Y,
|
||||
aTol,
|
||||
DMin,
|
||||
Rank);
|
||||
if(KK){
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
if (SelectBasics_BasicTool::MatchPolyg2d (aArrayOf2dPnt,
|
||||
X, Y,
|
||||
aTol,
|
||||
DMin,
|
||||
Rank))
|
||||
{
|
||||
mylastseg = Rank;
|
||||
// compute and validate the depth (::Depth()) along the eyeline
|
||||
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin);
|
||||
|
||||
}
|
||||
return KK;
|
||||
return Standard_False;
|
||||
|
||||
}
|
||||
//==================================================
|
||||
|
@@ -1,18 +1,18 @@
|
||||
-- File: Select3D_SensitiveEntity.cdl
|
||||
-- Created: Tue Jan 24 09:30:34 1995
|
||||
-- Author: Rob
|
||||
-- modified by rob jul/ 21/ 97 : inserting locations ...
|
||||
-- modified by rob jul/ 21/ 97 : inserting locations ...
|
||||
-- modified by rob jan/ 29/ 98 : Sort by deph-> add a field to be able
|
||||
-- to compute a depth
|
||||
-- to compute a depth
|
||||
-- -> Virtual methods rather than
|
||||
-- Deferred for Project
|
||||
-- WARNING : Must be redefined for
|
||||
-- WARNING : Must be redefined for
|
||||
-- each kind of sensitive entity
|
||||
--
|
||||
--
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
deferred class SensitiveEntity from Select3D inherits
|
||||
deferred class SensitiveEntity from Select3D inherits
|
||||
SensitiveEntity from SelectBasics
|
||||
|
||||
---Purpose: Abstract framework to define 3D sensitive entities.
|
||||
@@ -29,7 +29,7 @@ uses
|
||||
EntityOwner from SelectBasics,
|
||||
Location from TopLoc,
|
||||
Lin from gp,
|
||||
Box2d from Bnd,
|
||||
Box2d from Bnd,
|
||||
Array1OfPnt2d from TColgp
|
||||
|
||||
is
|
||||
@@ -37,26 +37,26 @@ is
|
||||
Initialize(OwnerId : EntityOwner from SelectBasics);
|
||||
|
||||
NeedsConversion(me) returns Boolean is redefined static;
|
||||
---Level: Public
|
||||
---Level: Public
|
||||
---Purpose: Returns true if this framework needs conversion.
|
||||
---C++: inline
|
||||
|
||||
|
||||
Is3D(me) returns Boolean from Standard is redefined static;
|
||||
---Purpose: Returns true if this framework provides 3D information.
|
||||
|
||||
Project (me:mutable;aProjector : Projector from Select3D) is virtual;
|
||||
---Level: Public
|
||||
---Level: Public
|
||||
---Purpose:Returns the projector aProjector.
|
||||
-- In classes inheriting this framework, you must
|
||||
-- redefine this function in order to get a sensitive 2D
|
||||
-- rectangle from a 3D entity. This rectangle is the
|
||||
-- sensitive zone which makes the 3D entity selectable.
|
||||
-- sensitive zone which makes the 3D entity selectable.
|
||||
|
||||
|
||||
MaxBoxes(me) returns Integer is redefined virtual;
|
||||
---Level: Public
|
||||
---Purpose: Returns the max number of sensitive areas returned
|
||||
-- by this class is 1 by default.
|
||||
---Level: Public
|
||||
---Purpose: Returns the max number of sensitive areas returned
|
||||
-- by this class is 1 by default.
|
||||
-- Else on must redefine this method.
|
||||
|
||||
|
||||
@@ -66,18 +66,18 @@ is
|
||||
-- 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.
|
||||
|
||||
Matches(me :mutable;
|
||||
|
||||
Matches(me :mutable;
|
||||
X,Y : Real from Standard;
|
||||
aTol: Real from Standard;
|
||||
DMin: out Real from Standard)
|
||||
DMin: out Real from Standard)
|
||||
returns Boolean is redefined virtual;
|
||||
---Purpose: Matches the coordinates X, Y with the entity found at
|
||||
-- that point within the tolerance aTol and the minimum depth DMin.
|
||||
-- You must redefine this function for every inheriting entity.
|
||||
-- You will have to call this framework inside the redefined function.
|
||||
|
||||
Matches (me :mutable;
|
||||
Matches (me :mutable;
|
||||
XMin,YMin,XMax,YMax : Real from Standard;
|
||||
aTol: Real from Standard)
|
||||
returns Boolean from Standard is redefined virtual;
|
||||
@@ -89,8 +89,8 @@ is
|
||||
-- maximum point in the upper right hand corner of the box.
|
||||
-- You must redefine this function for every inheriting entity.
|
||||
-- You will have to call this framework inside the redefined function.
|
||||
|
||||
Matches (me :mutable;
|
||||
|
||||
Matches (me :mutable;
|
||||
Polyline:Array1OfPnt2d from TColgp;
|
||||
aBox:Box2d from Bnd;
|
||||
aTol: Real from Standard)
|
||||
@@ -100,14 +100,14 @@ is
|
||||
|
||||
GetEyeLine(me; X,Y : Real from Standard) returns Lin from gp;
|
||||
---Purpose: Returns the eye line for the point defined by the coordinates X,Y.
|
||||
|
||||
ComputeDepth(me;EyeLine : Lin from gp) returns Real from Standard
|
||||
|
||||
ComputeDepth(me;EyeLine : Lin from gp) returns Real from Standard
|
||||
is deferred;
|
||||
---Purpose: Returns the depth of this object on the line EyeLine.
|
||||
-- EyeLine goes through the eye towards a point
|
||||
-- defined by the coordinates X,Y in the function GetEyeLine.
|
||||
---Purpose: gives an abcissa on <aLin> .
|
||||
-- <aLin> represents the line going through
|
||||
-- <aLin> represents the line going through
|
||||
-- the eye towards an X,Y point on the screen. This Method
|
||||
-- must return a mean Depth on this line.
|
||||
|
||||
@@ -115,7 +115,7 @@ is
|
||||
Depth(me) returns Real from Standard is redefined;
|
||||
|
||||
---Category: Location of sensitive entities...
|
||||
-- Default implementations of HasLocation() and Location() rely on
|
||||
-- Default implementations of HasLocation() and Location() rely on
|
||||
-- location obtained from the entity owner, to minimize memory usage.
|
||||
-- SetLocation() and ResetLocation() do nothing by default.
|
||||
|
||||
@@ -134,7 +134,7 @@ is
|
||||
---Purpose: 2 options :
|
||||
-- <FullDump> = False -> general information
|
||||
-- <FullDump> = True -> whole informtion 3D +2d ...
|
||||
|
||||
|
||||
DumpBox(myclass; S: in out OStream;abox:Box2d from Bnd) ;
|
||||
|
||||
UpdateLocation(me:mutable;aLoc:Location from TopLoc);
|
||||
@@ -145,8 +145,8 @@ is
|
||||
SetLastDepth(me:mutable; aDepth: Real from Standard) is protected;
|
||||
|
||||
fields
|
||||
|
||||
mylastprj : Address from Standard is protected;
|
||||
|
||||
mylastprj : Projector from Select3D is protected;
|
||||
mylastdepth : ShortReal from Standard;
|
||||
end SensitiveEntity;
|
||||
|
||||
|
@@ -19,8 +19,8 @@
|
||||
|
||||
Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
|
||||
SelectBasics_SensitiveEntity(OwnerId),
|
||||
mylastprj(NULL),
|
||||
mylastdepth(0.0)
|
||||
mylastprj(),
|
||||
mylastdepth(ShortRealLast())
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
@@ -28,9 +28,9 @@ mylastdepth(0.0)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveEntity::Project(const Select3D_Projector& aPrj)
|
||||
void Select3D_SensitiveEntity::Project(const Handle(Select3D_Projector)& aPrj)
|
||||
{
|
||||
mylastprj = (Standard_Address*)&aPrj;
|
||||
mylastprj = aPrj;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -43,12 +43,17 @@ Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
|
||||
const Standard_Real aTol,
|
||||
Standard_Real& DMin)
|
||||
{
|
||||
gp_Lin L;
|
||||
if(mylastprj!=NULL)
|
||||
L = (* ((Select3D_Projector*) mylastprj)).Shoot(X,Y);
|
||||
SetLastDepth( ComputeDepth(L) );
|
||||
|
||||
return (Abs(mylastdepth)>Precision::Confusion());
|
||||
if (!mylastprj.IsNull())
|
||||
{
|
||||
gp_Lin L = mylastprj->Shoot (X, Y);
|
||||
SetLastDepth (ComputeDepth (L));
|
||||
return (mylastdepth > mylastprj->DepthMin()) && (mylastdepth < mylastprj->DepthMax());
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastDepth (ComputeDepth (gp_Lin())); // how we determine depth without eyeline here?
|
||||
return (mylastdepth > ShortRealFirst()) && (mylastdepth < ShortRealLast());
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -184,8 +189,10 @@ gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
|
||||
const Standard_Real Y) const
|
||||
{
|
||||
gp_Lin L;
|
||||
if(mylastprj!=NULL)
|
||||
L = (* ((Select3D_Projector*) mylastprj)).Shoot(X,Y);
|
||||
if (!mylastprj.IsNull())
|
||||
{
|
||||
L = mylastprj->Shoot (X, Y);
|
||||
}
|
||||
return L;
|
||||
}
|
||||
|
||||
@@ -202,8 +209,8 @@ Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveEntity::SetLastPrj(const Select3D_Projector& aprj)
|
||||
{ mylastprj = (Standard_Address*)& aprj;}
|
||||
void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj)
|
||||
{ mylastprj = aprj; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -8,6 +8,7 @@
|
||||
//Modif on jul-21-97 : changement en harray1 pour eventuelles connexions ...
|
||||
|
||||
#include <Select3D_SensitiveFace.ixx>
|
||||
#include <Select3D_Projector.hxx>
|
||||
#include <SelectBasics_BasicTool.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
@@ -117,11 +118,9 @@ Matches(const Standard_Real X,
|
||||
Standard_Real valtst = PlaneTest^V1;
|
||||
if(isplane2d && Abs(valtst)>aTol) isplane2d=Standard_False;
|
||||
}
|
||||
|
||||
if(isplane2d) {
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
|
||||
return Standard_True;
|
||||
if (isplane2d)
|
||||
{
|
||||
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
}
|
||||
//detection d'une auto - intersection dans le polygon 2D; si oui on sort
|
||||
// if (!AutoComputeFlag(myautointer)) {
|
||||
@@ -151,10 +150,11 @@ Matches(const Standard_Real X,
|
||||
res = Standard_True;
|
||||
}
|
||||
}
|
||||
if(res)
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
|
||||
return res;
|
||||
if (res)
|
||||
{
|
||||
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -230,8 +230,17 @@ void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean Ful
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const
|
||||
{
|
||||
Standard_Real val(Precision::Infinite());
|
||||
for(Standard_Integer i=0;i<mynbpoints-1;i++)
|
||||
val = Min(val,ElCLib::Parameter(EyeLine,((Select3D_Pnt*)mypolyg3d)[i]));
|
||||
return val;
|
||||
Standard_Real aDepth = Precision::Infinite();
|
||||
Standard_Real aDepthMin = !mylastprj.IsNull() ? mylastprj->DepthMin() : -Precision::Infinite();
|
||||
Standard_Real aDepthMax = !mylastprj.IsNull() ? mylastprj->DepthMax() : Precision::Infinite();
|
||||
Standard_Real aDepthTest;
|
||||
for (Standard_Integer i = 0; i < mynbpoints - 1; i++)
|
||||
{
|
||||
aDepthTest = ElCLib::Parameter (EyeLine, ((Select3D_Pnt* )mypolyg3d)[i]);
|
||||
if (aDepthTest < aDepth && (aDepthTest > aDepthMin) && (aDepthTest < aDepthMax))
|
||||
{
|
||||
aDepth = aDepthTest;
|
||||
}
|
||||
}
|
||||
return aDepth;
|
||||
}
|
||||
|
@@ -89,10 +89,10 @@ void Select3D_SensitiveGroup::Clear()
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveGroup::Project(const Select3D_Projector& aProjector)
|
||||
void Select3D_SensitiveGroup::Project(const Handle(Select3D_Projector)& aProjector)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProjector); // to set the field last proj...
|
||||
|
||||
|
||||
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
|
||||
It.Value()->Project(aProjector);
|
||||
}
|
||||
@@ -180,16 +180,16 @@ Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real X,
|
||||
myLastTol = aTol;
|
||||
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
|
||||
myLastRank++;
|
||||
if(It.Value()->Matches(X,Y,aTol,DMin)){
|
||||
myX = X;myY = Y;myLastTol = aTol;
|
||||
SetLastDepth( Precision::Infinite() );
|
||||
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
return Standard_True;
|
||||
if (It.Value()->Matches (X, Y, aTol, DMin))
|
||||
{
|
||||
myX = X; myY = Y; myLastTol = aTol;
|
||||
// compute and validate the depth (will call ::ComputeDepth())
|
||||
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin);
|
||||
}
|
||||
}
|
||||
myLastRank =0;
|
||||
SetLastDepth(0.0);
|
||||
// no match
|
||||
myLastRank = 0;
|
||||
SetLastDepth (ShortRealLast());
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
@@ -258,18 +258,25 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveGroup::ComputeDepth(const gp_Lin& EyeLine) const
|
||||
{
|
||||
Standard_Integer currank(0);
|
||||
Standard_Real DMin,thedepth(Precision::Infinite());
|
||||
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
|
||||
Standard_Integer currank = 0;
|
||||
Standard_Real DMin, thedepth (Precision::Infinite());
|
||||
for (Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
|
||||
{
|
||||
currank++;
|
||||
if(currank>=myLastRank){
|
||||
if(It.Value()->Matches(myX,myY,myLastTol,DMin)){
|
||||
It.Value()->ComputeDepth(EyeLine);
|
||||
thedepth = Min(Depth(),
|
||||
It.Value()->Depth());
|
||||
if (currank >= myLastRank)
|
||||
{
|
||||
// this recomputes and validates the depth for the entity
|
||||
if (It.Value()->Matches (myX, myY, myLastTol, DMin))
|
||||
{
|
||||
It.Value()->ComputeDepth (EyeLine);
|
||||
if (It.Value()->Depth() < thedepth)
|
||||
{
|
||||
// search for topmost entity
|
||||
thedepth = It.Value()->Depth();
|
||||
//myLastRank = currank; // can not do this here...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return thedepth;
|
||||
}
|
||||
@@ -287,7 +294,7 @@ Standard_Integer Select3D_SensitiveGroup::MaxBoxes() const
|
||||
return nbboxes;
|
||||
}
|
||||
|
||||
void Select3D_SensitiveGroup::SetLastPrj(const Select3D_Projector& Prj)
|
||||
void Select3D_SensitiveGroup::SetLastPrj(const Handle(Select3D_Projector)& Prj)
|
||||
{
|
||||
Select3D_SensitiveEntity::SetLastPrj(Prj);
|
||||
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
|
||||
|
@@ -32,15 +32,15 @@ Select3D_SensitiveEntity(anOwner)
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void Select3D_SensitivePoint
|
||||
::Project (const Select3D_Projector& aProj)
|
||||
::Project (const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
gp_Pnt2d aPoint2d;
|
||||
if(!HasLocation())
|
||||
aProj.Project(mypoint, aPoint2d);
|
||||
aProj->Project(mypoint, aPoint2d);
|
||||
else{
|
||||
gp_Pnt aP(mypoint.x, mypoint.y, mypoint.z);
|
||||
aProj.Project(aP.Transformed(Location().Transformation()), aPoint2d);
|
||||
aProj->Project(aP.Transformed(Location().Transformation()), aPoint2d);
|
||||
}
|
||||
myprojpt = aPoint2d;
|
||||
}
|
||||
@@ -69,9 +69,10 @@ Standard_Boolean Select3D_SensitivePoint
|
||||
Standard_Real& DMin)
|
||||
{
|
||||
DMin = gp_Pnt2d(X,Y).Distance(myprojpt);
|
||||
if(DMin<=aTol*SensitivityFactor()) {
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
return Standard_True;
|
||||
if(DMin<=aTol*SensitivityFactor())
|
||||
{
|
||||
// compute and validate the depth (::Depth()) along the eyeline
|
||||
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ Select3D_SensitiveEntity(OwnerId)
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void Select3D_SensitivePoly::Project(const Select3D_Projector& aProj)
|
||||
void Select3D_SensitivePoly::Project(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
mybox2d.SetVoid();
|
||||
@@ -71,11 +71,14 @@ void Select3D_SensitivePoly::Project(const Select3D_Projector& aProj)
|
||||
for(Standard_Integer i=0;i<mynbpoints;i++)
|
||||
{
|
||||
gp_Pnt aPnt(((Select3D_Pnt*)mypolyg3d)[i].x, ((Select3D_Pnt*)mypolyg3d)[i].y, ((Select3D_Pnt*)mypolyg3d)[i].z);
|
||||
if(hasloc){
|
||||
aProj.Project(aPnt.Transformed(Location().Transformation()),aPnt2d);
|
||||
if (hasloc)
|
||||
{
|
||||
aProj->Project(aPnt.Transformed(Location().Transformation()),aPnt2d);
|
||||
}
|
||||
else
|
||||
aProj.Project(aPnt,aPnt2d);
|
||||
{
|
||||
aProj->Project(aPnt,aPnt2d);
|
||||
}
|
||||
mybox2d.Update(aPnt2d);
|
||||
((Select3D_Pnt2d*)mypolyg2d)[i] = aPnt2d;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ mymaxrect(MaxRect)
|
||||
// Purpose :
|
||||
//=====================================================
|
||||
void Select3D_SensitiveSegment
|
||||
::Project(const Select3D_Projector& aProj)
|
||||
::Project(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
gp_Pnt2d aPoint2dStart;
|
||||
@@ -54,12 +54,12 @@ void Select3D_SensitiveSegment
|
||||
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);
|
||||
aProj->Project(aStart.Transformed(Location().Transformation()),aPoint2dStart);
|
||||
aProj->Project(aEnd.Transformed(Location().Transformation()),aPoint2dEnd);
|
||||
}
|
||||
else{
|
||||
aProj.Project(mystart,aPoint2dStart);
|
||||
aProj.Project(myend,aPoint2dEnd);
|
||||
aProj->Project(mystart,aPoint2dStart);
|
||||
aProj->Project(myend,aPoint2dEnd);
|
||||
}
|
||||
myprojstart = aPoint2dStart;
|
||||
myprojend = aPoint2dEnd;
|
||||
@@ -124,8 +124,7 @@ Standard_Boolean Select3D_SensitiveSegment
|
||||
gp_Pnt2d aPEnd(myprojend.x,myprojend.y);
|
||||
if ( ! SelectBasics_BasicTool::MatchSegment (aPStart, aPEnd, X, Y, aTol, DMin) )
|
||||
return Standard_False;
|
||||
Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin); // to compute depth
|
||||
return Standard_True;
|
||||
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin); // compute and validate depth
|
||||
}
|
||||
|
||||
Standard_Boolean Select3D_SensitiveSegment::
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <Select3D_SensitiveTriangulation.ixx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <Poly.hxx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <CSLib_Class2d.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
@@ -31,7 +32,7 @@ static Standard_Integer S3D_NumberOfFreeEdges(const Handle(Poly_Triangulation)&
|
||||
for (j = 0; j < 3; j++)
|
||||
if (t[j] == 0) nFree++;
|
||||
}
|
||||
return nFree;
|
||||
return nFree;
|
||||
}
|
||||
static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY& p1, const gp_XY& TheP,
|
||||
const Standard_Real aTol, Standard_Real& aDMin)
|
||||
@@ -45,7 +46,7 @@ static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY&
|
||||
|
||||
gp_XY V01(p1);V01-=p0;
|
||||
gp_XY Vec(TheP);Vec -= p0;
|
||||
|
||||
|
||||
Standard_Real u = Vec*V01.Normalized();
|
||||
if(u<-aTol) return Standard_False;
|
||||
Standard_Real u1 = u-aTol;
|
||||
@@ -68,12 +69,12 @@ static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY&
|
||||
// VEdg-= PEdg2.XY();
|
||||
// VCur-=PCur.XY();
|
||||
// Standard_Real long1 = VEdg.SquareModulus();
|
||||
|
||||
|
||||
// if(long1<=TolTol)
|
||||
// return VCur.SquareModulus();
|
||||
// Standard_Real Val = VEdg^VCur;
|
||||
// return Val*Val/long1;
|
||||
|
||||
|
||||
// }
|
||||
|
||||
static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
|
||||
@@ -94,7 +95,7 @@ static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_SensitiveTriangulation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_SensitiveTriangulation::
|
||||
@@ -115,11 +116,11 @@ myDetectedTr(-1)
|
||||
|
||||
Standard_Integer fr = 1;
|
||||
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
Standard_Integer nbTriangles (myTriangul->NbTriangles());
|
||||
gp_XYZ cdg(0,0,0);
|
||||
Standard_Integer n[3];
|
||||
|
||||
|
||||
// pour rechercher les connexions dans le cas ou on ne s'occupe de la frontiere...
|
||||
if(!myIntFlag){
|
||||
myFreeEdges = new TColStd_HArray1OfInteger(1,2*S3D_NumberOfFreeEdges(Trg));
|
||||
@@ -148,10 +149,10 @@ myDetectedTr(-1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(nbTriangles!=0) cdg /= nbTriangles;
|
||||
myCDG3D = gp_Pnt(cdg);
|
||||
|
||||
|
||||
ComputeTotalTrsf();
|
||||
|
||||
if(myTrsf.Form()!=gp_Identity)
|
||||
@@ -161,7 +162,7 @@ myDetectedTr(-1)
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_SensitiveTriangulation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Select3D_SensitiveTriangulation::
|
||||
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
|
||||
@@ -182,105 +183,52 @@ myDetectedTr(-1)
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveTriangulation::Project(const Select3D_Projector& aPrj)
|
||||
void Select3D_SensitiveTriangulation::Project(const Handle(Select3D_Projector)& aPrj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aPrj); // to set the field last proj...
|
||||
|
||||
|
||||
mybox2d.SetVoid();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
|
||||
gp_Pnt2d ProjPT;
|
||||
|
||||
|
||||
for(Standard_Integer I=1;I<=myTriangul->NbNodes();I++){
|
||||
if(myTrsf.Form()!=gp_Identity)
|
||||
aPrj.Project(Nodes(I).Transformed(myTrsf),ProjPT);
|
||||
aPrj->Project(Nodes(I).Transformed(myTrsf),ProjPT);
|
||||
else
|
||||
aPrj.Project(Nodes(I),ProjPT);
|
||||
|
||||
aPrj->Project(Nodes(I),ProjPT);
|
||||
|
||||
myNodes2d.SetValue(I,ProjPT);
|
||||
mybox2d.Add(ProjPT);
|
||||
}
|
||||
|
||||
aPrj.Project(myCDG3D,myCDG2D);
|
||||
|
||||
aPrj->Project(myCDG3D,myCDG2D);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Areas
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveTriangulation::Areas(SelectBasics_ListOfBox2d& boxes)
|
||||
void Select3D_SensitiveTriangulation::Areas(SelectBasics_ListOfBox2d& boxes)
|
||||
{
|
||||
boxes.Append(mybox2d);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : getUV
|
||||
//purpose : compute parameters of the picked point on triangle in 2d
|
||||
// Note: parameters of point P on triangle (P1, P2, P3) are defined
|
||||
// as U and V such that P = P1 + U * (P2 - P1) + V * (P3 - P1);
|
||||
// Range: U >= 0, V >= 0, U + V <= 1
|
||||
//=======================================================================
|
||||
|
||||
static gp_XY getUV (const gp_XY& aP2d1, const gp_XY& aP2d2, const gp_XY& aP2d3,
|
||||
const gp_XY& aPick)
|
||||
{
|
||||
gp_XY aDU = aP2d2 - aP2d1;
|
||||
gp_XY aDV = aP2d3 - aP2d1;
|
||||
Standard_Real aDet = aDU ^ aDV;
|
||||
|
||||
// case of non-degenerated triangle
|
||||
gp_XY aDP = aPick - aP2d1;
|
||||
if ( Abs (aDet) > gp::Resolution() )
|
||||
{
|
||||
Standard_Real aU = (aDP ^ aDV) / aDet;
|
||||
Standard_Real aV = -(aDP ^ aDU) / aDet;
|
||||
if ( aU < 0. ) aU = 0.;
|
||||
if ( aV < 0. ) aV = 0.;
|
||||
if ( aU + aV > 1. ) { Standard_Real aD = aU + aV; aU /= aD; aV /= aD; }
|
||||
return gp_XY (aU, aV);
|
||||
}
|
||||
|
||||
// degenerated case (in 2d projection)
|
||||
Standard_Real aL2U = aDU.SquareModulus();
|
||||
Standard_Real aL2V = aDV.SquareModulus();
|
||||
if ( aL2U < gp::Resolution() ) // side 1-2 is degenerated
|
||||
{
|
||||
if ( aL2V < gp::Resolution() ) // whole triangle is degenerated to point
|
||||
return gp_XY (0., 0.);
|
||||
else
|
||||
return gp_XY (0., (aDP * aDV) / aL2V);
|
||||
}
|
||||
else if ( aL2V < gp::Resolution() ) // side 1-3 is degenerated
|
||||
return gp_XY ((aDP * aDU) / aL2U, 0.);
|
||||
else // sides 1-2 and 1-3 are collinear
|
||||
{
|
||||
// select parameter on one of sides so as to have points closer to picked
|
||||
Standard_Real aU = Min (1., Max (0., (aDP * aDU) / aL2U));
|
||||
Standard_Real aV = Min (1., Max (0., (aDP * aDV) / aL2V));
|
||||
gp_XY aP2dU = aP2d1 + aU * aDU;
|
||||
gp_XY aP2dV = aP2d1 + aV * aDV;
|
||||
if ( (aPick - aP2dU).SquareModulus() < (aPick - aP2dV).SquareModulus() )
|
||||
return gp_XY ((aDP * aDU) / aL2U, 0.);
|
||||
else
|
||||
return gp_XY (0., (aDP * aDV) / aL2V);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Matches
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Standard_Real aTol,
|
||||
Standard_Real& DMin)
|
||||
Standard_Real& DMin)
|
||||
{
|
||||
// get view direction (necessary for calculation of depth) from field mylastprj of the base class
|
||||
if ( ! mylastprj )
|
||||
if (mylastprj.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
DMin = Precision::Infinite();
|
||||
@@ -291,12 +239,12 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
// on regarde si on est a l'interieur d'1 triangle 2d.
|
||||
if(myIntFlag)
|
||||
{
|
||||
gp_Lin EyeLine = (*((Select3D_Projector*)mylastprj)).Shoot(X,Y);
|
||||
gp_Lin EyeLine = mylastprj->Shoot(X,Y);
|
||||
if ( myTrsf.Form()!=gp_Identity )
|
||||
EyeLine.Transform (myTrsf.Inverted());
|
||||
|
||||
Standard_Real aMinDepth = Precision::Infinite();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
for (Standard_Integer itr=1; itr<=myTriangul->NbTriangles(); itr++)
|
||||
{
|
||||
Standard_Integer n1,n2,n3;
|
||||
@@ -304,30 +252,32 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
const gp_XY& aPnt2d1 = myNodes2d(n1).XY();
|
||||
const gp_XY& aPnt2d2 = myNodes2d(n2).XY();
|
||||
const gp_XY& aPnt2d3 = myNodes2d(n3).XY();
|
||||
Standard_Real DD = 0.;
|
||||
if (Status (BidPoint, aPnt2d1, aPnt2d2, aPnt2d3, aTol, DD) == 2)
|
||||
gp_XY aUV;
|
||||
Standard_Real aDistSquare = Poly::PointOnTriangle (aPnt2d1, aPnt2d2, aPnt2d3, BidPoint, aUV);
|
||||
if ( aDistSquare > aTol * aTol )
|
||||
continue;
|
||||
|
||||
// compute depth on this triangle
|
||||
gp_XY aUV = getUV (aPnt2d1, aPnt2d2, aPnt2d3, BidPoint);
|
||||
Standard_Real aDepth1 = ElCLib::Parameter (EyeLine, Nodes(n1));
|
||||
Standard_Real aDepth2 = ElCLib::Parameter (EyeLine, Nodes(n2));
|
||||
Standard_Real aDepth3 = ElCLib::Parameter (EyeLine, Nodes(n3));
|
||||
Standard_Real aDepth = aDepth1 + aUV.X() * (aDepth2 - aDepth1) +
|
||||
Standard_Real aDepth = aDepth1 + aUV.X() * (aDepth2 - aDepth1) +
|
||||
aUV.Y() * (aDepth3 - aDepth1);
|
||||
|
||||
// take triangle with lowest depth
|
||||
if ( aDepth < aMinDepth )
|
||||
// take triangle with lowest depth and within defined depth interval
|
||||
if (aDepth < aMinDepth &&
|
||||
aDepth > mylastprj->DepthMin() &&
|
||||
aDepth < mylastprj->DepthMax())
|
||||
{
|
||||
aMinDepth = aDepth;
|
||||
myDetectedTr = itr;
|
||||
DMin = DD;
|
||||
DMin = Sqrt (aDistSquare);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Cas Uniquement Test sur Frontiere de la triangulation...
|
||||
//
|
||||
//
|
||||
else
|
||||
{
|
||||
//Standard_Integer ifirst;
|
||||
@@ -335,7 +285,7 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
Standard_Integer nn = FreeE.Length(), Node1,Node2;
|
||||
//Standard_Real LEdg;
|
||||
//Standard_Real DMinDMin,TolTol = aTol*aTol;
|
||||
|
||||
|
||||
for (Standard_Integer ifri =1; ifri <= nn && myDetectedTr < 0; ifri+=2)
|
||||
{
|
||||
Node1 = FreeE(ifri);
|
||||
@@ -344,43 +294,44 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
myNodes2d(Node2).XY(),
|
||||
BidPoint, aTol, DMin) )
|
||||
{
|
||||
for(Standard_Integer itr=1; itr <= myTriangul->NbTriangles(); itr++)
|
||||
for(Standard_Integer itr=1; itr <= myTriangul->NbTriangles(); itr++)
|
||||
{
|
||||
Standard_Integer n1,n2,n3;
|
||||
triangles(itr).Get(n1,n2,n3);
|
||||
if(S3D_IsEdgeIn(Node1,Node2,n1,n2,n3))
|
||||
triangles(itr).Get(n1,n2,n3);
|
||||
if(S3D_IsEdgeIn(Node1,Node2,n1,n2,n3))
|
||||
{
|
||||
myDetectedTr = itr;
|
||||
myDetectedTr = itr;
|
||||
break; // return first found; selection of closest is not implemented yet
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( myDetectedTr <= 0 )
|
||||
return Standard_False;
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
return Standard_True;
|
||||
|
||||
// compute and validate the depth (::Depth()) along the eyeline
|
||||
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Matches
|
||||
//purpose :
|
||||
//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)
|
||||
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=myNodes2d.Lower();i<=myNodes2d.Upper();i++){
|
||||
if(B.IsOut(myNodes2d(i)))
|
||||
return Standard_False;
|
||||
@@ -391,14 +342,14 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real XM
|
||||
|
||||
//=======================================================================
|
||||
//function : Matches
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::
|
||||
Matches (const TColgp_Array1OfPnt2d& aPoly,
|
||||
const Bnd_Box2d& aBox,
|
||||
const Standard_Real aTol)
|
||||
{
|
||||
{
|
||||
Standard_Real Umin,Vmin,Umax,Vmax;
|
||||
aBox.Get(Umin,Vmin,Umax,Vmax);
|
||||
Standard_Real Tolu,Tolv;
|
||||
@@ -427,7 +378,7 @@ Standard_Integer Select3D_SensitiveTriangulation::Status (const gp_XY& TheP,
|
||||
|
||||
//=======================================================================
|
||||
//function : IsFree
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer IndexOfTriangle,
|
||||
@@ -441,36 +392,36 @@ Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer
|
||||
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;}
|
||||
}
|
||||
|
||||
|
||||
return FoundIndex!=-1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangulation::
|
||||
GetConnected(const TopLoc_Location& aLoc)
|
||||
{
|
||||
|
||||
Handle(Select3D_SensitiveTriangulation) NiouEnt =
|
||||
|
||||
Handle(Select3D_SensitiveTriangulation) NiouEnt =
|
||||
new Select3D_SensitiveTriangulation(myOwnerId,myTriangul,myiniloc,myFreeEdges,myCDG3D,myIntFlag);
|
||||
|
||||
|
||||
if(HasLocation()) NiouEnt->SetLocation(Location());
|
||||
// TopLoc_Location TheLocToApply = HasLocation() ? Location()*aLoc : aLoc;
|
||||
// if(!TheLocToApply.IsIdentity())
|
||||
NiouEnt->UpdateLocation(aLoc);
|
||||
|
||||
|
||||
|
||||
return NiouEnt;
|
||||
}
|
||||
@@ -478,9 +429,9 @@ GetConnected(const TopLoc_Location& aLoc)
|
||||
|
||||
//=======================================================================
|
||||
//function : ResetLocation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveTriangulation::ResetLocation()
|
||||
void Select3D_SensitiveTriangulation::ResetLocation()
|
||||
{
|
||||
Select3D_SensitiveEntity::ResetLocation();
|
||||
ComputeTotalTrsf();
|
||||
@@ -494,9 +445,9 @@ void Select3D_SensitiveTriangulation::SetLocation(const TopLoc_Location& aLoc)
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
|
||||
void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
|
||||
{
|
||||
S<<"\tSensitiveTriangulation 3D :"<<endl;
|
||||
if(myiniloc.IsIdentity())
|
||||
@@ -505,7 +456,7 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
|
||||
S<<"\t\tExisting Initial Location"<<endl;
|
||||
if(HasLocation())
|
||||
S<<"\t\tExisting Location"<<endl;
|
||||
|
||||
|
||||
S<<"\t\tNb Triangles : "<<myTriangul->NbTriangles()<<endl;
|
||||
S<<"\t\tNb Nodes : "<<myTriangul->NbNodes()<<endl;
|
||||
S<<"\t\tNb Free Edges: "<<myFreeEdges->Length()/2<<endl;
|
||||
@@ -518,14 +469,14 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeDepth
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLine) const
|
||||
{
|
||||
if(myDetectedTr==-1) return Precision::Infinite(); // non implemente actuellement...
|
||||
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
|
||||
Standard_Integer n1,n2,n3;
|
||||
triangles(myDetectedTr).Get(n1,n2,n3);
|
||||
gp_Pnt P[3]={Nodes(n1),Nodes(n2),Nodes(n3)};
|
||||
@@ -535,18 +486,18 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
|
||||
P[i].Transform(myTrsf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// formule calcul du parametre du point sur l'intersection
|
||||
// t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir)
|
||||
Standard_Real prof(Precision::Infinite());
|
||||
gp_Pnt Oye = EyeLine.Location(); // origine de la ligne oeil/point vise...
|
||||
gp_Dir Dir = EyeLine.Direction();
|
||||
|
||||
gp_Vec Vtr[3];
|
||||
gp_Vec Vtr[3];
|
||||
for(Standard_Integer i=0;i<=2;i++)
|
||||
Vtr[i] = gp_Vec(P[i%3],P[(i+1)%3]);
|
||||
Vtr[2] = -Vtr[2];
|
||||
|
||||
|
||||
// eliminons tout de suite les cas singuliers...
|
||||
Standard_Integer SingularCase(-1);
|
||||
if(Vtr[0].SquareMagnitude()<= Precision::Confusion())
|
||||
@@ -557,13 +508,13 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
|
||||
if(Vtr[2].SquareMagnitude()<= Precision::Confusion())
|
||||
if( SingularCase < 0 ) SingularCase = 1;
|
||||
#endif
|
||||
|
||||
|
||||
// 3 pts confondus...
|
||||
if(SingularCase ==2){
|
||||
prof= ElCLib::Parameter(EyeLine,P[0]);
|
||||
return prof;
|
||||
}
|
||||
|
||||
|
||||
if(SingularCase!=0)
|
||||
Vtr[0].Normalize();
|
||||
if(SingularCase!=1 &&
|
||||
@@ -571,7 +522,7 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
|
||||
Vtr[2].Normalize();
|
||||
gp_Vec OPo(Oye,P[0]);
|
||||
// 2 points confondus... on recherche l'intersection entre le segment et la ligne oeil/point vise.
|
||||
//
|
||||
//
|
||||
if(SingularCase!=-1){
|
||||
gp_Vec V = SingularCase==0 ? Vtr[2] : Vtr[0];
|
||||
gp_Vec Det = Dir^V;
|
||||
@@ -584,25 +535,25 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
|
||||
prof = VSM.Z()/Det.Z();
|
||||
}
|
||||
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()){
|
||||
prof= ElCLib::Parameter(EyeLine,P[0]);
|
||||
prof = Min (prof, ElCLib::Parameter(EyeLine,P[1]));
|
||||
prof = Min (prof, ElCLib::Parameter(EyeLine,P[2]));
|
||||
}
|
||||
|
||||
|
||||
return prof;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DetectedTriangle
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
|
||||
gp_Pnt& P2,
|
||||
@@ -610,10 +561,10 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
|
||||
{
|
||||
if(myDetectedTr==-1) return Standard_False; // non implemente actuellement...
|
||||
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
Standard_Integer n1,n2,n3;
|
||||
triangles(myDetectedTr).Get(n1,n2,n3);
|
||||
|
||||
|
||||
P1 = Nodes(n1);
|
||||
P2 = Nodes(n2);
|
||||
P3 = Nodes(n3);
|
||||
@@ -622,27 +573,27 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
|
||||
P2.Transform(myTrsf);
|
||||
P3.Transform(myTrsf);
|
||||
}
|
||||
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Function : DetectedTriangle2d
|
||||
// Purpose :
|
||||
// Purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
|
||||
gp_Pnt2d& P1, gp_Pnt2d& P2, gp_Pnt2d& P3) const
|
||||
{
|
||||
if(myDetectedTr==-1)
|
||||
if(myDetectedTr==-1)
|
||||
return Standard_False; // non implemente actuellement...
|
||||
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
Standard_Integer n1,n2,n3;
|
||||
triangles( myDetectedTr ).Get(n1,n2,n3);
|
||||
|
||||
int aLower = myNodes2d.Lower();
|
||||
int anUpper = myNodes2d.Upper();
|
||||
if ( n1 >= aLower && n1 <= anUpper &&
|
||||
if ( n1 >= aLower && n1 <= anUpper &&
|
||||
n2 >= aLower && n2 <= anUpper &&
|
||||
n3 >= aLower && n3 <= anUpper )
|
||||
{
|
||||
@@ -651,15 +602,15 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
|
||||
P3 = myNodes2d.Value( n3 );
|
||||
return Standard_True;
|
||||
}
|
||||
else
|
||||
else
|
||||
return Standard_False;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Select3D_SensitiveTriangulation::ComputeTotalTrsf()
|
||||
void Select3D_SensitiveTriangulation::ComputeTotalTrsf()
|
||||
{
|
||||
Standard_Boolean hasloc = (HasLocation() || !myiniloc.IsIdentity());
|
||||
|
||||
|
||||
if(hasloc){
|
||||
if(myiniloc.IsIdentity())
|
||||
myTrsf = Location().Transformation();
|
||||
|
@@ -43,13 +43,13 @@ void Select3D_SensitiveWire
|
||||
mysensitive.Append(aSensitive);
|
||||
else
|
||||
mysensitive.Append(aSensitive->GetConnected(Location()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLocation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
|
||||
@@ -60,7 +60,7 @@ void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
|
||||
|
||||
if(HasLocation())
|
||||
if(aLoc == Location()) return;
|
||||
|
||||
|
||||
Select3D_SensitiveEntity::SetLocation(aLoc);
|
||||
for(Standard_Integer i=1;i<=mysensitive.Length();i++){
|
||||
if(mysensitive(i)->HasLocation()){
|
||||
@@ -69,12 +69,12 @@ void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
|
||||
}
|
||||
else
|
||||
mysensitive(i)->SetLocation(aLoc);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ResetLocation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveWire::ResetLocation()
|
||||
@@ -85,7 +85,7 @@ void Select3D_SensitiveWire::ResetLocation()
|
||||
mysensitive(i)->SetLocation(mysensitive(i)->Location()*Location().Inverted());
|
||||
else
|
||||
mysensitive(i)->ResetLocation();
|
||||
|
||||
|
||||
}
|
||||
Select3D_SensitiveEntity::ResetLocation();
|
||||
}
|
||||
@@ -94,9 +94,9 @@ void Select3D_SensitiveWire::ResetLocation()
|
||||
// Purpose :
|
||||
//=====================================================
|
||||
void Select3D_SensitiveWire
|
||||
::Project(const Select3D_Projector& aProj)
|
||||
::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);
|
||||
}
|
||||
@@ -113,12 +113,12 @@ void Select3D_SensitiveWire
|
||||
Standard_Integer i;
|
||||
for (i=1; i<=mysensitive.Length(); i++)
|
||||
mysensitive.Value(i)->Areas(BidL);
|
||||
|
||||
|
||||
for(SelectBasics_ListIteratorOfListOfBox2d it(BidL);it.More();it.Next())
|
||||
BB.Add(it.Value());
|
||||
|
||||
|
||||
theareas.Append(BB);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=====================================================
|
||||
@@ -144,9 +144,11 @@ Standard_Boolean Select3D_SensitiveWire
|
||||
}
|
||||
}
|
||||
}
|
||||
// Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
|
||||
return IsTouched;
|
||||
if ( ! IsTouched )
|
||||
return Standard_False;
|
||||
|
||||
// compute and validate the depth (::Depth()) along the eyeline
|
||||
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
}
|
||||
|
||||
//=====================================================
|
||||
@@ -162,7 +164,7 @@ Matches (const Standard_Real XMin,
|
||||
{
|
||||
Standard_Integer i;
|
||||
for (i=1; i<=mysensitive.Length(); i++) {
|
||||
if (!(mysensitive.Value(i)->Matches(XMin,YMin,XMax,YMax,aTol)))
|
||||
if (!(mysensitive.Value(i)->Matches(XMin,YMin,XMax,YMax,aTol)))
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
@@ -170,17 +172,17 @@ Matches (const Standard_Real XMin,
|
||||
|
||||
//=======================================================================
|
||||
//function : Matches
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveWire::
|
||||
Matches (const TColgp_Array1OfPnt2d& aPoly,
|
||||
const Bnd_Box2d& aBox,
|
||||
const Standard_Real aTol)
|
||||
{
|
||||
{
|
||||
Standard_Integer i;
|
||||
for (i=1; i<=mysensitive.Length(); i++) {
|
||||
if (!(mysensitive.Value(i)->Matches(aPoly, aBox, aTol)))
|
||||
if (!(mysensitive.Value(i)->Matches(aPoly, aBox, aTol)))
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
@@ -199,14 +201,14 @@ MaxBoxes () const
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetConnected(const TopLoc_Location& aLoc)
|
||||
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));
|
||||
|
||||
|
||||
if(HasLocation())
|
||||
SWIR->SetLocation(Location()*aLoc);
|
||||
else
|
||||
@@ -217,7 +219,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetConnected(const TopL
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
|
||||
@@ -237,23 +239,23 @@ void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean Ful
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeDepth
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveWire::ComputeDepth(const gp_Lin& EyeLine) const
|
||||
Standard_Real Select3D_SensitiveWire::ComputeDepth(const gp_Lin& EyeLine) const
|
||||
{
|
||||
|
||||
|
||||
if(myDetectedIndex==-1)
|
||||
// should be never called...
|
||||
return Precision::Infinite();
|
||||
return mysensitive(myDetectedIndex)->ComputeDepth(EyeLine);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLastPrj
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveWire::SetLastPrj(const Select3D_Projector& Prj)
|
||||
void Select3D_SensitiveWire::SetLastPrj(const Handle(Select3D_Projector)& Prj)
|
||||
{
|
||||
Select3D_SensitiveEntity::SetLastPrj(Prj);
|
||||
for(Standard_Integer i=1;i<=mysensitive.Length();i++)
|
||||
@@ -263,7 +265,7 @@ void Select3D_SensitiveWire::SetLastPrj(const Select3D_Projector& Prj)
|
||||
|
||||
//=======================================================================
|
||||
//function : GetEdges
|
||||
//purpose : returns the sensitive edges stored in this wire
|
||||
//purpose : returns the sensitive edges stored in this wire
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveWire::GetEdges( Select3D_SensitiveEntitySequence& theEdges )
|
||||
{
|
||||
@@ -273,7 +275,7 @@ void Select3D_SensitiveWire::GetEdges( Select3D_SensitiveEntitySequence& theEdge
|
||||
|
||||
//=============================================================================
|
||||
// Function : GetLastDetected
|
||||
// Purpose :
|
||||
// Purpose :
|
||||
//=============================================================================
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetLastDetected() const
|
||||
{
|
||||
|
Reference in New Issue
Block a user