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_VectorWithMagnitude_HeaderFile
0018 #define _Geom2d_VectorWithMagnitude_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom2d_Vector.hxx>
0024 class gp_Vec2d;
0025 class gp_Pnt2d;
0026 class gp_Trsf2d;
0027 class Geom2d_Geometry;
0028 
0029 
0030 class Geom2d_VectorWithMagnitude;
0031 DEFINE_STANDARD_HANDLE(Geom2d_VectorWithMagnitude, Geom2d_Vector)
0032 
0033 
0034 //! Defines a vector with magnitude.
0035 //! A vector with magnitude can have a zero length.
0036 class Geom2d_VectorWithMagnitude : public Geom2d_Vector
0037 {
0038 
0039 public:
0040 
0041   
0042   //! Creates a persistent copy of V.
0043   Standard_EXPORT Geom2d_VectorWithMagnitude(const gp_Vec2d& V);
0044   
0045   //! Creates a vector with two cartesian coordinates.
0046   Standard_EXPORT Geom2d_VectorWithMagnitude(const Standard_Real X, const Standard_Real Y);
0047   
0048 
0049   //! Creates a vector from the point P1 to the point P2.
0050   //! The magnitude of the vector is the distance between P1 and P2
0051   Standard_EXPORT Geom2d_VectorWithMagnitude(const gp_Pnt2d& P1, const gp_Pnt2d& P2);
0052   
0053   //! Set <me> to X, Y coordinates.
0054   Standard_EXPORT void SetCoord (const Standard_Real X, const Standard_Real Y);
0055   
0056   Standard_EXPORT void SetVec2d (const gp_Vec2d& V);
0057   
0058   //! Changes the X coordinate of <me>.
0059   Standard_EXPORT void SetX (const Standard_Real X);
0060   
0061   //! Changes the Y coordinate of <me>
0062   Standard_EXPORT void SetY (const Standard_Real Y);
0063   
0064   //! Returns the magnitude of <me>.
0065   Standard_EXPORT Standard_Real Magnitude() const Standard_OVERRIDE;
0066   
0067   //! Returns the square magnitude of <me>.
0068   Standard_EXPORT Standard_Real SquareMagnitude() const Standard_OVERRIDE;
0069   
0070 
0071   //! Adds the Vector Other to <me>.
0072   Standard_EXPORT void Add (const Handle(Geom2d_Vector)& Other);
0073 void operator += (const Handle(Geom2d_Vector)& Other)
0074 {
0075   Add(Other);
0076 }
0077   
0078 
0079   //! Adds the vector Other to <me>.
0080   Standard_NODISCARD Standard_EXPORT
0081   Handle(Geom2d_VectorWithMagnitude) Added (const Handle(Geom2d_Vector)& Other) const;
0082 Standard_NODISCARD Handle(Geom2d_VectorWithMagnitude) operator + (const Handle(Geom2d_Vector)& Other) const
0083 {
0084   return Added(Other);
0085 }
0086   
0087 
0088   //! Computes the cross product  between <me> and Other
0089   //! <me> ^ Other. A new vector is returned.
0090   Standard_EXPORT Standard_Real Crossed (const Handle(Geom2d_Vector)& Other) const Standard_OVERRIDE;
0091 Standard_Real operator ^ (const Handle(Geom2d_Vector)& Other) const
0092 {
0093   return Crossed(Other);
0094 }
0095   
0096   //! Divides <me> by a scalar.
0097   Standard_EXPORT void Divide (const Standard_Real Scalar);
0098 void operator /= (const Standard_Real Scalar)
0099 {
0100   Divide(Scalar);
0101 }
0102   
0103 
0104   //! Divides <me> by a scalar. A new vector is returned.
0105   Standard_NODISCARD Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Divided (const Standard_Real Scalar) const;
0106 Standard_NODISCARD Handle(Geom2d_VectorWithMagnitude) operator / (const Standard_Real Scalar) const
0107 {
0108   return Divided(Scalar);
0109 }
0110   
0111 
0112   //! Computes the product of the vector <me> by a scalar.
0113   //! A new vector is returned.
0114   //!
0115   //! -C++: alias operator *
0116   //! Collision with same operator defined for the class Vector!
0117   Standard_NODISCARD Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Multiplied (const Standard_Real Scalar) const;
0118   
0119 
0120   //! Computes the product of the vector <me> by a scalar.
0121   Standard_EXPORT void Multiply (const Standard_Real Scalar);
0122 void operator *= (const Standard_Real Scalar)
0123 {
0124   Multiply(Scalar);
0125 }
0126   
0127   //! Normalizes <me>.
0128   //!
0129   //! Raised if the magnitude of the vector is lower or equal to
0130   //! Resolution from package gp.
0131   Standard_EXPORT void Normalize();
0132   
0133   //! Returns a copy of <me> Normalized.
0134   //!
0135   //! Raised if the magnitude of the vector is lower or equal to
0136   //! Resolution from package gp.
0137   Standard_NODISCARD Standard_EXPORT Handle(Geom2d_VectorWithMagnitude) Normalized() const;
0138   
0139   //! Subtracts the Vector Other to <me>.
0140   Standard_EXPORT void Subtract (const Handle(Geom2d_Vector)& Other);
0141 void operator -= (const Handle(Geom2d_Vector)& Other)
0142 {
0143   Subtract(Other);
0144 }
0145   
0146 
0147   //! Subtracts the vector Other to <me>. A new vector is returned.
0148   Standard_NODISCARD Standard_EXPORT
0149   Handle(Geom2d_VectorWithMagnitude) Subtracted (const Handle(Geom2d_Vector)& Other) const;
0150 Standard_NODISCARD Handle(Geom2d_VectorWithMagnitude) operator - (const Handle(Geom2d_Vector)& Other) const
0151 {
0152   return Subtracted(Other);
0153 }
0154   
0155   //! Applies the transformation T to this vector.
0156   Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
0157   
0158   //! Creates a new object which is a copy of this vector.
0159   Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
0160 
0161 
0162 
0163 
0164   DEFINE_STANDARD_RTTIEXT(Geom2d_VectorWithMagnitude,Geom2d_Vector)
0165 
0166 protected:
0167 
0168 
0169 
0170 
0171 private:
0172 
0173 
0174 
0175 
0176 };
0177 
0178 
0179 
0180 
0181 
0182 
0183 
0184 #endif // _Geom2d_VectorWithMagnitude_HeaderFile