0024070: OpenGL capped object-level clipping planes
[occt.git] / src / Select3D / Select3D_Projector.lxx
CommitLineData
b311480e 1// Created on: 1992-07-09
2// Created by: Christophe MARION
3// Copyright (c) 1992-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#include <Standard_NoSuchObject.hxx>
23#include <gp_Vec.hxx>
24#include <gp_Pnt.hxx>
25#include <gp_Lin.hxx>
26#include <V3d_View.hxx>
27#include <V3d.hxx>
28
29//=======================================================================
7fd59977 30//function : Perspective
4952a30a 31//purpose :
7fd59977 32//=======================================================================
33
34inline Standard_Boolean Select3D_Projector::Perspective() const
35{ return myPersp; }
36
37//=======================================================================
38//function : Transformation
4952a30a 39//purpose :
7fd59977 40//=======================================================================
41
42inline const gp_GTrsf& Select3D_Projector::Transformation() const
43{ return myGTrsf; }
44
45//=======================================================================
46//function : InvertedTransformation
4952a30a 47//purpose :
7fd59977 48//=======================================================================
49
50inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
51{ return myInvTrsf; }
52
53//=======================================================================
54//function : FullTransformation
4952a30a 55//purpose :
7fd59977 56//=======================================================================
57
58inline const gp_Trsf& Select3D_Projector::FullTransformation() const
59{ return myScaledTrsf; }
60
61//=======================================================================
62//function : Focus
4952a30a 63//purpose :
7fd59977 64//=======================================================================
65
66inline Standard_Real Select3D_Projector::Focus() const
67{
68 Standard_NoSuchObject_Raise_if(!myPersp,
69 "Select3D_Projector::Not a Perpective");
70 return myFocus;
71}
72
73//=======================================================================
74//function : Transform
4952a30a 75//purpose :
7fd59977 76//=======================================================================
77
78inline void Select3D_Projector::Transform (gp_Vec& D) const
79{
80 gp_XYZ coord = D.XYZ();
81 if (myGTrsf.Form() == gp_Identity || myGTrsf.Form() == gp_Translation) { }
82 else if (myGTrsf.Form() == gp_PntMirror) { coord.Reverse(); }
83 else { coord.Multiply (myGTrsf.VectorialPart()); }
84 D.SetXYZ(coord);
85}
86
87//=======================================================================
88//function : Transform
4952a30a 89//purpose :
7fd59977 90//=======================================================================
91
92inline void Select3D_Projector::Transform (gp_Pnt& Pnt) const
4952a30a 93{
7fd59977 94 gp_XYZ xyz = Pnt.XYZ();
95 myGTrsf.Transforms(xyz);
96 Pnt = gp_Pnt(xyz);
97}
98
99
100inline const Handle(V3d_View)& Select3D_Projector::View() const
101{return myView;}
102
103inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const
4952a30a 104{
7fd59977 105 gp_Ax1 ax1 = Lin.Position();
106 gp_XYZ xyz = ax1.Location().XYZ();
107 T.Transforms(xyz);
108 ax1.SetLocation(gp_Pnt(xyz));
109 gp_Dir dir = ax1.Direction();
110 gp_XYZ coord = dir.XYZ();
111 if (T.Form() == gp_Identity || T.Form() == gp_Translation) { }
112 else if (T.Form() == gp_PntMirror) { coord.Reverse(); }
113 else {
114 coord.Multiply (T.VectorialPart());
115 Standard_Real D = coord.Modulus();
116 coord.Divide(D);
117 }
118 dir.SetXYZ(coord);
119 ax1.SetDirection(dir);
120 Lin.SetPosition(ax1);
121}
122
123inline void Select3D_Projector::Transform (gp_Pnt& Pnt, const gp_GTrsf& T) const
4952a30a 124{
7fd59977 125 gp_XYZ xyz = Pnt.XYZ();
126 T.Transforms(xyz);
127 Pnt = gp_Pnt(xyz);
128}