|
||||
File indexing completed on 2025-01-18 10:03:37
0001 // Created on: 1993-03-10 0002 // Created by: JCV 0003 // Copyright (c) 1993-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Geom_Transformation_HeaderFile 0018 #define _Geom_Transformation_HeaderFile 0019 0020 #include <gp_Trsf.hxx> 0021 #include <Standard.hxx> 0022 #include <Standard_Integer.hxx> 0023 #include <Standard_Real.hxx> 0024 #include <Standard_Type.hxx> 0025 #include <Standard_Transient.hxx> 0026 0027 DEFINE_STANDARD_HANDLE(Geom_Transformation, Standard_Transient) 0028 0029 //! Describes how to construct the following elementary transformations 0030 //! - translations, 0031 //! - rotations, 0032 //! - symmetries, 0033 //! - scales. 0034 //! The Transformation class can also be used to 0035 //! construct complex transformations by combining these 0036 //! elementary transformations. 0037 //! However, these transformations can never change 0038 //! the type of an object. For example, the projection 0039 //! transformation can change a circle into an ellipse, and 0040 //! therefore change the real type of the object. Such a 0041 //! transformation is forbidden in this environment and 0042 //! cannot be a Geom_Transformation. 0043 //! The transformation can be represented as follow : 0044 //! 0045 //! V1 V2 V3 T 0046 //! | a11 a12 a13 a14 | | x | | x'| 0047 //! | a21 a22 a23 a24 | | y | | y'| 0048 //! | a31 a32 a33 a34 | | z | = | z'| 0049 //! | 0 0 0 1 | | 1 | | 1 | 0050 //! 0051 //! where {V1, V2, V3} defines the vectorial part of the 0052 //! transformation and T defines the translation part of 0053 //! the transformation. 0054 //! Note: Geom_Transformation transformations 0055 //! provide the same kind of "geometric" services as 0056 //! gp_Trsf ones but have more complex data structures. 0057 //! The geometric objects provided by the Geom 0058 //! package use gp_Trsf transformations in the syntaxes 0059 //! Transform and Transformed. 0060 //! Geom_Transformation transformations are used in 0061 //! a context where they can be shared by several 0062 //! objects contained inside a common data structure. 0063 class Geom_Transformation : public Standard_Transient 0064 { 0065 DEFINE_STANDARD_RTTIEXT(Geom_Transformation, Standard_Transient) 0066 public: 0067 0068 //! Creates an identity transformation. 0069 Standard_EXPORT Geom_Transformation(); 0070 0071 //! Creates a transient copy of T. 0072 Standard_EXPORT Geom_Transformation(const gp_Trsf& T); 0073 0074 //! Makes the transformation into a symmetrical transformation 0075 //! with respect to a point P. 0076 //! P is the center of the symmetry. 0077 void SetMirror (const gp_Pnt& thePnt) { gpTrsf.SetMirror (thePnt); } 0078 0079 //! Makes the transformation into a symmetrical transformation 0080 //! with respect to an axis A1. 0081 //! A1 is the center of the axial symmetry. 0082 void SetMirror (const gp_Ax1& theA1) { gpTrsf.SetMirror (theA1); } 0083 0084 //! Makes the transformation into a symmetrical transformation 0085 //! with respect to a plane. The plane of the symmetry is 0086 //! defined with the axis placement A2. It is the plane 0087 //! (Location, XDirection, YDirection). 0088 void SetMirror (const gp_Ax2& theA2) { gpTrsf.SetMirror (theA2); } 0089 0090 //! Makes the transformation into a rotation. 0091 //! A1 is the axis rotation and Ang is the angular value 0092 //! of the rotation in radians. 0093 void SetRotation (const gp_Ax1& theA1, const Standard_Real theAng) { gpTrsf.SetRotation (theA1, theAng); } 0094 0095 //! Makes the transformation into a scale. P is the center of 0096 //! the scale and S is the scaling value. 0097 void SetScale (const gp_Pnt& thePnt, const Standard_Real theScale) { gpTrsf.SetScale (thePnt, theScale); } 0098 0099 //! Makes a transformation allowing passage from the coordinate 0100 //! system "FromSystem1" to the coordinate system "ToSystem2". 0101 //! Example : 0102 //! In a C++ implementation : 0103 //! Real x1, y1, z1; // are the coordinates of a point in the 0104 //! // local system FromSystem1 0105 //! Real x2, y2, z2; // are the coordinates of a point in the 0106 //! // local system ToSystem2 0107 //! gp_Pnt P1 (x1, y1, z1) 0108 //! Geom_Transformation T; 0109 //! T.SetTransformation (FromSystem1, ToSystem2); 0110 //! gp_Pnt P2 = P1.Transformed (T); 0111 //! P2.Coord (x2, y2, z2); 0112 void SetTransformation (const gp_Ax3& theFromSystem1, const gp_Ax3& theToSystem2) { gpTrsf.SetTransformation (theFromSystem1, theToSystem2); } 0113 0114 //! Makes the transformation allowing passage from the basic 0115 //! coordinate system 0116 //! {P(0.,0.,0.), VX (1.,0.,0.), VY (0.,1.,0.), VZ (0., 0. ,1.) } 0117 //! to the local coordinate system defined with the Ax2 ToSystem. 0118 //! Same utilisation as the previous method. FromSystem1 is 0119 //! defaulted to the absolute coordinate system. 0120 void SetTransformation (const gp_Ax3& theToSystem) { gpTrsf.SetTransformation (theToSystem); } 0121 0122 //! Makes the transformation into a translation. 0123 //! V is the vector of the translation. 0124 void SetTranslation (const gp_Vec& theVec) { gpTrsf.SetTranslation (theVec); } 0125 0126 //! Makes the transformation into a translation from the point 0127 //! P1 to the point P2. 0128 void SetTranslation (const gp_Pnt& P1, const gp_Pnt& P2) { gpTrsf.SetTranslation (P1, P2); } 0129 0130 //! Converts the gp_Trsf transformation T into this transformation. 0131 void SetTrsf (const gp_Trsf& theTrsf) { gpTrsf = theTrsf; } 0132 0133 //! Checks whether this transformation is an indirect 0134 //! transformation: returns true if the determinant of the 0135 //! matrix of the vectorial part of the transformation is less than 0. 0136 Standard_Boolean IsNegative() const { return gpTrsf.IsNegative(); } 0137 0138 //! Returns the nature of this transformation as a value 0139 //! of the gp_TrsfForm enumeration. 0140 gp_TrsfForm Form() const { return gpTrsf.Form(); } 0141 0142 //! Returns the scale value of the transformation. 0143 Standard_Real ScaleFactor() const { return gpTrsf.ScaleFactor(); } 0144 0145 //! Returns a non transient copy of <me>. 0146 const gp_Trsf& Trsf() const { return gpTrsf; } 0147 0148 //! Returns the coefficients of the global matrix of transformation. 0149 //! It is a 3 rows X 4 columns matrix. 0150 //! 0151 //! Raised if Row < 1 or Row > 3 or Col < 1 or Col > 4 0152 Standard_Real Value (const Standard_Integer theRow, const Standard_Integer theCol) const { return gpTrsf.Value (theRow, theCol); } 0153 0154 //! Raised if the transformation is singular. This means that 0155 //! the ScaleFactor is lower or equal to Resolution from 0156 //! package gp. 0157 void Invert() { gpTrsf.Invert(); } 0158 0159 //! Raised if the transformation is singular. This means that 0160 //! the ScaleFactor is lower or equal to Resolution from 0161 //! package gp. 0162 Standard_NODISCARD Standard_EXPORT Handle(Geom_Transformation) Inverted() const; 0163 0164 //! Computes the transformation composed with Other and <me>. 0165 //! <me> * Other. 0166 //! Returns a new transformation 0167 Standard_NODISCARD Standard_EXPORT Handle(Geom_Transformation) Multiplied (const Handle(Geom_Transformation)& Other) const; 0168 0169 //! Computes the transformation composed with Other and <me> . 0170 //! <me> = <me> * Other. 0171 void Multiply (const Handle(Geom_Transformation)& theOther) { gpTrsf.Multiply (theOther->Trsf()); } 0172 0173 //! Computes the following composition of transformations 0174 //! if N > 0 <me> * <me> * .......* <me>. 0175 //! if N = 0 Identity 0176 //! if N < 0 <me>.Invert() * .........* <me>.Invert() 0177 //! 0178 //! Raised if N < 0 and if the transformation is not inversible 0179 void Power (const Standard_Integer N) { gpTrsf.Power (N); } 0180 0181 //! Raised if N < 0 and if the transformation is not inversible 0182 Standard_EXPORT Handle(Geom_Transformation) Powered (const Standard_Integer N) const; 0183 0184 //! Computes the matrix of the transformation composed with 0185 //! <me> and Other. <me> = Other * <me> 0186 Standard_EXPORT void PreMultiply (const Handle(Geom_Transformation)& Other); 0187 0188 //! Applies the transformation <me> to the triplet {X, Y, Z}. 0189 void Transforms (Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const { gpTrsf.Transforms (theX, theY, theZ); } 0190 0191 //! Creates a new object which is a copy of this transformation. 0192 Standard_EXPORT Handle(Geom_Transformation) Copy() const; 0193 0194 //! Dumps the content of me into the stream 0195 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; 0196 0197 private: 0198 0199 gp_Trsf gpTrsf; 0200 0201 }; 0202 0203 #endif // _Geom_Transformation_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |