1 -- Created on: 1995-11-15
2 -- Created by: Jean-Louis Frenkel <rmi@pernox>
3 -- Copyright (c) 1995-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and / or modify it
9 -- under the terms of the GNU Lesser General Public version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 -- Modified: Gerard GRAS <gg@photox> Tue Feb 25
18 -- Add local system methodes
19 -- Modified Mon Apr 7 16:52:40 1997 by Patrick BOSINCO
20 -- Add Dimensions access methods
21 -- GG 05/02/01 MECALOG
22 -- Add Check() method.
27 ---Purpose: The UnitsAPI global functions are used to
28 -- convert a value from any unit into another unit.
30 -- Conversion is executed among three unit systems:
32 -- - the user's Local System
33 -- - the user's Current System.
34 -- The SI System is the standard international unit
35 -- system. It is indicated by SI in the synopses of
36 -- the UnitsAPI functions.
37 -- The MDTV System corresponds to the SI
38 -- international standard but the length unit and all
39 -- its derivatives use millimeters instead of the meters.
40 -- Both systems are proposed by Open CASCADE;
41 -- the SI System is the standard option. By
42 -- selecting one of these two systems, the user
43 -- defines his Local System through the
44 -- SetLocalSystem function. The Local System is
45 -- indicated by LS in the synopses of the UnitsAPI functions.
46 -- The user's Local System units can be modified in
47 -- the working environment. The user defines his
48 -- Current System by modifying its units through
49 -- the SetCurrentUnit function. The Current
50 -- System is indicated by Current in the synopses
51 -- of the UnitsAPI functions.
57 enumeration SystemUnits is DEFAULT,SI,MDTV end;
58 ---Purpose: Identifies unit systems which may be defined as a
59 -- basis system in the user's session:
60 -- - UnitsAPI_DEFAULT : default system (this is the SI system)
61 -- - UnitsAPI_SI : the SI unit system
62 -- - UnitsAPI_MDTV : the MDTV unit system; it
63 -- is equivalent to the SI unit system but the
64 -- length unit and all its derivatives use
65 -- millimeters instead of meters.
66 -- Use the function SetLocalSystem to set up one
67 -- of these unit systems as working environment.
69 CurrentToLS(aData: Real from Standard; aQuantity: CString from Standard)
70 returns Real from Standard;
71 ---Purpose: Converts the current unit value to the local system units value.
72 -- Example: CurrentToLS(1.,"LENGTH") returns 1000. if the current length unit
73 -- is meter and LocalSystem is MDTV.
75 CurrentToSI(aData: Real from Standard; aQuantity: CString from Standard)
76 returns Real from Standard;
77 ---Purpose: Converts the current unit value to the SI system units value.
78 -- Example: CurrentToSI(1.,"LENGTH") returns 0.001 if current length unit
81 CurrentFromLS(aData: Real from Standard; aQuantity: CString from Standard)
82 returns Real from Standard;
83 ---Purpose: Converts the local system units value to the current unit value.
84 -- Example: CurrentFromLS(1000.,"LENGTH") returns 1. if current length unit
85 -- is meter and LocalSystem is MDTV.
87 CurrentFromSI(aData: Real from Standard; aQuantity: CString from Standard)
88 returns Real from Standard;
89 ---Purpose: Converts the SI system units value to the current unit value.
90 -- Example: CurrentFromSI(0.001,"LENGTH") returns 1 if current length unit
93 AnyToLS(aData: Real from Standard; aUnit: CString from Standard)
94 returns Real from Standard;
95 ---Purpose: Converts the local unit value to the local system units value.
96 -- Example: AnyToLS(1.,"in.") returns 25.4 if the LocalSystem is MDTV.
98 AnyToLS(aData: Real from Standard; aUnit: CString from Standard;
99 aDim : out Dimensions from Units)
100 returns Real from Standard;
101 ---Purpose: Converts the local unit value to the local system units value.
102 -- and gives the associated dimension of the unit
104 AnyToSI(aData: Real from Standard; aUnit: CString from Standard)
105 returns Real from Standard;
106 ---Purpose: Converts the local unit value to the SI system units value.
107 -- Example: AnyToSI(1.,"in.") returns 0.0254
109 AnyToSI(aData: Real from Standard; aUnit: CString from Standard;
110 aDim : out Dimensions from Units)
111 returns Real from Standard;
112 ---Purpose: Converts the local unit value to the SI system units value.
113 -- and gives the associated dimension of the unit
115 AnyFromLS(aData: Real from Standard; aUnit: CString from Standard)
116 returns Real from Standard;
117 ---Purpose: Converts the local system units value to the local unit value.
118 -- Example: AnyFromLS(25.4,"in.") returns 1. if the LocalSystem is MDTV.
119 -- Note: aUnit is also used to identify the type of physical quantity to convert.
121 AnyFromSI(aData: Real from Standard; aUnit: CString from Standard)
122 returns Real from Standard;
123 ---Purpose: Converts the SI system units value to the local unit value.
124 -- Example: AnyFromSI(0.0254,"in.") returns 0.001
125 -- Note: aUnit is also used to identify the type of physical quantity to convert.
127 CurrentToAny(aData: Real from Standard; aQuantity: CString from Standard;
128 aUnit: CString from Standard)
129 returns Real from Standard;
130 ---Purpose: Converts the aData value expressed in the
131 -- current unit for the working environment, as
132 -- defined for the physical quantity aQuantity by the
133 -- last call to the SetCurrentUnit function, into the unit aUnit.
135 CurrentFromAny(aData: Real from Standard; aQuantity: CString from Standard;
136 aUnit: CString from Standard)
137 returns Real from Standard;
138 ---Purpose: Converts the aData value expressed in the unit
139 -- aUnit, into the current unit for the working
140 -- environment, as defined for the physical quantity
141 -- aQuantity by the last call to the SetCurrentUnit function.
143 AnyToAny(aData: Real from Standard; aUnit1: CString from Standard;
144 aUnit2: CString from Standard)
145 returns Real from Standard;
146 ---Purpose: Converts the local unit value to another local unit value.
147 -- Example: AnyToAny(0.0254,"in.","millimeter") returns 1. ;
149 LSToSI(aData: Real from Standard; aQuantity: CString from Standard)
150 returns Real from Standard;
151 ---Purpose: Converts the local system units value to the SI system unit value.
152 -- Example: LSToSI(1.,"LENGTH") returns 0.001 if the local system
153 -- length unit is millimeter.
155 SIToLS(aData: Real from Standard; aQuantity: CString from Standard)
156 returns Real from Standard;
157 ---Purpose: Converts the SI system unit value to the local system units value.
158 -- Example: SIToLS(1.,"LENGTH") returns 1000. if the local system
159 -- length unit is millimeter.
161 SetLocalSystem(aSystemUnit: SystemUnits = UnitsAPI_SI);
162 ---Purpose: Sets the local system units.
163 -- Example: SetLocalSystem(UnitsAPI_MDTV)
165 LocalSystem returns SystemUnits;
166 ---Purpose: Returns the current local system units.
168 SetCurrentUnit(aQuantity: CString from Standard; aUnit: CString from Standard);
169 ---Purpose: Sets the current unit dimension <aUnit> to the unit quantity <aQuantity>.
170 -- Example: SetCurrentUnit("LENGTH","millimeter")
172 CurrentUnit(aQuantity:CString from Standard)
173 returns CString from Standard;
174 ---Purpose: Returns the current unit dimension <aUnit> from the unit quantity <aQuantity>.
177 ---Purpose: saves the units in the file .CurrentUnits of the directory pointed by the
178 -- CSF_CurrentUnitsUserDefaults environment variable.
182 CheckLoading(aSystemUnit: SystemUnits) is private;
184 Dimensions(aQuantity : CString from Standard)
185 returns Dimensions from Units
186 raises NoSuchObject from Standard;
187 ---Purpose: return the dimension associated to the quantity
188 ---Example: Dimensions("LENGTH")
190 DimensionLess returns Dimensions from Units;
191 DimensionMass returns Dimensions from Units;
192 DimensionLength returns Dimensions from Units;
193 DimensionTime returns Dimensions from Units;
194 DimensionElectricCurrent returns Dimensions from Units;
195 DimensionThermodynamicTemperature returns Dimensions from Units;
196 DimensionAmountOfSubstance returns Dimensions from Units;
197 DimensionLuminousIntensity returns Dimensions from Units;
198 DimensionPlaneAngle returns Dimensions from Units;
199 DimensionSolidAngle returns Dimensions from Units;
200 ---Purpose: Returns the basic dimensions.
202 Check( aQuantity: CString from Standard;
203 aUnit: CString from Standard)
204 returns Boolean from Standard;
205 ---Purpose: Checks the coherence between the quantity <aQuantity>
206 -- and the unit <aUnits> in the current system and
207 -- returns FALSE when it's WRONG.