OpenCascade.js
API ReferenceFoundationClassesTKernel

Units

OCCT package Units: Units, Units_Dimensions, Units_Explorer, Units_Lexicon, and 14 more bound classes.

Units

This package provides all the facilities to create and question a dictionary of units, and also to manipulate measurements which are real values with units.

Constructors(1)

Static methods(16)

  • UnitsFile(afile: string): void

    Defines the location of the file containing all the information useful in creating the dictionary of all the units known to the system.

    Parameters (1)
    • afile
  • LexiconFile(afile: string): void

    Defines the location of the file containing the lexicon useful in manipulating composite units.

    Parameters (1)
    • afile
  • Returns a unique instance of the dictionary of units. If <amode> is True, then it forces the recomputation of the dictionary of units.

    Parameters (1)
    • amode
  • Quantity(aquantity: string): Units_Quantity

    Returns a unique quantity instance corresponding to <aquantity>.

    Parameters (1)
    • aquantity
  • FirstQuantity(aunit: string): string

    Returns the first quantity string founded from the unit <aUnit>.

    Parameters (1)
    • aunit
  • LexiconUnits(amode?: boolean): Units_Lexicon

    Returns a unique instance of the Units_Lexicon. If <amode> is True, it forces the recomputation of the dictionary of units, and by consequence the completion of the Units_Lexicon.

    Parameters (1)
    • amode
  • Return a unique instance of LexiconFormula.

  • Returns always the same instance of Dimensions.

  • Convert(avalue: number, afirstunit: string, asecondunit: string): number

    Converts <avalue> expressed in <afirstunit> into the <asecondunit>.

    Parameters (3)
    • avalue
    • afirstunit
    • asecondunit
  • ToSI(aData: number, aUnit: string): number
    Parameters (2)
    • aData
    • aUnit
  • ToSI_1(aData: number, aUnit: string): number
    Parameters (2)
    • aData
    • aUnit
  • ToSI_2(aData: number, aUnit: string): { returnValue: number; aDim: Units_Dimensions; [Symbol.dispose](): void }
    Parameters (2)
    • aData
    • aUnit
  • FromSI(aData: number, aUnit: string): number
    Parameters (2)
    • aData
    • aUnit
  • FromSI_1(aData: number, aUnit: string): number
    Parameters (2)
    • aData
    • aUnit
  • FromSI_2(aData: number, aUnit: string): { returnValue: number; aDim: Units_Dimensions; [Symbol.dispose](): void }
    Parameters (2)
    • aData
    • aUnit
  • return the dimension associated to the Type

    Parameters (1)
    • aType

Units_Dimensions

This class includes all the methods to create and manipulate the dimensions of the physical quantities.

Constructors(1)

  • constructor(amass: number, alength: number, atime: number, anelectriccurrent: number, athermodynamictemperature: number, anamountofsubstance: number, aluminousintensity: number, aplaneangle: number, asolidangle: number): Units_Dimensions

    Returns a Dimensions object which represents the dimension of a physical quantity. Each of the <amass>, <alength>, <atime>, <anelectriccurrent>, <athermodynamictemperature>, <anamountofsubstance>, <aluminousintensity>, <aplaneangle>, <asolidangle> are the powers for the 7 fundamental units of physical quantity and the 2 secondary fundamental units of physical quantity.

    Parameters (9)
    • amass
    • alength
    • atime
    • anelectriccurrent
    • athermodynamictemperature
    • anamountofsubstance
    • aluminousintensity
    • aplaneangle
    • asolidangle

Static methods(12)

Instance methods(17)

  • Mass(): number

    Returns the power of mass stored in the dimensions.

  • Length(): number

    Returns the power of length stored in the dimensions.

  • Time(): number

    Returns the power of time stored in the dimensions.

  • ElectricCurrent(): number

    Returns the power of electrical intensity (current) stored in the dimensions.

  • Returns the power of temperature stored in the dimensions.

  • Returns the power of quantity of material (mole) stored in the dimensions.

  • Returns the power of light intensity stored in the dimensions.

  • PlaneAngle(): number

    Returns the power of plane angle stored in the dimensions.

  • SolidAngle(): number

    Returns the power of solid angle stored in the dimensions.

  • Quantity(): string

    Returns the quantity string of the dimension.

  • Creates and returns a new Dimensions object which is the result of the multiplication of <me> and <adimensions>.

    Parameters (1)
    • adimensions
  • Creates and returns a new Dimensions object which is the result of the division of <me> by <adimensions>.

    Parameters (1)
    • adimensions
  • Power(anexponent: number): Units_Dimensions

    Creates and returns a new Dimensions object which is the result of the power of <me> and <anexponent>.

    Parameters (1)
    • anexponent
  • IsEqual(adimensions: Units_Dimensions): boolean

    Returns true if <me> and <adimensions> have the same dimensions, false otherwise.

    Parameters (1)
    • adimensions
  • IsNotEqual(adimensions: Units_Dimensions): boolean

    Returns false if <me> and <adimensions> have the same dimensions, true otherwise.

    Parameters (1)
    • adimensions
  • Dump(ashift: number): void

    Useful for degugging.

    Parameters (1)
    • ashift

Units_Explorer

This class provides all the services to explore UnitsSystem or UnitsDictionary.

Constructors(5)

Instance methods(11)

  • Init(aunitssystem: Units_UnitsSystem): void

    Initializes the instance of the class with the UnitsSystem <aunitssystem>.

    Parameters (1)
    • aunitssystem
  • Init(aunitsdictionary: Units_UnitsDictionary): void

    Initializes the instance of the class with the UnitsDictionary <aunitsdictionary>.

    Parameters (1)
    • aunitsdictionary
  • Init(aunitssystem: Units_UnitsSystem, aquantity: string): void

    Initializes the instance of the class with the UnitsSystem <aunitssystem> and positioned at the quantity <aquantity>.

    Parameters (2)
    • aunitssystem
    • aquantity
  • Init(aunitsdictionary: Units_UnitsDictionary, aquantity: string): void

    Initializes the instance of the class with the UnitsDictionary <aunitsdictionary> and positioned at the quantity <aquantity>.

    Parameters (2)
    • aunitsdictionary
    • aquantity
  • MoreQuantity(): boolean

    Returns True if there is another Quantity to explore, False otherwise.

  • NextQuantity(): void

    Sets the next Quantity current.

  • Returns the name of the current Quantity.

  • MoreUnit(): boolean

    Returns True if there is another Unit to explore, False otherwise.

  • NextUnit(): void

    Sets the next Unit current.

  • Returns the name of the current unit.

  • IsActive(): boolean

    If the units system to explore is a user system, returns True if the current unit is active, False otherwise.
    If the units system to explore is the units dictionary, returns True if the current unit is the S.I. unit.

Units_Lexicon

This class defines a lexicon useful to analyse and recognize the different key words included in a sentence. The lexicon is stored in a sequence of tokens.

Constructors(1)

Static methods(2)

Instance methods(5)

  • Creates(): void

    Reads the file <afilename> to create a sequence of tokens stored in <thesequenceoftokens>.

  • Returns the first item of the sequence of tokens.

  • AddToken(aword: string, amean: string, avalue: number): void

    Adds to the lexicon a new token with <aword>, <amean>, <avalue> as arguments. If there is already a token with the field <theword> equal to <aword>, the existing token is updated.

    Parameters (3)
    • aword
    • amean
    • avalue
  • Dump(): void

    Useful for debugging.

Units_MathSentence

This class defines all the methods to create and compute an algebraic formula.

Constructors(1)

  • Creates and returns a MathSentence object. The string <astring> describes an algebraic formula in natural language.

    Parameters (1)
    • astring

Units_Measurement

This class defines a measurement which is the association of a real value and a unit.

Constructors(3)

  • It is the empty constructor of the class.

  • constructor(avalue: number, atoken: Units_Token): Units_Measurement

    Returns an instance of this class. <avalue> defines the measurement, and <atoken> the token which defines the unit used.

    Parameters (2)
    • avalue
    • atoken
  • constructor(avalue: number, aunit: string): Units_Measurement

    Returns an instance of this class. <avalue> defines the measurement, and <aunit> the unit used, described in natural language.

    Parameters (2)
    • avalue
    • aunit

Instance methods(14)

  • Convert(aunit: string): void

    Converts (if possible) the measurement object into another unit. <aunit> must have the same dimensionality as the unit contained in the token <thetoken>.

    Parameters (1)
    • aunit
  • Returns a Measurement object with the integer value of the measurement contained in <me>.

  • Returns a Measurement object with the fractional value of the measurement contained in <me>.

  • Measurement(): number

    Returns the value of the measurement.

  • Returns the token contained in <me>.

  • Returns (if it is possible) a measurement which is the addition of <me> and <ameasurement>. The chosen returned unit is the unit of <me>.

    Parameters (1)
    • ameasurement
  • Returns (if it is possible) a measurement which is the subtraction of <me> and <ameasurement>. The chosen returned unit is the unit of <me>.

    Parameters (1)
    • ameasurement
  • Returns a measurement which is the multiplication of <me> and <ameasurement>.

    Parameters (1)
    • ameasurement
  • Multiply(avalue: number): Units_Measurement

    Returns a measurement which is the multiplication of <me> with the value <avalue>.

    Parameters (1)
    • avalue
  • Returns a measurement which is the division of <me> by <ameasurement>.

    Parameters (1)
    • ameasurement
  • Divide(avalue: number): Units_Measurement

    Returns a measurement which is the division of <me> by the constant <avalue>.

    Parameters (1)
    • avalue
  • Power(anexponent: number): Units_Measurement

    Returns a measurement which is <me> powered <anexponent>.

    Parameters (1)
    • anexponent
  • HasToken(): boolean
  • Dump(): void

    Useful for debugging.

Units_Quantity

This class stores in its field all the possible units of all the unit systems for a given physical quantity. Each unit's value is expressed in the S.I. unit system.

Constructors(1)

Static methods(2)

Instance methods(6)

Units_Sentence

This class describes all the methods to create and compute an expression contained in a string.

Constructors(1)

  • constructor(alexicon: Units_Lexicon, astring: string): Units_Sentence

    Createsand returns a Sentence, by analyzing the string <astring> with the lexicon <alexicon>.

    Parameters (2)
    • alexicon
    • astring

Instance methods(6)

Units_ShiftedToken

The ShiftedToken class inherits from Token and describes tokens which have a gap in addition of the multiplicative factor. This kind of token allows the description of linear functions which do not pass through the origin, of the form:
y = ax +b
where <x> and <y> are the unknown variables, the mutiplicative factor, and the gap relative to the ordinate axis.
An example is the translation between the Celsius and Fahrenheit degree of temperature.

Constructors(1)

  • constructor(aword: string, amean: string, avalue: number, amove: number, adimensions: Units_Dimensions): Units_ShiftedToken

    Creates and returns a shifted token. <aword> is a string containing the available word, <amean> gives the signification of the token, <avalue> is the numeric value of the dimension, <amove> is the gap, and <adimensions> is the dimension of the given word <aword>.

    Parameters (5)
    • aword
    • amean
    • avalue
    • amove
    • adimensions

Static methods(2)

Instance methods(6)

  • Creates and returns a token, which is a ShiftedToken.

  • Move(): number

    Returns the gap <themove>.

  • Multiplied(avalue: number): number

    This virtual method is called by the Measurement methods, to compute the measurement during a conversion.

    Parameters (1)
    • avalue
  • Divided(avalue: number): number

    This virtual method is called by the Measurement methods, to compute the measurement during a conversion.

    Parameters (1)
    • avalue
  • Dump(ashift: number, alevel: number): void

    Useful for debugging.

    Parameters (2)
    • ashift
    • alevel

Units_ShiftedUnit

This class is useful to describe units with a shifted origin in relation to another unit. A well known example is the Celsius degrees in relation to Kelvin degrees. The shift of the Celsius origin is 273.15 Kelvin degrees.

Constructors(3)

  • Creates and returns a unit. <aname> is the name of the unit.

    Parameters (1)
    • aname
  • constructor(aname: string, asymbol: string): Units_ShiftedUnit

    Creates and returns a unit. <aname> is the name of the unit, <asymbol> is the usual abbreviation of the unit.

    Parameters (2)
    • aname
    • asymbol
  • constructor(aname: string, asymbol: string, avalue: number, amove: number, aquantity: Units_Quantity): Units_ShiftedUnit

    Creates and returns a shifted unit. <aname> is the name of the unit, <asymbol> is the usual abbreviation of the unit, <avalue> is the value in relation to the International System of Units, and <amove> is the gap in relation to another unit.
    For example Celsius degree of temperature is an instance of ShiftedUnit with <avalue> equal to 1. and <amove> equal to 273.15.

    Parameters (5)
    • aname
    • asymbol
    • avalue
    • amove
    • aquantity

Static methods(2)

Instance methods(5)

  • Move(amove: number): void

    Sets the field <themove> to <amove>.

    Parameters (1)
    • amove
  • Move(): number

    Returns the shifted value <themove>.

  • This redefined method returns a ShiftedToken object.

  • Dump(ashift: number, alevel: number): void

    Useful for debugging.

    Parameters (2)
    • ashift
    • alevel

Units_Token

This class defines an elementary word contained in a Sentence object.

Constructors(6)

  • Creates and returns a empty token.

  • constructor(aword: string): Units_Token

    Creates and returns a token. <aword> is a string containing the available word.

    Parameters (1)
    • aword
  • Creates and returns a token. <atoken> is copied in the returned token.

    Parameters (1)
    • atoken
  • constructor(aword: string, amean: string): Units_Token

    Creates and returns a token. <aword> is a string containing the available word and <amean> gives the signification of the token.

    Parameters (2)
    • aword
    • amean
  • constructor(aword: string, amean: string, avalue: number): Units_Token

    Creates and returns a token. <aword> is a string containing the available word, <amean> gives the signification of the token and <avalue> is the numeric value of the dimension.

    Parameters (3)
    • aword
    • amean
    • avalue
  • constructor(aword: string, amean: string, avalue: number, adimension: Units_Dimensions): Units_Token

    Creates and returns a token. <aword> is a string containing the available word, <amean> gives the signification of the token, <avalue> is the numeric value of the dimension, and <adimensions> is the dimension of the given word <aword>.

    Parameters (4)
    • aword
    • amean
    • avalue
    • adimension

Static methods(2)

Instance methods(30)

  • Creates and returns a token, which is a ShiftedToken.

  • Length(): number

    Returns the length of the word.

  • Returns the string <theword>.

  • Word(aword: string): void

    Sets the field <theword> to <aword>.

    Parameters (1)
    • aword
  • Returns the significance of the word <theword>, which is in the field <themean>.

  • Mean(amean: string): void

    Sets the field <themean> to <amean>.

    Parameters (1)
    • amean
  • Value(): number

    Returns the value stored in the field <thevalue>.

  • Value(avalue: number): void

    Sets the field <thevalue> to <avalue>.

    Parameters (1)
    • avalue
  • Returns the dimensions of the token <thedimensions>.

  • Dimensions(adimensions: Units_Dimensions): void

    Sets the field <thedimensions> to <adimensions>.

    Parameters (1)
    • adimensions
  • Update(amean: string): void

    Updates the token <me> with the additional signification <amean> by concatenation of the two strings <themean> and <amean>. If the two significations are the same, an information message is written in the output device.

    Parameters (1)
    • amean
  • Add(aninteger: number): Units_Token
    Parameters (1)
    • aninteger
  • Returns a token which is the addition of <me> and another token <atoken>. The addition is possible if and only if the dimensions are the same.

    Parameters (1)
    • atoken
  • Returns a token which is the subtraction of <me> and another token <atoken>. The subtraction is possible if and only if the dimensions are the same.

    Parameters (1)
    • atoken
  • Returns a token which is the product of <me> and another token <atoken>.

    Parameters (1)
    • atoken
  • Multiplied(avalue: number): number

    This virtual method is called by the Measurement methods, to compute the measurement during a conversion.

    Parameters (1)
    • avalue
  • Returns a token which is the division of <me> by another token <atoken>.

    Parameters (1)
    • atoken
  • Divided(avalue: number): number

    This virtual method is called by the Measurement methods, to compute the measurement during a conversion.

    Parameters (1)
    • avalue
  • Returns a token which is <me> to the power of another token <atoken>. The computation is possible only if <atoken> is a dimensionless constant.

    Parameters (1)
    • atoken
  • Power(anexponent: number): Units_Token

    Returns a token which is <me> to the power of <anexponent>.

    Parameters (1)
    • anexponent
  • IsEqual(astring: string): boolean

    Returns true if the field <theword> and the string <astring> are the same, false otherwise.

    Parameters (1)
    • astring
  • IsEqual(atoken: Units_Token): boolean

    Returns true if the field <theword> and the string <theword> contained in the token <atoken> are the same, false otherwise.

    Parameters (1)
    • atoken
  • IsNotEqual(astring: string): boolean

    Returns false if the field <theword> and the string <astring> are the same, true otherwise.

    Parameters (1)
    • astring
  • IsNotEqual(atoken: Units_Token): boolean

    Returns false if the field <theword> and the string <theword> contained in the token <atoken> are the same, true otherwise.

    Parameters (1)
    • atoken
  • IsLessOrEqual(astring: string): boolean

    Returns true if the field <theword> is strictly contained at the beginning of the string <astring>, false otherwise.

    Parameters (1)
    • astring
  • IsGreater(astring: string): boolean

    Returns false if the field <theword> is strictly contained at the beginning of the string <astring>, true otherwise.

    Parameters (1)
    • astring
  • IsGreater(atoken: Units_Token): boolean

    Returns false if the field <theword> is strictly contained at the beginning of the string <astring>, true otherwise.

    Parameters (1)
    • atoken
  • IsGreaterOrEqual(atoken: Units_Token): boolean

    Returns true if the string <astring> is strictly contained at the beginning of the field <theword> false otherwise.

    Parameters (1)
    • atoken
  • Dump(ashift: number, alevel: number): void

    Useful for debugging.

    Parameters (2)
    • ashift
    • alevel

Units_Unit

This class defines an elementary word contained in a physical quantity.

Constructors(3)

  • constructor(aname: string): Units_Unit

    Creates and returns a unit. <aname> is the name of the unit.

    Parameters (1)
    • aname
  • constructor(aname: string, asymbol: string): Units_Unit

    Creates and returns a unit. <aname> is the name of the unit, <asymbol> is the usual abbreviation of the unit.

    Parameters (2)
    • aname
    • asymbol
  • constructor(aname: string, asymbol: string, avalue: number, aquantity: Units_Quantity): Units_Unit

    Creates and returns a unit. <aname> is the name of the unit, <asymbol> is the usual abbreviation of the unit, and <avalue> is the value in relation to the International System of Units.

    Parameters (4)
    • aname
    • asymbol
    • avalue
    • aquantity

Static methods(2)

Instance methods(11)

Units_UnitsDictionary

This class creates a dictionary of all the units you want to know.

Constructors(1)

Static methods(2)

Instance methods(6)

  • Creates(): void

    Returns a UnitsDictionary object which contains the sequence of all the units you want to consider, physical quantity by physical quantity.

  • Returns the head of the sequence of physical quantities.

  • Returns for <aquantity> the active unit.

    Parameters (1)
    • aquantity
  • Dump(alevel: number): void

    Dumps only the sequence of quantities without the units if <alevel> is equal to zero, and for each quantity all the units stored if <alevel> is equal to one.

    Parameters (1)
    • alevel
  • Dump(adimensions: Units_Dimensions): void

    Dumps for a designated physical dimensions <adimensions> all the previously stored units.

    Parameters (1)
    • adimensions

Units_UnitSentence

This class describes all the facilities to manipulate and compute units contained in a string expression.

Constructors(2)

  • Creates and returns a UnitSentence. The string <astring> describes in natural language the unit or the composed unit to be analysed.

    Parameters (1)
    • astring
  • Creates and returns a UnitSentence. The string <astring> describes in natural language the unit to be analysed. The sequence of physical quantities <asequenceofquantities> describes the available dictionary of units you want to use.

    Parameters (2)
    • astring
    • aquantitiessequence

Instance methods(2)

  • Analyse(): void

    Analyzes the sequence of tokens created by the constructor to find the true significance of each token.

  • For each token which represents a unit, finds in the sequence of physical quantities all the characteristics of the unit found.

    Parameters (1)
    • aquantitiessequence

Units_UnitsLexicon

This class defines a lexicon useful to analyse and recognize the different key words included in a sentence. The lexicon is stored in a sequence of tokens.

Constructors(1)

Static methods(2)

Instance methods(4)

  • Creates(amode?: boolean): void

    Reads the files <afilename1> and <afilename2> to create a sequence of tokens stored in <thesequenceoftokens>.

    Parameters (1)
    • amode
  • Creates(): void

    Reads the files <afilename1> and <afilename2> to create a sequence of tokens stored in <thesequenceoftokens>.

  • Dump(): void

    Useful for debugging.

Units_UnitsSystem

This class allows the user to define his own system of units.

Constructors(2)

  • Returns an instance of UnitsSystem initialized to the S.I. units system.

  • constructor(aName: string, Verbose?: boolean): Units_UnitsSystem

    Returns an instance of UnitsSystem initialized to the S.I. units system upgraded by the base system units description file. Attempts to find the four following files: $CSF_aNameDefaults/.aName $CSF_aNameSiteDefaults/.aName $CSF_aNameGroupDefaults/.aName $CSF_aNameUserDefaults/.aName See : Resource_Manager for the description of this file.

    Parameters (2)
    • aName
    • Verbose

Static methods(2)

Instance methods(13)

  • Returns the sequence of refined quantities.

  • Returns a sequence of integer in correspondence with the sequence of quantities, which indicates, for each redefined quantity, the index into the sequence of units, of the active unit.

  • Specify(aquantity: string, aunit: string): void

    Specifies for <aquantity> the unit <aunit> used.

    Parameters (2)
    • aquantity
    • aunit
  • Remove(aquantity: string, aunit: string): void

    Removes for <aquantity> the unit <aunit> used.

    Parameters (2)
    • aquantity
    • aunit
  • Activate(aquantity: string, aunit: string): void

    Specifies for <aquantity> the unit <aunit> used.

    Parameters (2)
    • aquantity
    • aunit
  • Activates(): void

    Activates the first unit of all defined system quantities.

  • Returns for <aquantity> the active unit.

    Parameters (1)
    • aquantity
  • ConvertValueToUserSystem(aquantity: string, avalue: number, aunit: string): number

    Converts a real value <avalue> from the unit <aunit> belonging to the physical dimensions <aquantity> to the corresponding unit of the user system.

    Parameters (3)
    • aquantity
    • avalue
    • aunit
  • ConvertSIValueToUserSystem(aquantity: string, avalue: number): number

    Converts the real value <avalue> from the S.I. system of units to the user system of units. <aquantity> is the physical dimensions of the measurement.

    Parameters (2)
    • aquantity
    • avalue
  • ConvertUserSystemValueToSI(aquantity: string, avalue: number): number

    Converts the real value <avalue> from the user system of units to the S.I. system of units. <aquantity> is the physical dimensions of the measurement.

    Parameters (2)
    • aquantity
    • avalue
  • Dump(): void
  • IsEmpty(): boolean

    Returns TRUE if no units has been defined in the system.