Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-20 10:28:34

0001 // Created on: 1993-10-22
0002 // Created by: Gilles DEBARBOUILLE
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 _Units_UnitsSystem_HeaderFile
0018 #define _Units_UnitsSystem_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Units_Quantity.hxx>
0024 #include <NCollection_Sequence.hxx>
0025 #include <NCollection_HSequence.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <Standard_Transient.hxx>
0028 class TCollection_AsciiString;
0029 
0030 //! This class allows the user to define his own
0031 //! system of units.
0032 class Units_UnitsSystem : public Standard_Transient
0033 {
0034 
0035 public:
0036   //! Returns an instance of UnitsSystem initialized to the
0037   //! S.I. units system.
0038   Standard_EXPORT Units_UnitsSystem();
0039 
0040   //! Returns an instance of UnitsSystem initialized to the
0041   //! S.I. units system upgraded by the base system units description
0042   //! file.
0043   //! Attempts to find the four following files:
0044   //! $CSF_`aName`Defaults/.aName
0045   //! $CSF_`aName`SiteDefaults/.aName
0046   //! $CSF_`aName`GroupDefaults/.aName
0047   //! $CSF_`aName`UserDefaults/.aName
0048   //! See : Resource_Manager for the description of this file.
0049   Standard_EXPORT Units_UnitsSystem(const char* const aName, const bool Verbose = false);
0050 
0051   //! Returns the sequence of refined quantities.
0052   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<Units_Quantity>>>
0053                   QuantitiesSequence() const;
0054 
0055   //! Returns a sequence of integer in correspondence with
0056   //! the sequence of quantities, which indicates, for each
0057   //! redefined quantity, the index into the sequence of
0058   //! units, of the active unit.
0059   Standard_EXPORT occ::handle<NCollection_HSequence<int>> ActiveUnitsSequence() const;
0060 
0061   //! Specifies for <aquantity> the unit <aunit> used.
0062   Standard_EXPORT void Specify(const char* const aquantity, const char* const aunit);
0063 
0064   //! Removes for <aquantity> the unit <aunit> used.
0065   Standard_EXPORT void Remove(const char* const aquantity, const char* const aunit);
0066 
0067   //! Specifies for <aquantity> the unit <aunit> used.
0068   Standard_EXPORT void Activate(const char* const aquantity, const char* const aunit);
0069 
0070   //! Activates the first unit of all defined system quantities
0071   Standard_EXPORT void Activates();
0072 
0073   //! Returns for <aquantity> the active unit.
0074   Standard_EXPORT TCollection_AsciiString ActiveUnit(const char* const aquantity) const;
0075 
0076   //! Converts a real value <avalue> from the unit <aunit>
0077   //! belonging to the physical dimensions <aquantity> to
0078   //! the corresponding unit of the user system.
0079   Standard_EXPORT double ConvertValueToUserSystem(const char* const aquantity,
0080                                                   const double      avalue,
0081                                                   const char* const aunit) const;
0082 
0083   //! Converts the real value <avalue> from the S.I. system
0084   //! of units to the user system of units. <aquantity> is
0085   //! the physical dimensions of the measurement.
0086   Standard_EXPORT double ConvertSIValueToUserSystem(const char* const aquantity,
0087                                                     const double      avalue) const;
0088 
0089   //! Converts the real value <avalue> from the user system
0090   //! of units to the S.I. system of units. <aquantity> is
0091   //! the physical dimensions of the measurement.
0092   Standard_EXPORT double ConvertUserSystemValueToSI(const char* const aquantity,
0093                                                     const double      avalue) const;
0094 
0095   Standard_EXPORT void Dump() const;
0096 
0097   //! Returns TRUE if no units has been defined in the system.
0098   Standard_EXPORT bool IsEmpty() const;
0099 
0100   DEFINE_STANDARD_RTTIEXT(Units_UnitsSystem, Standard_Transient)
0101 
0102 private:
0103   occ::handle<NCollection_HSequence<occ::handle<Units_Quantity>>> thequantitiessequence;
0104   occ::handle<NCollection_HSequence<int>>                         theactiveunitssequence;
0105 };
0106 
0107 #endif // _Units_UnitsSystem_HeaderFile