Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:33

0001 // Created on: 1993-03-24
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 _Geom2d_Transformation_HeaderFile
0018 #define _Geom2d_Transformation_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <gp_Trsf2d.hxx>
0023 #include <Standard_Transient.hxx>
0024 #include <Standard_Real.hxx>
0025 #include <gp_TrsfForm.hxx>
0026 #include <Standard_Integer.hxx>
0027 class gp_Pnt2d;
0028 class gp_Ax2d;
0029 class gp_Vec2d;
0030 
0031 
0032 class Geom2d_Transformation;
0033 DEFINE_STANDARD_HANDLE(Geom2d_Transformation, Standard_Transient)
0034 
0035 
0036 //! The class Transformation allows to create Translation,
0037 //! Rotation, Symmetry, Scaling and complex transformations
0038 //! obtained by combination of the previous elementary
0039 //! transformations.
0040 //! The Transformation class can also be used to
0041 //! construct complex transformations by combining
0042 //! these elementary transformations.
0043 //! However, these transformations can never change
0044 //! the type of an object. For example, the projection
0045 //! transformation can change a circle into an ellipse,
0046 //! and therefore change the real type of the object.
0047 //! Such a transformation is forbidden in this
0048 //! environment and cannot be a Geom2d_Transformation.
0049 //! The transformation can be represented as follow :
0050 //!
0051 //! V1   V2     T
0052 //! | a11  a12    a14 |   | x |      | x'|
0053 //! | a21  a22    a24 |   | y |      | y'|
0054 //! |  0    0      1  |   | 1 |      | 1 |
0055 //!
0056 //! where {V1, V2} defines the vectorial part of the
0057 //! transformation and T defines the translation part of
0058 //! the transformation.
0059 //! - Geom2d_Transformation transformations provide
0060 //! the same kind of "geometric" services as
0061 //! gp_Trsf2d ones but have more complex data
0062 //! structures. The geometric objects provided by the
0063 //! Geom2d package use gp_Trsf2d transformations
0064 //! in the syntaxes Transform and Transformed.
0065 //! - Geom2d_Transformation transformations are
0066 //! used in a context where they can be shared by
0067 //! several objects contained inside a common data structure.
0068 class Geom2d_Transformation : public Standard_Transient
0069 {
0070 
0071 public:
0072 
0073   
0074   //! Creates an identity transformation.
0075   Standard_EXPORT Geom2d_Transformation();
0076   
0077   //! Creates a persistent copy of T.
0078   Standard_EXPORT Geom2d_Transformation(const gp_Trsf2d& T);
0079   
0080 
0081   //! Makes the transformation into a symmetrical transformation
0082   //! with respect to a point P.
0083   //! P is the center of the symmetry.
0084   Standard_EXPORT void SetMirror (const gp_Pnt2d& P);
0085   
0086 
0087   //! Makes the transformation into a symmetrical transformation
0088   //! with respect to an axis A.
0089   //! A is the center of the axial symmetry.
0090   Standard_EXPORT void SetMirror (const gp_Ax2d& A);
0091   
0092   //! Assigns to this transformation the geometric
0093   //! properties of a rotation at angle Ang (in radians) about point P.
0094   Standard_EXPORT void SetRotation (const gp_Pnt2d& P, const Standard_Real Ang);
0095   
0096 
0097   //! Makes the transformation into a scale. P is the center of
0098   //! the scale and S is the scaling value.
0099   Standard_EXPORT void SetScale (const gp_Pnt2d& P, const Standard_Real S);
0100   
0101 
0102   //! Makes a transformation allowing passage from the coordinate
0103   //! system "FromSystem1" to the coordinate system "ToSystem2".
0104   Standard_EXPORT void SetTransformation (const gp_Ax2d& FromSystem1, const gp_Ax2d& ToSystem2);
0105   
0106 
0107   //! Makes the transformation allowing passage from the basic
0108   //! coordinate system
0109   //! {P(0.,0.,0.), VX (1.,0.,0.), VY (0.,1.,0.)}
0110   //! to the local coordinate system defined with the Ax2d ToSystem.
0111   Standard_EXPORT void SetTransformation (const gp_Ax2d& ToSystem);
0112   
0113 
0114   //! Makes the transformation into a translation.
0115   //! V is the vector of the translation.
0116   Standard_EXPORT void SetTranslation (const gp_Vec2d& V);
0117   
0118 
0119   //! Makes the transformation into a translation from the point
0120   //! P1 to the point P2.
0121   Standard_EXPORT void SetTranslation (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
0122   
0123 
0124   //! Makes the transformation into a transformation T from
0125   //! package gp.
0126   Standard_EXPORT void SetTrsf2d (const gp_Trsf2d& T);
0127   
0128   //! Checks whether this transformation is an indirect
0129   //! transformation: returns true if the determinant of the
0130   //! matrix of the vectorial part of the transformation is less than 0.
0131   Standard_EXPORT Standard_Boolean IsNegative() const;
0132   
0133   //! Returns the nature of this transformation as a value
0134   //! of the gp_TrsfForm enumeration.
0135   //! Returns the nature of the transformation. It can be
0136   //! Identity, Rotation, Translation, PntMirror, Ax1Mirror,
0137   //! Scale, CompoundTrsf
0138   Standard_EXPORT gp_TrsfForm Form() const;
0139   
0140   //! Returns the scale value of the transformation.
0141   Standard_EXPORT Standard_Real ScaleFactor() const;
0142   
0143   //! Converts this transformation into a gp_Trsf2d transformation.
0144   //! Returns a non persistent copy of <me>.
0145   //! -C++: return const&
0146   Standard_EXPORT gp_Trsf2d Trsf2d() const;
0147   
0148 
0149   //! Returns the coefficients of the global matrix of transformation.
0150   //! It is a 2 rows X 3 columns matrix.
0151   //!
0152   //! Raised if  Row < 1 or Row > 2  or  Col < 1 or Col > 2
0153   //!
0154   //! Computes the reverse transformation.
0155   Standard_EXPORT Standard_Real Value (const Standard_Integer Row, const Standard_Integer Col) const;
0156   
0157   //! Computes the inverse of this transformation.
0158   //! and  assigns the result to this transformatio
0159   //!
0160   //! Raised if the transformation is singular. This means that
0161   //! the ScaleFactor is lower or equal to Resolution from
0162   //! package gp.
0163   Standard_EXPORT void Invert();
0164   
0165   //! Computes the inverse of this transformation and creates a new one.
0166   //! Raises ConstructionError  if the transformation is singular. This means that
0167   //! the ScaleFactor is lower or equal to Resolution from package gp.
0168   Standard_NODISCARD Standard_EXPORT Handle(Geom2d_Transformation) Inverted() const;
0169   
0170 
0171   //! Computes the transformation composed with Other and <me>.
0172   //! <me> * Other.
0173   //! Returns a new transformation
0174   Standard_NODISCARD Standard_EXPORT
0175     Handle(Geom2d_Transformation) Multiplied (const Handle(Geom2d_Transformation)& Other) const;
0176 Standard_NODISCARD Handle(Geom2d_Transformation) operator * (const Handle(Geom2d_Transformation)& Other) const
0177 {
0178   return Multiplied(Other);
0179 }
0180   
0181 
0182   //! Computes the transformation composed with Other and <me> .
0183   //! <me> = <me> * Other.
0184   //!
0185   //! Computes the following composition of transformations
0186   //! if N > 0  <me> * <me> * .......* <me>.
0187   //! if N = 0  Identity
0188   //! if N < 0  <me>.Invert() * .........* <me>.Invert()
0189   Standard_EXPORT void Multiply (const Handle(Geom2d_Transformation)& Other);
0190 void operator *= (const Handle(Geom2d_Transformation)& Other)
0191 {
0192   Multiply(Other);
0193 }
0194   
0195 
0196   //! Raised if N < 0 and if the transformation is not inversible
0197   Standard_EXPORT void Power (const Standard_Integer N);
0198   
0199 
0200   //! Raised if N < 0 and if the transformation is not inversible
0201   Standard_EXPORT Handle(Geom2d_Transformation) Powered (const Standard_Integer N) const;
0202   
0203 
0204   //! Computes the matrix of the transformation composed with
0205   //! <me> and Other.     <me> = Other * <me>
0206   Standard_EXPORT void PreMultiply (const Handle(Geom2d_Transformation)& Other);
0207   
0208 
0209   //! Applies the transformation <me> to the triplet {X, Y}.
0210   Standard_EXPORT void Transforms (Standard_Real& X, Standard_Real& Y) const;
0211   
0212   //! Creates a new object, which is a copy of this transformation.
0213   Standard_EXPORT Handle(Geom2d_Transformation) Copy() const;
0214 
0215 
0216 
0217 
0218   DEFINE_STANDARD_RTTIEXT(Geom2d_Transformation,Standard_Transient)
0219 
0220 protected:
0221 
0222 
0223 
0224 
0225 private:
0226 
0227 
0228   gp_Trsf2d gpTrsf2d;
0229 
0230 
0231 };
0232 
0233 
0234 
0235 
0236 
0237 
0238 
0239 #endif // _Geom2d_Transformation_HeaderFile