1 -- Created on: 1992-03-12
2 -- Created by: Christophe MARION
3 -- Copyright (c) 1992-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 -- <cma@sdsun2> copie quasi exacte de HLRAlgo_Projector
19 class Projector from Select3D inherits Transient from Standard
20 ---Purpose: A framework to define 3D projectors.
21 -- Projector provides services for projecting points from
22 -- world-coordinates to a viewing plane. Projection could be defined by
23 -- corresponding transformation, or coordinate system. The transformation
24 -- could be constructed for a view with transposed view transformation
25 -- matrix ( that represents view-orientation ), including, for perspective
26 -- view, focal distance ( distance from an eye to the view plane ) and
27 -- translational part that represents translation of focal point in
28 -- view-coordinate space. The Select3D_Projector class recognizes the
29 -- predefined set of popular projections: axonometric, top view, front
30 -- view and uses more efficient algorithm for projection computations.
31 -- User-defined transformation could be also defined in constructor.
32 -- Perspective projection consists of two separate parts, that are
33 -- composed together during computation: transformation component and
38 Boolean from Standard,
51 NoSuchObject from Standard
55 Create(aView:View from V3d) returns Projector from Select3D;
56 --- Purpose: Constructs the 3D projector object defined by the 3D view aView.
57 Create returns Projector from Select3D;
59 Create(CS : Ax2 from gp)
60 ---Purpose: Creates an axonometric projector. <CS> represents viewing coordinate
61 -- system and could be constructed from x direction, view plane normal direction,
62 -- and view point location in world-coordinate space.
63 returns Projector from Select3D;
65 Create(CS : Ax2 from gp;
66 Focus : Real from Standard)
67 ---Purpose: Creates a perspective projector. <CS> represents viewing
68 -- coordinate system and could be constructed from x direction,
69 -- view plane normal direction, and focal point location in world-coordinate
70 -- space. <Focus> should represent distance of an eye from view plane
71 -- in world-coordinate space (focal distance).
72 returns Projector from Select3D;
74 Create(T : Trsf from gp;
75 Persp : Boolean from Standard;
76 Focus : Real from Standard)
77 ---Purpose: build a Projector from the given transformation.
78 -- In case, when <T> transformation should represent custom view projection,
79 -- it could be constructed from two separate components: transposed view
80 -- orientation matrix and translation of focal point in view-coordiante
81 -- system. <T> could be built up from x direction, up direction,
82 -- view plane normal direction vectors and translation with SetValues(...)
83 -- method, where first row arguments (a11, a12, a13, a14) are x, y, z
84 -- component of x direction vector, and x value of reversed translation
85 -- vector. Second row arguments, are x y z for up direction and y value of
86 -- reversed translation, and the third row defined in the same manner.
87 -- This also suits for simple perspective view, where <Focus> is the focale
88 -- distance of an eye from view plane in world-space coordiantes.
89 -- Note, that in that case amount of perspective distortion (perspective
90 -- angle) should be defined through focal distance.
91 returns Projector from Select3D;
93 Create(GT : GTrsf from gp;
94 Persp : Boolean from Standard;
95 Focus : Real from Standard)
96 ---Purpose: build a Projector from the given transformation.
97 -- In case, when <GT> transformation should represent custom view
98 -- projection, it could be constructed from two separate components:
99 -- transposed view orientation matrix and translation of a focal point
100 -- in view-coordinate system.
101 -- This also suits for perspective view, with <Focus> that could be
102 -- equal to distance from an eye to a view plane in
103 -- world-coordinates (focal distance).
104 -- The 3x3 transformation matrix is built up from three vectors:
105 -- x direction, up direction and view plane normal vectors, where each
106 -- vector is a matrix row. Then <GT> is constructed from matrix and
107 -- reversed translation with methods SetTranslationPart(..) and
108 -- SetVectorialPart(..).
109 -- Note, that in that case amount of perspective distortion (perspective
110 -- angle) should be defined through focal distance.
111 returns Projector from Select3D;
115 Persp : Boolean from Standard;
116 Focus : Real from Standard)
119 SetView(me : mutable; V : View from V3d);
120 ---Purpose: Sets the 3D view V used at the time of construction.
122 View(me) returns any View from V3d;
123 ---Purpose: Returns the 3D view used at the time of construction.
124 ---C++: return const&
127 Scaled(me : mutable; On : Boolean from Standard = Standard_False)
128 ---Purpose: to compute with the given scale and translation.
131 Perspective(me) returns Boolean
132 ---Purpose: Returns True if there is a perspective transformation.
136 Transformation(me) returns GTrsf from gp
137 ---Purpose: Returns the active transformation.
139 ---C++: return const &
142 InvertedTransformation(me) returns GTrsf from gp
143 ---Purpose: Returns the active inverted transformation.
145 ---C++: return const &
148 FullTransformation(me) returns Trsf from gp
149 ---Purpose: Returns the original transformation.
151 ---C++: return const &
154 Focus(me) returns Real from Standard
155 ---Purpose: Returns the focal length.
158 NoSuchObject from Standard -- if there is no perspective
161 Transform(me; D : in out Vec from gp)
165 Transform(me; Pnt : in out Pnt from gp)
169 Project(me; P : Pnt from gp;
170 Pout : out Pnt2d from gp)
171 ---Purpose: Transform and apply perspective if needed.
174 Project(me; P : Pnt from gp;
175 X,Y,Z : out Real from Standard)
176 ---Purpose: Transform and apply perspective if needed.
179 Project(me; P : Pnt from gp;
181 Pout : out Pnt2d from gp;
182 D1out : out Vec2d from gp)
183 ---Purpose: Transform and apply perspective if needed.
186 Shoot(me; X , Y : Real from Standard)
188 ---Purpose: return a line going through the eye towards the
192 Transform(me; P : in out Pnt from gp;
197 Transform(me; D : in out Lin from gp;
203 myType : Integer from Standard;
205 myPersp : Boolean from Standard is protected;
206 myFocus : Real from Standard is protected;
207 myScaledTrsf : Trsf from gp is protected;
208 myGTrsf : GTrsf from gp is protected;
209 myInvTrsf : GTrsf from gp is protected;
211 myView : View from V3d;