| 1 | // File: Select3D_Projector.lxx |
| 2 | // Created: Thu Jul 9 12:50:25 1992 |
| 3 | // Author: Christophe MARION |
| 4 | // <cma@sdsun1> |
| 5 | |
| 6 | #include <Standard_NoSuchObject.hxx> |
| 7 | #include <gp_Vec.hxx> |
| 8 | #include <gp_Pnt.hxx> |
| 9 | #include <gp_Lin.hxx> |
| 10 | #include <V3d_View.hxx> |
| 11 | #include <V3d.hxx> |
| 12 | |
| 13 | //======================================================================= |
| 14 | //function : Perspective |
| 15 | //purpose : |
| 16 | //======================================================================= |
| 17 | |
| 18 | inline Standard_Boolean Select3D_Projector::Perspective() const |
| 19 | { return myPersp; } |
| 20 | |
| 21 | //======================================================================= |
| 22 | //function : Transformation |
| 23 | //purpose : |
| 24 | //======================================================================= |
| 25 | |
| 26 | inline const gp_GTrsf& Select3D_Projector::Transformation() const |
| 27 | { return myGTrsf; } |
| 28 | |
| 29 | //======================================================================= |
| 30 | //function : InvertedTransformation |
| 31 | //purpose : |
| 32 | //======================================================================= |
| 33 | |
| 34 | inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const |
| 35 | { return myInvTrsf; } |
| 36 | |
| 37 | //======================================================================= |
| 38 | //function : FullTransformation |
| 39 | //purpose : |
| 40 | //======================================================================= |
| 41 | |
| 42 | inline const gp_Trsf& Select3D_Projector::FullTransformation() const |
| 43 | { return myScaledTrsf; } |
| 44 | |
| 45 | //======================================================================= |
| 46 | //function : Focus |
| 47 | //purpose : |
| 48 | //======================================================================= |
| 49 | |
| 50 | inline Standard_Real Select3D_Projector::Focus() const |
| 51 | { |
| 52 | Standard_NoSuchObject_Raise_if(!myPersp, |
| 53 | "Select3D_Projector::Not a Perpective"); |
| 54 | return myFocus; |
| 55 | } |
| 56 | |
| 57 | //======================================================================= |
| 58 | //function : Transform |
| 59 | //purpose : |
| 60 | //======================================================================= |
| 61 | |
| 62 | inline void Select3D_Projector::Transform (gp_Vec& D) const |
| 63 | { |
| 64 | gp_XYZ coord = D.XYZ(); |
| 65 | if (myGTrsf.Form() == gp_Identity || myGTrsf.Form() == gp_Translation) { } |
| 66 | else if (myGTrsf.Form() == gp_PntMirror) { coord.Reverse(); } |
| 67 | else { coord.Multiply (myGTrsf.VectorialPart()); } |
| 68 | D.SetXYZ(coord); |
| 69 | } |
| 70 | |
| 71 | //======================================================================= |
| 72 | //function : Transform |
| 73 | //purpose : |
| 74 | //======================================================================= |
| 75 | |
| 76 | inline void Select3D_Projector::Transform (gp_Pnt& Pnt) const |
| 77 | { |
| 78 | gp_XYZ xyz = Pnt.XYZ(); |
| 79 | myGTrsf.Transforms(xyz); |
| 80 | Pnt = gp_Pnt(xyz); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | inline const Handle(V3d_View)& Select3D_Projector::View() const |
| 85 | {return myView;} |
| 86 | |
| 87 | inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const |
| 88 | { |
| 89 | gp_Ax1 ax1 = Lin.Position(); |
| 90 | gp_XYZ xyz = ax1.Location().XYZ(); |
| 91 | T.Transforms(xyz); |
| 92 | ax1.SetLocation(gp_Pnt(xyz)); |
| 93 | gp_Dir dir = ax1.Direction(); |
| 94 | gp_XYZ coord = dir.XYZ(); |
| 95 | if (T.Form() == gp_Identity || T.Form() == gp_Translation) { } |
| 96 | else if (T.Form() == gp_PntMirror) { coord.Reverse(); } |
| 97 | else { |
| 98 | coord.Multiply (T.VectorialPart()); |
| 99 | Standard_Real D = coord.Modulus(); |
| 100 | coord.Divide(D); |
| 101 | } |
| 102 | dir.SetXYZ(coord); |
| 103 | ax1.SetDirection(dir); |
| 104 | Lin.SetPosition(ax1); |
| 105 | } |
| 106 | |
| 107 | inline void Select3D_Projector::Transform (gp_Pnt& Pnt, const gp_GTrsf& T) const |
| 108 | { |
| 109 | gp_XYZ xyz = Pnt.XYZ(); |
| 110 | T.Transforms(xyz); |
| 111 | Pnt = gp_Pnt(xyz); |
| 112 | } |
| 113 | |
| 114 | inline Standard_Real Select3D_Projector::DepthMin() const |
| 115 | { |
| 116 | return myDepthMin; |
| 117 | } |
| 118 | |
| 119 | inline Standard_Real Select3D_Projector::DepthMax() const |
| 120 | { |
| 121 | return myDepthMax; |
| 122 | } |