|
||||
File indexing completed on 2025-01-18 10:05:30
0001 // Created on: 1995-11-15 0002 // Created by: Jean-Louis Frenkel <rmi@pernox> 0003 // Copyright (c) 1995-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 _UnitsAPI_HeaderFile 0018 #define _UnitsAPI_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_CString.hxx> 0025 #include <UnitsAPI_SystemUnits.hxx> 0026 class Units_Dimensions; 0027 0028 0029 //! The UnitsAPI global functions are used to 0030 //! convert a value from any unit into another unit. 0031 //! Principles 0032 //! Conversion is executed among three unit systems: 0033 //! - the SI System 0034 //! - the user's Local System 0035 //! - the user's Current System. 0036 //! The SI System is the standard international unit 0037 //! system. It is indicated by SI in the synopses of 0038 //! the UnitsAPI functions. 0039 //! The MDTV System corresponds to the SI 0040 //! international standard but the length unit and all 0041 //! its derivatives use millimeters instead of the meters. 0042 //! Both systems are proposed by Open CASCADE; 0043 //! the SI System is the standard option. By 0044 //! selecting one of these two systems, the user 0045 //! defines his Local System through the 0046 //! SetLocalSystem function. The Local System is 0047 //! indicated by LS in the synopses of the UnitsAPI functions. 0048 //! The user's Local System units can be modified in 0049 //! the working environment. The user defines his 0050 //! Current System by modifying its units through 0051 //! the SetCurrentUnit function. The Current 0052 //! System is indicated by Current in the synopses 0053 //! of the UnitsAPI functions. 0054 class UnitsAPI 0055 { 0056 public: 0057 0058 DEFINE_STANDARD_ALLOC 0059 0060 0061 //! Converts the current unit value to the local system units value. 0062 //! Example: CurrentToLS(1.,"LENGTH") returns 1000. if the current length unit 0063 //! is meter and LocalSystem is MDTV. 0064 Standard_EXPORT static Standard_Real CurrentToLS (const Standard_Real aData, const Standard_CString aQuantity); 0065 0066 //! Converts the current unit value to the SI system units value. 0067 //! Example: CurrentToSI(1.,"LENGTH") returns 0.001 if current length unit 0068 //! is millimeter. 0069 Standard_EXPORT static Standard_Real CurrentToSI (const Standard_Real aData, const Standard_CString aQuantity); 0070 0071 //! Converts the local system units value to the current unit value. 0072 //! Example: CurrentFromLS(1000.,"LENGTH") returns 1. if current length unit 0073 //! is meter and LocalSystem is MDTV. 0074 Standard_EXPORT static Standard_Real CurrentFromLS (const Standard_Real aData, const Standard_CString aQuantity); 0075 0076 //! Converts the SI system units value to the current unit value. 0077 //! Example: CurrentFromSI(0.001,"LENGTH") returns 1 if current length unit 0078 //! is millimeter. 0079 Standard_EXPORT static Standard_Real CurrentFromSI (const Standard_Real aData, const Standard_CString aQuantity); 0080 0081 //! Converts the local unit value to the local system units value. 0082 //! Example: AnyToLS(1.,"in.") returns 25.4 if the LocalSystem is MDTV. 0083 Standard_EXPORT static Standard_Real AnyToLS (const Standard_Real aData, const Standard_CString aUnit); 0084 0085 //! Converts the local unit value to the local system units value. 0086 //! and gives the associated dimension of the unit 0087 Standard_EXPORT static Standard_Real AnyToLS (const Standard_Real aData, const Standard_CString aUnit, Handle(Units_Dimensions)& aDim); 0088 0089 //! Converts the local unit value to the SI system units value. 0090 //! Example: AnyToSI(1.,"in.") returns 0.0254 0091 Standard_EXPORT static Standard_Real AnyToSI (const Standard_Real aData, const Standard_CString aUnit); 0092 0093 //! Converts the local unit value to the SI system units value. 0094 //! and gives the associated dimension of the unit 0095 Standard_EXPORT static Standard_Real AnyToSI (const Standard_Real aData, const Standard_CString aUnit, Handle(Units_Dimensions)& aDim); 0096 0097 //! Converts the local system units value to the local unit value. 0098 //! Example: AnyFromLS(25.4,"in.") returns 1. if the LocalSystem is MDTV. 0099 //! Note: aUnit is also used to identify the type of physical quantity to convert. 0100 Standard_EXPORT static Standard_Real AnyFromLS (const Standard_Real aData, const Standard_CString aUnit); 0101 0102 //! Converts the SI system units value to the local unit value. 0103 //! Example: AnyFromSI(0.0254,"in.") returns 0.001 0104 //! Note: aUnit is also used to identify the type of physical quantity to convert. 0105 Standard_EXPORT static Standard_Real AnyFromSI (const Standard_Real aData, const Standard_CString aUnit); 0106 0107 //! Converts the aData value expressed in the 0108 //! current unit for the working environment, as 0109 //! defined for the physical quantity aQuantity by the 0110 //! last call to the SetCurrentUnit function, into the unit aUnit. 0111 Standard_EXPORT static Standard_Real CurrentToAny (const Standard_Real aData, const Standard_CString aQuantity, const Standard_CString aUnit); 0112 0113 //! Converts the aData value expressed in the unit 0114 //! aUnit, into the current unit for the working 0115 //! environment, as defined for the physical quantity 0116 //! aQuantity by the last call to the SetCurrentUnit function. 0117 Standard_EXPORT static Standard_Real CurrentFromAny (const Standard_Real aData, const Standard_CString aQuantity, const Standard_CString aUnit); 0118 0119 //! Converts the local unit value to another local unit value. 0120 //! Example: AnyToAny(0.0254,"in.","millimeter") returns 1. ; 0121 Standard_EXPORT static Standard_Real AnyToAny (const Standard_Real aData, const Standard_CString aUnit1, const Standard_CString aUnit2); 0122 0123 //! Converts the local system units value to the SI system unit value. 0124 //! Example: LSToSI(1.,"LENGTH") returns 0.001 if the local system 0125 //! length unit is millimeter. 0126 Standard_EXPORT static Standard_Real LSToSI (const Standard_Real aData, const Standard_CString aQuantity); 0127 0128 //! Converts the SI system unit value to the local system units value. 0129 //! Example: SIToLS(1.,"LENGTH") returns 1000. if the local system 0130 //! length unit is millimeter. 0131 Standard_EXPORT static Standard_Real SIToLS (const Standard_Real aData, const Standard_CString aQuantity); 0132 0133 //! Sets the local system units. 0134 //! Example: SetLocalSystem(UnitsAPI_MDTV) 0135 Standard_EXPORT static void SetLocalSystem (const UnitsAPI_SystemUnits aSystemUnit = UnitsAPI_SI); 0136 0137 //! Returns the current local system units. 0138 Standard_EXPORT static UnitsAPI_SystemUnits LocalSystem(); 0139 0140 //! Sets the current unit dimension <aUnit> to the unit quantity <aQuantity>. 0141 //! Example: SetCurrentUnit("LENGTH","millimeter") 0142 Standard_EXPORT static void SetCurrentUnit (const Standard_CString aQuantity, const Standard_CString aUnit); 0143 0144 //! Returns the current unit dimension <aUnit> from the unit quantity <aQuantity>. 0145 Standard_EXPORT static Standard_CString CurrentUnit (const Standard_CString aQuantity); 0146 0147 //! saves the units in the file .CurrentUnits of the directory pointed by the 0148 //! CSF_CurrentUnitsUserDefaults environment variable. 0149 Standard_EXPORT static void Save(); 0150 0151 Standard_EXPORT static void Reload(); 0152 0153 //! return the dimension associated to the quantity 0154 Standard_EXPORT static Handle(Units_Dimensions) Dimensions (const Standard_CString aQuantity); 0155 0156 Standard_EXPORT static Handle(Units_Dimensions) DimensionLess(); 0157 0158 Standard_EXPORT static Handle(Units_Dimensions) DimensionMass(); 0159 0160 Standard_EXPORT static Handle(Units_Dimensions) DimensionLength(); 0161 0162 Standard_EXPORT static Handle(Units_Dimensions) DimensionTime(); 0163 0164 Standard_EXPORT static Handle(Units_Dimensions) DimensionElectricCurrent(); 0165 0166 Standard_EXPORT static Handle(Units_Dimensions) DimensionThermodynamicTemperature(); 0167 0168 Standard_EXPORT static Handle(Units_Dimensions) DimensionAmountOfSubstance(); 0169 0170 Standard_EXPORT static Handle(Units_Dimensions) DimensionLuminousIntensity(); 0171 0172 Standard_EXPORT static Handle(Units_Dimensions) DimensionPlaneAngle(); 0173 0174 //! Returns the basic dimensions. 0175 Standard_EXPORT static Handle(Units_Dimensions) DimensionSolidAngle(); 0176 0177 //! Checks the coherence between the quantity <aQuantity> 0178 //! and the unit <aUnits> in the current system and 0179 //! returns FALSE when it's WRONG. 0180 Standard_EXPORT static Standard_Boolean Check (const Standard_CString aQuantity, const Standard_CString aUnit); 0181 0182 0183 0184 0185 protected: 0186 0187 0188 0189 0190 0191 private: 0192 0193 0194 Standard_EXPORT static void CheckLoading (const UnitsAPI_SystemUnits aSystemUnit); 0195 0196 0197 0198 0199 }; 0200 0201 0202 0203 0204 0205 0206 0207 #endif // _UnitsAPI_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |