Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:18:20

0001 // Created on: 1992-06-22
0002 // Created by: Gilles DEBARBOUILLE
0003 // Copyright (c) 1992-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 _Units_Measurement_HeaderFile
0018 #define _Units_Measurement_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 class Units_Token;
0025 
0026 //! This class defines a measurement which is the
0027 //! association of a real value and a unit.
0028 class Units_Measurement
0029 {
0030 public:
0031   DEFINE_STANDARD_ALLOC
0032 
0033   //! It is the empty constructor of the class.
0034   Standard_EXPORT Units_Measurement();
0035 
0036   //! Returns an instance of this class. <avalue> defines
0037   //! the measurement, and <atoken> the token which defines
0038   //! the unit used.
0039   Standard_EXPORT Units_Measurement(const double avalue, const occ::handle<Units_Token>& atoken);
0040 
0041   //! Returns an instance of this class. <avalue> defines
0042   //! the measurement, and <aunit> the unit used,
0043   //! described in natural language.
0044   Standard_EXPORT Units_Measurement(const double avalue, const char* const aunit);
0045 
0046   //! Converts (if possible) the measurement object into
0047   //! another unit. <aunit> must have the same
0048   //! dimensionality as the unit contained in the token
0049   //! <thetoken>.
0050   Standard_EXPORT void Convert(const char* const aunit);
0051 
0052   //! Returns a Measurement object with the integer value of
0053   //! the measurement contained in <me>.
0054   Standard_EXPORT Units_Measurement Integer() const;
0055 
0056   //! Returns a Measurement object with the fractional value
0057   //! of the measurement contained in <me>.
0058   Standard_EXPORT Units_Measurement Fractional() const;
0059 
0060   //! Returns the value of the measurement.
0061   Standard_EXPORT double Measurement() const;
0062 
0063   //! Returns the token contained in <me>.
0064   Standard_EXPORT occ::handle<Units_Token> Token() const;
0065 
0066   //! Returns (if it is possible) a measurement which is the
0067   //! addition of <me> and <ameasurement>. The chosen
0068   //! returned unit is the unit of <me>.
0069   Standard_EXPORT Units_Measurement Add(const Units_Measurement& ameasurement) const;
0070 
0071   Units_Measurement operator+(const Units_Measurement& ameasurement) const
0072   {
0073     return Add(ameasurement);
0074   }
0075 
0076   //! Returns (if it is possible) a measurement which is the
0077   //! subtraction of <me> and <ameasurement>. The chosen
0078   //! returned unit is the unit of <me>.
0079   Standard_EXPORT Units_Measurement Subtract(const Units_Measurement& ameasurement) const;
0080 
0081   Units_Measurement operator-(const Units_Measurement& ameasurement) const
0082   {
0083     return Subtract(ameasurement);
0084   }
0085 
0086   //! Returns a measurement which is the multiplication of
0087   //! <me> and <ameasurement>.
0088   Standard_EXPORT Units_Measurement Multiply(const Units_Measurement& ameasurement) const;
0089 
0090   Units_Measurement operator*(const Units_Measurement& ameasurement) const
0091   {
0092     return Multiply(ameasurement);
0093   }
0094 
0095   //! Returns a measurement which is the multiplication of
0096   //! <me> with the value <avalue>.
0097   Standard_EXPORT Units_Measurement Multiply(const double avalue) const;
0098 
0099   Units_Measurement operator*(const double avalue) const { return Multiply(avalue); }
0100 
0101   //! Returns a measurement which is the division of <me> by
0102   //! <ameasurement>.
0103   Standard_EXPORT Units_Measurement Divide(const Units_Measurement& ameasurement) const;
0104 
0105   Units_Measurement operator/(const Units_Measurement& ameasurement) const
0106   {
0107     return Divide(ameasurement);
0108   }
0109 
0110   //! Returns a measurement which is the division of <me> by
0111   //! the constant <avalue>.
0112   Standard_EXPORT Units_Measurement Divide(const double avalue) const;
0113 
0114   Units_Measurement operator/(const double avalue) const { return Divide(avalue); }
0115 
0116   //! Returns a measurement which is <me> powered
0117   //! <anexponent>.
0118   Standard_EXPORT Units_Measurement Power(const double anexponent) const;
0119 
0120   Standard_EXPORT bool HasToken() const;
0121 
0122   //! Useful for debugging.
0123   Standard_EXPORT void Dump() const;
0124 
0125 private:
0126   double                   themeasurement;
0127   occ::handle<Units_Token> myToken;
0128 };
0129 
0130 #endif // _Units_Measurement_HeaderFile