UnitsAPI
OCCT package UnitsAPI: UnitsAPI, UnitsAPI_SystemUnits.
UnitsAPI
The UnitsAPI global functions are used to convert a value from any unit into another unit. Principles Conversion is executed among three unit systems:
- the SI System
- the user's Local System
- the user's Current System. The SI System is the standard international unit system. It is indicated by SI in the synopses of the
UnitsAPIfunctions.
The MDTV System corresponds to the SI international standard but the length unit and all its derivatives use millimeters instead of the meters. Both systems are proposed by Open CASCADE; the SI System is the standard option. By selecting one of these two systems, the user defines his Local System through the SetLocalSystem function. The Local System is indicated by LS in the synopses of theUnitsAPIfunctions. The user's Local System units can be modified in the working environment. The user defines his Current System by modifying its units through the SetCurrentUnit function. The Current System is indicated by Current in the synopses of theUnitsAPIfunctions.
Constructors(1)
Static methods(35)
- CurrentToLS(aData: number, aQuantity: string): number
Converts the current unit value to the local system units value. Example: CurrentToLS(1.,"LENGTH") returns 1000. if the current length unit is meter and LocalSystem is MDTV.
Parameters (2)aDataaQuantity
- CurrentToSI(aData: number, aQuantity: string): number
Converts the current unit value to the SI system units value. Example: CurrentToSI(1.,"LENGTH") returns 0.001 if current length unit is millimeter.
Parameters (2)aDataaQuantity
- CurrentFromLS(aData: number, aQuantity: string): number
Converts the local system units value to the current unit value. Example: CurrentFromLS(1000.,"LENGTH") returns 1. if current length unit is meter and LocalSystem is MDTV.
Parameters (2)aDataaQuantity
- CurrentFromSI(aData: number, aQuantity: string): number
Converts the SI system units value to the current unit value. Example: CurrentFromSI(0.001,"LENGTH") returns 1 if current length unit is millimeter.
Parameters (2)aDataaQuantity
- AnyToLS(aData: number, aUnit: string): number
Converts the local unit value to the local system units value. Example: AnyToLS(1.,"in.") returns 25.4 if the LocalSystem is MDTV.
Parameters (2)aDataaUnit
- AnyToLS_1(aData: number, aUnit: string): number
Converts the local unit value to the local system units value. Example: AnyToLS(1.,"in.") returns 25.4 if the LocalSystem is MDTV.
Parameters (2)aDataaUnit
- AnyToLS_2(aData: number, aUnit: string): { returnValue: number; aDim: Units_Dimensions; [Symbol.dispose](): void }
Converts the local unit value to the local system units value. and gives the associated dimension of the unit.
Parameters (2)aDataaUnit
ReturnsA result object with fields:
returnValue: the C++ return valueaDim: owned by the returned envelope.
Dispose the returned envelope to release owned Handle fields.
- AnyToSI(aData: number, aUnit: string): number
Converts the local unit value to the SI system units value. Example: AnyToSI(1.,"in.") returns 0.0254.
Parameters (2)aDataaUnit
- AnyToSI_1(aData: number, aUnit: string): number
Converts the local unit value to the SI system units value. Example: AnyToSI(1.,"in.") returns 0.0254.
Parameters (2)aDataaUnit
- AnyToSI_2(aData: number, aUnit: string): { returnValue: number; aDim: Units_Dimensions; [Symbol.dispose](): void }
Converts the local unit value to the SI system units value. and gives the associated dimension of the unit.
Parameters (2)aDataaUnit
ReturnsA result object with fields:
returnValue: the C++ return valueaDim: owned by the returned envelope.
Dispose the returned envelope to release owned Handle fields.
- AnyFromLS(aData: number, aUnit: string): number
Converts the local system units value to the local unit value. Example: AnyFromLS(25.4,"in.") returns 1. if the LocalSystem is MDTV. Note: aUnit is also used to identify the type of physical quantity to convert.
Parameters (2)aDataaUnit
- AnyFromSI(aData: number, aUnit: string): number
Converts the SI system units value to the local unit value. Example: AnyFromSI(0.0254,"in.") returns 0.001 Note: aUnit is also used to identify the type of physical quantity to convert.
Parameters (2)aDataaUnit
- CurrentToAny(aData: number, aQuantity: string, aUnit: string): number
Converts the aData value expressed in the current unit for the working environment, as defined for the physical quantity aQuantity by the last call to the SetCurrentUnit function, into the unit aUnit.
Parameters (3)aDataaQuantityaUnit
- CurrentFromAny(aData: number, aQuantity: string, aUnit: string): number
Converts the aData value expressed in the unit aUnit, into the current unit for the working environment, as defined for the physical quantity aQuantity by the last call to the SetCurrentUnit function.
Parameters (3)aDataaQuantityaUnit
- AnyToAny(aData: number, aUnit1: string, aUnit2: string): number
Converts the local unit value to another local unit value. Example: AnyToAny(0.0254,"in.","mm") returns 1. ;.
Parameters (3)aDataaUnit1aUnit2
- LSToSI(aData: number, aQuantity: string): number
Converts the local system units value to the SI system unit value. Example: LSToSI(1.,"LENGTH") returns 0.001 if the local system length unit is millimeter.
Parameters (2)aDataaQuantity
- SIToLS(aData: number, aQuantity: string): number
Converts the SI system unit value to the local system units value. Example: SIToLS(1.,"LENGTH") returns 1000. if the local system length unit is millimeter.
Parameters (2)aDataaQuantity
- SetLocalSystem(aSystemUnit?: UnitsAPI_SystemUnits): void
Sets the local system units. Example: SetLocalSystem(UnitsAPI_MDTV).
Parameters (1)aSystemUnit
Returns the current local system units.
- SetCurrentUnit(aQuantity: string, aUnit: string): void
Sets the current unit dimension <aUnit> to the unit quantity <aQuantity>. Example: SetCurrentUnit("LENGTH","mm").
Parameters (2)aQuantityaUnit
- CurrentUnit(aQuantity: string): string
Returns the current unit dimension <aUnit> from the unit quantity <aQuantity>.
Parameters (1)aQuantity
- Save(): void
saves the units in the file .CurrentUnits of the directory pointed by the CSF_CurrentUnitsUserDefaults environment variable.
- Reload(): void
- Dimensions(aQuantity: string): Units_Dimensions
return the dimension associated to the quantity
Parameters (1)aQuantity
Returns the basic dimensions.
- Check(aQuantity: string, aUnit: string): boolean
Checks the coherence between the quantity <aQuantity> and the unit <aUnits> in the current system and returns FALSE when it's WRONG.
Parameters (2)aQuantityaUnit