mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-05-16 10:54:53 +03:00
0022683: Incorrect result of Select3D_Projector::Project() in the case of perspective projection
This commit is contained in:
parent
2166f0fad8
commit
b0f0bd0c2f
@ -6,6 +6,21 @@
|
|||||||
|
|
||||||
class Projector from Select3D inherits Transient from Standard
|
class Projector from Select3D inherits Transient from Standard
|
||||||
---Purpose: A framework to define 3D projectors.
|
---Purpose: A framework to define 3D projectors.
|
||||||
|
-- Projector provides services for projecting points from
|
||||||
|
-- world-coordinates to a viewing plane. Projection could be defined by
|
||||||
|
-- corresponding transformation, or coordinate system. The transformation
|
||||||
|
-- could be constructed for a view with transposed view transformation
|
||||||
|
-- matrix ( that represents view-orientation ), including, for perspective
|
||||||
|
-- view, focal distance ( distance from an eye to the view plane ) and
|
||||||
|
-- translational part that represents translation of focal point in
|
||||||
|
-- view-coordinate space. The Select3D_Projector class recognizes the
|
||||||
|
-- predefined set of popular projections: axonometric, top view, front
|
||||||
|
-- view and uses more efficient algorithm for projection computations.
|
||||||
|
-- User-defined transformation could be also defined in constructor.
|
||||||
|
-- Perspective projection consists of two separate parts, that are
|
||||||
|
-- composed together during computation: transformation component and
|
||||||
|
-- focale distance.
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Real from Standard,
|
Real from Standard,
|
||||||
Boolean from Standard,
|
Boolean from Standard,
|
||||||
@ -30,33 +45,57 @@ is
|
|||||||
Create returns Projector from Select3D;
|
Create returns Projector from Select3D;
|
||||||
|
|
||||||
Create(CS : Ax2 from gp)
|
Create(CS : Ax2 from gp)
|
||||||
---Purpose: Creates an axonometric projector. <CS> is the
|
---Purpose: Creates an axonometric projector. <CS> represents viewing coordinate
|
||||||
-- viewing coordinate system.
|
-- system and could be constructed from x direction, view plane normal direction,
|
||||||
|
-- and view point location in world-coordinate space.
|
||||||
returns Projector from Select3D;
|
returns Projector from Select3D;
|
||||||
|
|
||||||
Create(CS : Ax2 from gp;
|
Create(CS : Ax2 from gp;
|
||||||
Focus : Real from Standard)
|
Focus : Real from Standard)
|
||||||
---Purpose: Creates a perspective projector. <CS> is the
|
---Purpose: Creates a perspective projector. <CS> represents viewing
|
||||||
-- viewing coordinate system.
|
-- coordinate system and could be constructed from x direction,
|
||||||
|
-- view plane normal direction, and focal point location in world-coordinate
|
||||||
|
-- space. <Focus> should represent distance of an eye from view plane
|
||||||
|
-- in world-coordinate space (focal distance).
|
||||||
returns Projector from Select3D;
|
returns Projector from Select3D;
|
||||||
|
|
||||||
Create(T : Trsf from gp;
|
Create(T : Trsf from gp;
|
||||||
Persp : Boolean from Standard;
|
Persp : Boolean from Standard;
|
||||||
Focus : Real from Standard)
|
Focus : Real from Standard)
|
||||||
---Purpose: build a Projector with automatic minmax directions.
|
---Purpose: build a Projector from the given transformation.
|
||||||
returns Projector from Select3D;
|
-- In case, when <T> transformation should represent custom view projection,
|
||||||
|
-- it could be constructed from two separate components: transposed view
|
||||||
Create(T : Trsf from gp;
|
-- orientation matrix and translation of focal point in view-coordiante
|
||||||
Persp : Boolean from Standard;
|
-- system. <T> could be built up from x direction, up direction,
|
||||||
Focus : Real from Standard;
|
-- view plane normal direction vectors and translation with SetValues(...)
|
||||||
v1,v2,v3 : Vec2d from gp)
|
-- method, where first row arguments (a11, a12, a13, a14) are x, y, z
|
||||||
---Purpose: build a Projector with given minmax directions.
|
-- component of x direction vector, and x value of reversed translation
|
||||||
|
-- vector. Second row arguments, are x y z for up direction and y value of
|
||||||
|
-- reversed translation, and the third row defined in the same manner.
|
||||||
|
-- This also suits for simple perspective view, where <Focus> is the focale
|
||||||
|
-- distance of an eye from view plane in world-space coordiantes.
|
||||||
|
-- Note, that in that case amount of perspective distortion (perspective
|
||||||
|
-- angle) should be defined through focal distance.
|
||||||
returns Projector from Select3D;
|
returns Projector from Select3D;
|
||||||
|
|
||||||
Create(GT : GTrsf from gp;
|
Create(GT : GTrsf from gp;
|
||||||
Persp : Boolean from Standard;
|
Persp : Boolean from Standard;
|
||||||
Focus : Real from Standard)
|
Focus : Real from Standard)
|
||||||
---Purpose: build a Projector with automatic minmax directions.
|
---Purpose: build a Projector from the given transformation.
|
||||||
|
-- In case, when <GT> transformation should represent custom view
|
||||||
|
-- projection, it could be constructed from two separate components:
|
||||||
|
-- transposed view orientation matrix and translation of a focal point
|
||||||
|
-- in view-coordinate system.
|
||||||
|
-- This also suits for perspective view, with <Focus> that could be
|
||||||
|
-- equal to distance from an eye to a view plane in
|
||||||
|
-- world-coordinates (focal distance).
|
||||||
|
-- The 3x3 transformation matrix is built up from three vectors:
|
||||||
|
-- x direction, up direction and view plane normal vectors, where each
|
||||||
|
-- vector is a matrix row. Then <GT> is constructed from matrix and
|
||||||
|
-- reversed translation with methods SetTranslationPart(..) and
|
||||||
|
-- SetVectorialPart(..).
|
||||||
|
-- Note, that in that case amount of perspective distortion (perspective
|
||||||
|
-- angle) should be defined through focal distance.
|
||||||
returns Projector from Select3D;
|
returns Projector from Select3D;
|
||||||
|
|
||||||
Set (me : mutable;
|
Set (me : mutable;
|
||||||
@ -65,7 +104,6 @@ is
|
|||||||
Focus : Real from Standard)
|
Focus : Real from Standard)
|
||||||
is static;
|
is static;
|
||||||
|
|
||||||
|
|
||||||
SetView(me : mutable; V : View from V3d);
|
SetView(me : mutable; V : View from V3d);
|
||||||
---Purpose: Sets the 3D view V used at the time of construction.
|
---Purpose: Sets the 3D view V used at the time of construction.
|
||||||
|
|
||||||
@ -74,11 +112,6 @@ is
|
|||||||
---C++: return const&
|
---C++: return const&
|
||||||
---C++: inline
|
---C++: inline
|
||||||
|
|
||||||
|
|
||||||
Directions(me; D1 , D2 , D3 : out Vec2d from gp)
|
|
||||||
---C++: inline
|
|
||||||
is virtual;
|
|
||||||
|
|
||||||
Scaled(me : mutable; On : Boolean from Standard = Standard_False)
|
Scaled(me : mutable; On : Boolean from Standard = Standard_False)
|
||||||
---Purpose: to compute with the given scale and translation.
|
---Purpose: to compute with the given scale and translation.
|
||||||
is virtual;
|
is virtual;
|
||||||
@ -138,11 +171,6 @@ is
|
|||||||
---Purpose: Transform and apply perspective if needed.
|
---Purpose: Transform and apply perspective if needed.
|
||||||
is virtual;
|
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>.
|
|
||||||
is virtual;
|
|
||||||
|
|
||||||
Shoot(me; X , Y : Real from Standard)
|
Shoot(me; X , Y : Real from Standard)
|
||||||
returns Lin from gp
|
returns Lin from gp
|
||||||
---Purpose: return a line going through the eye towards the
|
---Purpose: return a line going through the eye towards the
|
||||||
@ -166,9 +194,6 @@ is
|
|||||||
--- projection functionality itself).
|
--- projection functionality itself).
|
||||||
--- Should be used when call ::Shoot() to compute eyeline.
|
--- Should be used when call ::Shoot() to compute eyeline.
|
||||||
|
|
||||||
SetDirection(me : mutable)
|
|
||||||
is static private;
|
|
||||||
|
|
||||||
Transform(me; P : in out Pnt from gp;
|
Transform(me; P : in out Pnt from gp;
|
||||||
T : GTrsf from gp)
|
T : GTrsf from gp)
|
||||||
---C++: inline
|
---C++: inline
|
||||||
@ -187,9 +212,6 @@ fields
|
|||||||
myScaledTrsf : Trsf from gp is protected;
|
myScaledTrsf : Trsf from gp is protected;
|
||||||
myGTrsf : GTrsf from gp is protected;
|
myGTrsf : GTrsf from gp is protected;
|
||||||
myInvTrsf : GTrsf from gp is protected;
|
myInvTrsf : GTrsf from gp is protected;
|
||||||
myD1 : Vec2d from gp is protected;
|
|
||||||
myD2 : Vec2d from gp is protected;
|
|
||||||
myD3 : Vec2d from gp is protected;
|
|
||||||
|
|
||||||
myView : View from V3d;
|
myView : View from V3d;
|
||||||
myDepthMin : Real from Standard;
|
myDepthMin : Real from Standard;
|
||||||
|
@ -28,9 +28,6 @@
|
|||||||
Select3D_Projector::Select3D_Projector(const Handle(V3d_View)& aViou)
|
Select3D_Projector::Select3D_Projector(const Handle(V3d_View)& aViou)
|
||||||
: myPersp(aViou->Type()==V3d_PERSPECTIVE),
|
: myPersp(aViou->Type()==V3d_PERSPECTIVE),
|
||||||
myFocus(aViou->Focale()),
|
myFocus(aViou->Focale()),
|
||||||
myD1(1,0),
|
|
||||||
myD2(0,1),
|
|
||||||
myD3(1,1),
|
|
||||||
myView(aViou),
|
myView(aViou),
|
||||||
myDepthMin(-Precision::Infinite()),
|
myDepthMin(-Precision::Infinite()),
|
||||||
myDepthMax( Precision::Infinite())
|
myDepthMax( Precision::Infinite())
|
||||||
@ -60,14 +57,10 @@ Select3D_Projector::Select3D_Projector(const Handle(V3d_View)& aViou)
|
|||||||
Select3D_Projector::Select3D_Projector()
|
Select3D_Projector::Select3D_Projector()
|
||||||
: myPersp(Standard_False),
|
: myPersp(Standard_False),
|
||||||
myFocus(0),
|
myFocus(0),
|
||||||
myD1(1,0),
|
|
||||||
myD2(0,1),
|
|
||||||
myD3(1,1),
|
|
||||||
myDepthMin(-Precision::Infinite()),
|
myDepthMin(-Precision::Infinite()),
|
||||||
myDepthMax( Precision::Infinite())
|
myDepthMax( Precision::Infinite())
|
||||||
{
|
{
|
||||||
Scaled();
|
Scaled();
|
||||||
SetDirection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -84,7 +77,6 @@ Select3D_Projector::Select3D_Projector (const gp_Ax2& CS)
|
|||||||
myScaledTrsf.SetTransformation(CS);
|
myScaledTrsf.SetTransformation(CS);
|
||||||
myGTrsf.SetTrsf(myScaledTrsf);
|
myGTrsf.SetTrsf(myScaledTrsf);
|
||||||
Scaled();
|
Scaled();
|
||||||
SetDirection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -102,7 +94,6 @@ Select3D_Projector::Select3D_Projector (const gp_Ax2& CS,
|
|||||||
myScaledTrsf.SetTransformation(CS);
|
myScaledTrsf.SetTransformation(CS);
|
||||||
myGTrsf.SetTrsf(myScaledTrsf);
|
myGTrsf.SetTrsf(myScaledTrsf);
|
||||||
Scaled();
|
Scaled();
|
||||||
SetDirection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -118,31 +109,6 @@ Select3D_Projector::Select3D_Projector (const gp_Trsf& T,
|
|||||||
myScaledTrsf(T),
|
myScaledTrsf(T),
|
||||||
myDepthMin(-Precision::Infinite()),
|
myDepthMin(-Precision::Infinite()),
|
||||||
myDepthMax( Precision::Infinite())
|
myDepthMax( Precision::Infinite())
|
||||||
{
|
|
||||||
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,
|
|
||||||
const gp_Vec2d& v1,
|
|
||||||
const gp_Vec2d& v2,
|
|
||||||
const gp_Vec2d& v3)
|
|
||||||
: myPersp(Persp),
|
|
||||||
myFocus(Focus),
|
|
||||||
myScaledTrsf(T),
|
|
||||||
myD1(v1),
|
|
||||||
myD2(v2),
|
|
||||||
myD3(v3),
|
|
||||||
myDepthMin(-Precision::Infinite()),
|
|
||||||
myDepthMax( Precision::Infinite())
|
|
||||||
{
|
{
|
||||||
myGTrsf.SetTrsf(myScaledTrsf);
|
myGTrsf.SetTrsf(myScaledTrsf);
|
||||||
Scaled();
|
Scaled();
|
||||||
@ -163,7 +129,6 @@ Select3D_Projector::Select3D_Projector (const gp_GTrsf& GT,
|
|||||||
myDepthMax( Precision::Infinite())
|
myDepthMax( Precision::Infinite())
|
||||||
{
|
{
|
||||||
Scaled();
|
Scaled();
|
||||||
SetDirection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -180,7 +145,6 @@ void Select3D_Projector::Set
|
|||||||
myFocus = Focus;
|
myFocus = Focus;
|
||||||
myScaledTrsf = T;
|
myScaledTrsf = T;
|
||||||
Scaled();
|
Scaled();
|
||||||
SetDirection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -438,19 +402,6 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : BoxAdd
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
void Select3D_Projector::BoxAdd
|
|
||||||
(const gp_Pnt2d& P,
|
|
||||||
Bnd_Box& B) const
|
|
||||||
{
|
|
||||||
gp_Vec2d V(P.X(),P.Y());
|
|
||||||
gp_Pnt PP(myD1 * V, myD2 * V, myD3 * V);
|
|
||||||
B.Add(PP);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Shoot
|
//function : Shoot
|
||||||
@ -476,30 +427,6 @@ gp_Lin Select3D_Projector::Shoot
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetDirection
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
void Select3D_Projector::SetDirection ()
|
|
||||||
{
|
|
||||||
gp_Vec V1(1,0,0);
|
|
||||||
Transform(V1);
|
|
||||||
if ((Abs(V1.X()) + Abs(V1.Y())) < Precision::Angular()) V1.SetCoord(1,1,0);
|
|
||||||
gp_Vec2d D1(V1.X(),V1.Y());
|
|
||||||
myD1.SetCoord(-D1.Y(),D1.X());
|
|
||||||
gp_Vec V2(0,1,0);
|
|
||||||
Transform(V2);
|
|
||||||
if ((Abs(V2.X()) + Abs(V2.Y())) < Precision::Angular()) V2.SetCoord(1,1,0);
|
|
||||||
gp_Vec2d D2(V2.X(),V2.Y());
|
|
||||||
myD2.SetCoord(-D2.Y(),D2.X());
|
|
||||||
gp_Vec V3(0,0,1);
|
|
||||||
Transform(V3);
|
|
||||||
if ((Abs(V3.X()) + Abs(V3.Y())) < Precision::Angular()) V3.SetCoord(1,1,0);
|
|
||||||
gp_Vec2d D3(V3.X(),V3.Y());
|
|
||||||
myD3.SetCoord(-D3.Y(),D3.X());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Select3D_Projector::SetView(const Handle(V3d_View)& aViou)
|
void Select3D_Projector::SetView(const Handle(V3d_View)& aViou)
|
||||||
{
|
{
|
||||||
myView = aViou;
|
myView = aViou;
|
||||||
|
@ -10,19 +10,6 @@
|
|||||||
#include <V3d_View.hxx>
|
#include <V3d_View.hxx>
|
||||||
#include <V3d.hxx>
|
#include <V3d.hxx>
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Directions
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
inline void Select3D_Projector::Directions
|
|
||||||
(gp_Vec2d& D1, gp_Vec2d& D2, gp_Vec2d& D3) const
|
|
||||||
{
|
|
||||||
D1 = myD1;
|
|
||||||
D2 = myD2;
|
|
||||||
D3 = myD3;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Perspective
|
//function : Perspective
|
||||||
//purpose :
|
//purpose :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user