|
|
|||
File indexing completed on 2026-10-06 09:20:26
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 //! Describes how to construct the following elementary transformations 0028 //! - translations, 0029 //! - rotations, 0030 //! - symmetries, 0031 //! - scales. 0032 //! The Transformation class can also be used to 0033 //! construct complex transformations by combining these 0034 //! elementary transformations. 0035 //! However, these transformations can never change 0036 //! the type of an object. For example, the projection 0037 //! transformation can change a circle into an ellipse, and 0038 //! therefore change the real type of the object. Such a 0039 //! transformation is forbidden in this environment and 0040 //! cannot be a Geom_Transformation. 0041 //! The transformation can be represented as follow : 0042 //! 0043 //! V1 V2 V3 T 0044 //! | a11 a12 a13 a14 | | x | | x'| 0045 //! | a21 a22 a23 a24 | | y | | y'| 0046 //! | a31 a32 a33 a34 | | z | = | z'| 0047 //! | 0 0 0 1 | | 1 | | 1 | 0048 //! 0049 //! where {V1, V2, V3} defines the vectorial part of the 0050 //! transformation and T defines the translation part of 0051 //! the transformation. 0052 //! Note: Geom_Transformation transformations 0053 //! provide the same kind of "geometric" services as 0054 //! gp_Trsf ones but have more complex data structures. 0055 //! The geometric objects provided by the Geom 0056 //! package use gp_Trsf transformations in the syntaxes 0057 //! Transform and Transformed. 0058 //! Geom_Transformation transformations are used in 0059 //! a context where they can be shared by several 0060 //! objects contained inside a common data structure. 0061 class Geom_Transformation : public Standard_Transient 0062 { 0063 DEFINE_STANDARD_RTTIEXT(Geom_Transformation, Standard_Transient) 0064 public: 0065 //! Creates an identity transformation. 0066 Standard_EXPORT Geom_Transformation(); 0067 0068 //! Creates a transient copy of T. 0069 Standard_EXPORT Geom_Transformation(const gp_Trsf& T); 0070 0071 //! Makes the transformation into a symmetrical transformation 0072 //! with respect to a point P. 0073 //! P is the center of the symmetry. 0074 void SetMirror(const gp_Pnt& thePnt) { gpTrsf.SetMirror(thePnt); } 0075 0076 //! Makes the transformation into a symmetrical transformation 0077 //! with respect to an axis A1. 0078 //! A1 is the center of the axial symmetry. 0079 void SetMirror(const gp_Ax1& theA1) { gpTrsf.SetMirror(theA1); } 0080 0081 //! Makes the transformation into a symmetrical transformation 0082 //! with respect to a plane. The plane of the symmetry is 0083 //! defined with the axis placement A2. It is the plane 0084 //! (Location, XDirection, YDirection). 0085 void SetMirror(const gp_Ax2& theA2) { gpTrsf.SetMirror(theA2); } 0086 0087 //! Makes the transformation into a rotation. 0088 //! A1 is the axis rotation and Ang is the angular value 0089 //! of the rotation in radians. 0090 void SetRotation(const gp_Ax1& theA1, const double theAng) { gpTrsf.SetRotation(theA1, theAng); } 0091 0092 //! Makes the transformation into a scale. P is the center of 0093 //! the scale and S is the scaling value. 0094 void SetScale(const gp_Pnt& thePnt, const double theScale) { gpTrsf.SetScale(thePnt, theScale); } 0095 0096 //! Makes a transformation allowing passage from the coordinate 0097 //! system "FromSystem1" to the coordinate system "ToSystem2". 0098 //! Example : 0099 //! In a C++ implementation : 0100 //! Real x1, y1, z1; // are the coordinates of a point in the 0101 //! // local system FromSystem1 0102 //! Real x2, y2, z2; // are the coordinates of a point in the 0103 //! // local system ToSystem2 0104 //! gp_Pnt P1 (x1, y1, z1) 0105 //! Geom_Transformation T; 0106 //! T.SetTransformation (FromSystem1, ToSystem2); 0107 //! gp_Pnt P2 = P1.Transformed (T); 0108 //! P2.Coord (x2, y2, z2); 0109 void SetTransformation(const gp_Ax3& theFromSystem1, const gp_Ax3& theToSystem2) 0110 { 0111 gpTrsf.SetTransformation(theFromSystem1, theToSystem2); 0112 } 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 bool 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 double 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 double Value(const int theRow, const int 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 [[nodiscard]] Standard_EXPORT occ::handle<Geom_Transformation> Inverted() const; 0163 0164 //! Computes the transformation composed with Other and <me>. 0165 //! <me> * Other. 0166 //! Returns a new transformation 0167 [[nodiscard]] Standard_EXPORT occ::handle<Geom_Transformation> Multiplied( 0168 const occ::handle<Geom_Transformation>& Other) const; 0169 0170 //! Computes the transformation composed with Other and <me> . 0171 //! <me> = <me> * Other. 0172 void Multiply(const occ::handle<Geom_Transformation>& theOther) 0173 { 0174 gpTrsf.Multiply(theOther->Trsf()); 0175 } 0176 0177 //! Computes the following composition of transformations 0178 //! if N > 0 <me> * <me> * .......* <me>. 0179 //! if N = 0 Identity 0180 //! if N < 0 <me>.Invert() * .........* <me>.Invert() 0181 //! 0182 //! Raised if N < 0 and if the transformation is not inversible 0183 void Power(const int N) { gpTrsf.Power(N); } 0184 0185 //! Raised if N < 0 and if the transformation is not inversible 0186 Standard_EXPORT occ::handle<Geom_Transformation> Powered(const int N) const; 0187 0188 //! Computes the matrix of the transformation composed with 0189 //! <me> and Other. <me> = Other * <me> 0190 Standard_EXPORT void PreMultiply(const occ::handle<Geom_Transformation>& Other); 0191 0192 //! Applies the transformation <me> to the triplet {X, Y, Z}. 0193 void Transforms(double& theX, double& theY, double& theZ) const 0194 { 0195 gpTrsf.Transforms(theX, theY, theZ); 0196 } 0197 0198 //! Creates a new object which is a copy of this transformation. 0199 [[nodiscard]] Standard_EXPORT occ::handle<Geom_Transformation> Copy() const; 0200 0201 //! Dumps the content of me into the stream 0202 Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const; 0203 0204 private: 0205 gp_Trsf gpTrsf; 0206 }; 0207 0208 #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 |
|