OCC.Quantity module¶
The Quantities component deals withmathematical and physical quantities.A mathematical quantity is characterized by its value. It is a real value.A physical quantity is characterized by:- its value, which is also a real value, and- the unit in which it is expressed. This unit maybe either an international unit complying withthe International Unit System (SI) or a userdefined unit. The unit is managed by thephysical quantity user.Each mathematical or physical quantity isdescribed by its name. This ensures distinctionbetween two different quantities.Moreover, both physical and mathematicalquantities are also manipulated as real values:- They are defined as aliases of reals, so allfunctions provided by the Standard_Realclass are available on each quantity.- You may also mix several physical quantitiesin a mathematical or physical formula involving real values.Associated with the physical quantities, a rangeof functions provides tools to manage unit conversions.The physical quantities described in this chapterare commonly used basic physical quantities.Nevertheless, the Quantity package includes allphysical quantities you may require.The Quantities component also providesresources to manage time information (dates andperiods) and color definition.
-
class
Handle_Quantity_HArray1OfColor
(*args)¶ Bases:
OCC.MMgt.Handle_MMgt_TShared
-
static
DownCast
()¶
-
GetObject
()¶
-
IsNull
()¶
-
Nullify
()¶
-
thisown
¶ The membership flag
-
static
-
class
Quantity_Array1OfCoefficient
(*args)¶ Bases:
object
Parameters: Return type: Return type: -
Assign
()¶ Parameters: Other (Quantity_Array1OfCoefficient &) – Return type: Quantity_Array1OfCoefficient
-
Set
()¶ Parameters: Other (Quantity_Array1OfCoefficient &) – Return type: Quantity_Array1OfCoefficient
-
thisown
¶ The membership flag
-
-
class
Quantity_Array1OfColor
(*args)¶ Bases:
object
Parameters: Return type: Return type: -
Assign
()¶ Parameters: Other (Quantity_Array1OfColor &) – Return type: Quantity_Array1OfColor
-
ChangeValue
()¶ Parameters: Index (int) – Return type: Quantity_Color
-
Set
()¶ Parameters: Other (Quantity_Array1OfColor &) – Return type: Quantity_Array1OfColor
-
Value
()¶ Parameters: Index (int) – Return type: Quantity_Color
-
thisown
¶ The membership flag
-
-
class
Quantity_Array2OfColor
(*args)¶ Bases:
object
Parameters: Return type: Return type: -
Assign
()¶ Parameters: Other (Quantity_Array2OfColor &) – Return type: Quantity_Array2OfColor
-
ChangeValue
()¶ Parameters: Return type:
-
Set
()¶ Parameters: Other (Quantity_Array2OfColor &) – Return type: Quantity_Array2OfColor
-
Value
()¶ Parameters: Return type:
-
thisown
¶ The membership flag
-
-
class
Quantity_Color
(*args)¶ Bases:
object
- Creates a colour with the default value of Colour name : YELLOW
Return type: None - Creates the colour <AName>.
Parameters: AName (Quantity_NameOfColor) – Return type: None - Creates a colour according to the definition system TypeOfColor. TOC_RGB : <R1> the value of red between 0. and 1. <R2> the value of green between 0. and 1. <R3> the value of blue between 0. and 1. //! TOC_HLS : <R1> is the hue angle in degrees, 0. being red <R2> is the lightness between 0. and 1. <R3> is the saturation between 0. and 1.
Parameters: - R1 (Quantity_Parameter) –
- R2 (Quantity_Parameter) –
- R3 (Quantity_Parameter) –
- AType (Quantity_TypeOfColor) –
Return type: -
static
Argb2color
()¶ - Convert integer ARGB value to Color. Alpha bits are ignored
Parameters: - theARGB (int) –
- theColor (Quantity_Color &) –
Return type: void
-
Assign
()¶ - Updates the colour <self> from the definition of the colour <Other>.
Parameters: Other (Quantity_Color &) – Return type: Quantity_Color
-
Blue
()¶ - Returns the Blue component (quantity of blue) of the color <self>.
Return type: Quantity_Parameter
-
ChangeContrast
()¶ - Increases or decreases the contrast by <ADelta>. <ADelta> is a percentage. Any value greater than zero will increase the contrast. The variation is expressed as a percentage of the current value. It is a variation of the saturation.
Parameters: ADelta (Quantity_Rate) – Return type: None
-
ChangeIntensity
()¶ - Increases or decreases the intensity by <ADelta>. <ADelta> is a percentage. Any value greater than zero will increase the intensity. The variation is expressed as a percentage of the current value. It is a variation of the lightness.
Parameters: ADelta (Quantity_Rate) – Return type: None
-
static
Color2argb
()¶ - Convert the Color value to ARGB integer value. theARGB has Alpha equal to zero, so the output is formatted as 0x00RRGGBB
Parameters: - theColor (Quantity_Color &) –
- theARGB (int &) –
Return type: void
-
static
ColorFromName
()¶ - Finds color from predefined names. For example, the name of the color which corresponds to ‘BLACK’ is Quantity_NOC_BLACK. Returns false if name is unknown.
Parameters: - theName (char *) –
- theColor (Quantity_NameOfColor &) –
Return type:
-
Delta
()¶ - Returns the percentage change of contrast and intensity between <self> and <AColor>. <DC> and <DI> are percentages, either positive or negative. The calculation is with respect to the current value of <self> If <DC> is positive then <self> is more contrasty. If <DI> is positive then <self> is more intense.
Parameters: - AColor (Quantity_Color &) –
- DC (Quantity_Parameter &) –
- DI (Quantity_Parameter &) –
Return type:
-
Distance
()¶ - Returns the distance between two colours. It’s a value between 0 and the square root of 3 (the black/white distance)
Parameters: AColor (Quantity_Color &) – Return type: float
-
static
Epsilon
()¶ - Returns the specified value used to compare <self> and an other color in IsDifferent and in IsEqual methods.
Return type: Quantity_Parameter
-
Green
()¶ - Returns the Green component (quantity of green) of the color <self>.
Return type: Quantity_Parameter
-
static
HlsRgb
()¶ - Converts HLS components into RGB ones.
Parameters: - H (Quantity_Parameter) –
- L (Quantity_Parameter) –
- S (Quantity_Parameter) –
- R (Quantity_Parameter &) –
- G (Quantity_Parameter &) –
- B (Quantity_Parameter &) –
Return type: void
-
Hue
()¶ - Returns the Hue component (hue angle) of the color <self>.
Return type: Quantity_Parameter
-
IsDifferent
()¶ - Returns Standard_True if the distance between <self> and <Other> is greater than Epsilon ().
Parameters: Other (Quantity_Color &) – Return type: bool
-
IsEqual
()¶ - Returns true if the Other color is - different from, or - equal to this color. Two colors are considered to be equal if their distance is no greater than Epsilon(). These methods are aliases of operator != and operator ==.
Parameters: Other (Quantity_Color &) – Return type: bool
-
Light
()¶ - Returns the Light component (value of the lightness) of the color <self>.
Return type: Quantity_Parameter
-
static
Name
()¶ - Returns the name of the color defined by its quantities of red R, green G and blue B; more precisely this is the nearest color from the Quantity_NameOfColor enumeration. Exceptions Standard_OutOfRange if R, G or B is less than 0. or greater than 1.
Return type: Quantity_NameOfColor - Returns the name of the colour for which the RGB components are nearest to <R>, <G> and <B>.
Parameters: - R (Quantity_Parameter) –
- G (Quantity_Parameter) –
- B (Quantity_Parameter) –
Return type: Quantity_NameOfColor
-
Red
()¶ - Returns the Red component (quantity of red) of the color <self>.
Return type: Quantity_Parameter
-
static
RgbHls
()¶ - Converts RGB components into HLS ones.
Parameters: - R (Quantity_Parameter) –
- G (Quantity_Parameter) –
- B (Quantity_Parameter) –
- H (Quantity_Parameter &) –
- L (Quantity_Parameter &) –
- S (Quantity_Parameter &) –
Return type: void
-
Saturation
()¶ - Returns the Saturation component (value of the saturation) of the color <self>.
Return type: Quantity_Parameter
-
Set
()¶ Parameters: Other (Quantity_Color &) – Return type: Quantity_Color
-
static
SetEpsilon
()¶ - Sets the specified value used to compare <self> and an other color in IsDifferent and in IsEqual methods. Warning: The default value is 0.0001
Parameters: AnEpsilon (Quantity_Parameter) – Return type: void
-
SetValues
()¶ - Updates the colour <self> from the definition of the colour <AName>.
Parameters: AName (Quantity_NameOfColor) – Return type: None - Updates a colour according to the mode specified by TypeOfColor TOC_RGB : <R1> the value of red between 0. and 1. <R2> the value of green between 0. and 1. <R3> the value of blue between 0. and 1. //! TOC_HLS : <R1> is the hue angle in degrees, 0. being red <R2> is the lightness between 0. and 1. <R3> is the saturation between 0. and 1.
Parameters: - R1 (Quantity_Parameter) –
- R2 (Quantity_Parameter) –
- R3 (Quantity_Parameter) –
- AType (Quantity_TypeOfColor) –
Return type:
-
SquareDistance
()¶ - Returns the square of distance between two colours.
Parameters: AColor (Quantity_Color &) – Return type: float
-
static
StringName
()¶ - Returns the name of the color identified by AName in the Quantity_NameOfColor enumeration. For example, the name of the color which corresponds to Quantity_NOC_BLACK is ‘BLACK’. Exceptions Standard_OutOfRange if AName in not known in the Quantity_NameOfColor enumeration.
Parameters: AColor (Quantity_NameOfColor) – Return type: char *
-
static
Test
()¶ - Internal test
Return type: void
-
Values
()¶ - Returns in R1, R2 and R3 the components of this color according to the color system definition AType. - if AType is Quantity_TOC_RGB R1 is the quantity of red, R2 is the quantity of green and R3 is the quantity of blue in this color. - if AType is Quantity_TOC_HLS R1 is the hue angle in degrees (0 being red), R2 is the lightness and R3 is the saturation of this color.
Parameters: - R1 (Quantity_Parameter &) –
- R2 (Quantity_Parameter &) –
- R3 (Quantity_Parameter &) –
- AType (Quantity_TypeOfColor) –
Return type:
-
thisown
¶ The membership flag
-
Quantity_Color_Argb2color
()¶ - Convert integer ARGB value to Color. Alpha bits are ignored
Parameters: - theARGB (int) –
- theColor (Quantity_Color &) –
Return type: void
-
Quantity_Color_Color2argb
()¶ - Convert the Color value to ARGB integer value. theARGB has Alpha equal to zero, so the output is formatted as 0x00RRGGBB
Parameters: - theColor (Quantity_Color &) –
- theARGB (int &) –
Return type: void
-
Quantity_Color_ColorFromName
()¶ - Finds color from predefined names. For example, the name of the color which corresponds to ‘BLACK’ is Quantity_NOC_BLACK. Returns false if name is unknown.
Parameters: - theName (char *) –
- theColor (Quantity_NameOfColor &) –
Return type:
-
Quantity_Color_Epsilon
()¶ - Returns the specified value used to compare <self> and an other color in IsDifferent and in IsEqual methods.
Return type: Quantity_Parameter
-
Quantity_Color_HlsRgb
()¶ - Converts HLS components into RGB ones.
Parameters: - H (Quantity_Parameter) –
- L (Quantity_Parameter) –
- S (Quantity_Parameter) –
- R (Quantity_Parameter &) –
- G (Quantity_Parameter &) –
- B (Quantity_Parameter &) –
Return type: void
-
Quantity_Color_Name
()¶ - Returns the name of the color defined by its quantities of red R, green G and blue B; more precisely this is the nearest color from the Quantity_NameOfColor enumeration. Exceptions Standard_OutOfRange if R, G or B is less than 0. or greater than 1.
Return type: Quantity_NameOfColor - Returns the name of the colour for which the RGB components are nearest to <R>, <G> and <B>.
Parameters: - R (Quantity_Parameter) –
- G (Quantity_Parameter) –
- B (Quantity_Parameter) –
Return type: Quantity_NameOfColor
-
Quantity_Color_RgbHls
()¶ - Converts RGB components into HLS ones.
Parameters: - R (Quantity_Parameter) –
- G (Quantity_Parameter) –
- B (Quantity_Parameter) –
- H (Quantity_Parameter &) –
- L (Quantity_Parameter &) –
- S (Quantity_Parameter &) –
Return type: void
-
Quantity_Color_SetEpsilon
()¶ - Sets the specified value used to compare <self> and an other color in IsDifferent and in IsEqual methods. Warning: The default value is 0.0001
Parameters: AnEpsilon (Quantity_Parameter) – Return type: void
-
Quantity_Color_StringName
()¶ - Returns the name of the color identified by AName in the Quantity_NameOfColor enumeration. For example, the name of the color which corresponds to Quantity_NOC_BLACK is ‘BLACK’. Exceptions Standard_OutOfRange if AName in not known in the Quantity_NameOfColor enumeration.
Parameters: AColor (Quantity_NameOfColor) – Return type: char *
-
Quantity_Color_Test
()¶ - Internal test
Return type: void
-
class
Quantity_Convert
(*args)¶ Bases:
object
- Creates an object;
Return type: None -
static
ConvertSIToUser
()¶ - Converts, from the conversion table, the value <aVal> from the SI system to the user system.
Parameters: - aQuantity (Quantity_PhysicalQuantity) –
- aVal (float) –
Return type:
-
static
ConvertUserToSI
()¶ - Converts, from the conversion table, the value <aVal> from the user system to the SI system.
Parameters: - aQuantity (Quantity_PhysicalQuantity) –
- aVal (float) –
Return type:
-
static
IsPhysicalQuantity
()¶ - if (aType is a physical quantity) returns True and the name of the associated PhysicalQuantity . else returns False.
Parameters: - aTypeName (TCollection_AsciiString &) –
- anEnum (TCollection_AsciiString &) –
Return type:
-
static
SetQuantity
()¶ - Updates the conversion table (correspondances between Quantities and conversion coefficients).
Parameters: - aQuantity (Quantity_PhysicalQuantity) –
- aCoef (Quantity_Coefficient) –
Return type: void
-
thisown
¶ The membership flag
-
Quantity_Convert_ConvertSIToUser
()¶ - Converts, from the conversion table, the value <aVal> from the SI system to the user system.
Parameters: - aQuantity (Quantity_PhysicalQuantity) –
- aVal (float) –
Return type:
-
Quantity_Convert_ConvertUserToSI
()¶ - Converts, from the conversion table, the value <aVal> from the user system to the SI system.
Parameters: - aQuantity (Quantity_PhysicalQuantity) –
- aVal (float) –
Return type:
-
Quantity_Convert_IsPhysicalQuantity
()¶ - if (aType is a physical quantity) returns True and the name of the associated PhysicalQuantity . else returns False.
Parameters: - aTypeName (TCollection_AsciiString &) –
- anEnum (TCollection_AsciiString &) –
Return type:
-
Quantity_Convert_SetQuantity
()¶ - Updates the conversion table (correspondances between Quantities and conversion coefficients).
Parameters: - aQuantity (Quantity_PhysicalQuantity) –
- aCoef (Quantity_Coefficient) –
Return type: void
-
class
Quantity_Date
(*args)¶ Bases:
object
- Constructs a default date (00:00 GMT, January 1, 1979 (zero hour)); use the function SetValues to define the required date; or
Return type: None - Constructs a date from the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0).. With: 1 <= mm <= 12 1 <= dd <= max number of days of <mm> 1979 <= yyyy 0 <= hh <= 23 0 <= mn <= 59 0 <= ss <= 59 0 <= mis <= 999 0 <= mics <= 999 Exceptions Quantity_DateDefinitionError if mm, dd, hh, mn, ss, mis and mics are not the components of the valid date.
Parameters: Return type: -
Add
()¶ - Adds a Period to a Date and returns the new Date.
Parameters: aPeriod (Quantity_Period &) – Return type: Quantity_Date
-
Difference
()¶ - Subtracts one Date from another one to find the period between and returns the value. The result is the absolute value between the difference of two dates.
Parameters: anOther (Quantity_Date &) – Return type: Quantity_Period
-
IsEarlier
()¶ - Returns True if <self> is earlier than <other>.
Parameters: anOther (Quantity_Date &) – Return type: bool
-
IsEqual
()¶ - Returns True if both <self> and <other> are equal. This method is an alias of operator ==.
Parameters: anOther (Quantity_Date &) – Return type: bool
-
IsLater
()¶ - Returns True if <self> is later then <other>.
Parameters: anOther (Quantity_Date &) – Return type: bool
-
static
IsLeap
()¶ - Returns true if a year is a leap year. The leap years are divisable by 4 and not by 100 except the years divisable by 400.
Parameters: yy (int) – Return type: bool
-
static
IsValid
()¶ - Checks the validity of a date - returns true if a date defined from the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0) is valid. A date must satisfy the conditions above: - yyyy is greater than or equal to 1979, - mm lies within the range [1, 12] (with 1 corresponding to January and 12 to December), - dd lies within a valid range for the month mm (from 1 to 28, 29, 30 or 31 depending on mm and whether yyyy is a leap year or not), - hh lies within the range [0, 23], - mn lies within the range [0, 59], - ss lies within the range [0, 59], - mis lies within the range [0, 999], - mics lies within the range [0, 999].C
Parameters: Return type:
-
SetValues
()¶ - Assigns to this date the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0). Exceptions Quantity_DateDefinitionError if mm, dd, hh, mn, ss, mis and mics are not components of a valid date.
Parameters: Return type:
-
Subtract
()¶ - Subtracts a period from a Date and returns the new Date. Raises an exception if the result date is anterior to Jan 1, 1979.
Parameters: aPeriod (Quantity_Period &) – Return type: Quantity_Date
-
Values
()¶ - Gets a complete Date. - in mm - the month, - in dd - the day, - in yyyy - the year, - in hh - the hour, - in mn - the minute, - in ss - the second, - in mis - the millisecond, and - in mics - the microsecond
Parameters: - mm (int &) –
- dd (int &) –
- yy (int &) –
- hh (int &) –
- mn (int &) –
- ss (int &) –
- mis (int &) –
- mics (int &) –
Return type:
-
thisown
¶ The membership flag
-
Quantity_Date_IsLeap
()¶ - Returns true if a year is a leap year. The leap years are divisable by 4 and not by 100 except the years divisable by 400.
Parameters: yy (int) – Return type: bool
-
Quantity_Date_IsValid
()¶ - Checks the validity of a date - returns true if a date defined from the year yyyy, the month mm, the day dd, the hour hh, the minute mn, the second ss, the millisecond mis (defaulted to 0) and the microsecond mics (defaulted to 0) is valid. A date must satisfy the conditions above: - yyyy is greater than or equal to 1979, - mm lies within the range [1, 12] (with 1 corresponding to January and 12 to December), - dd lies within a valid range for the month mm (from 1 to 28, 29, 30 or 31 depending on mm and whether yyyy is a leap year or not), - hh lies within the range [0, 23], - mn lies within the range [0, 59], - ss lies within the range [0, 59], - mis lies within the range [0, 999], - mics lies within the range [0, 999].C
Parameters: Return type:
-
class
Quantity_HArray1OfColor
(*args)¶ Bases:
OCC.MMgt.MMgt_TShared
Parameters: Return type: Return type: -
Array1
()¶ Return type: Quantity_Array1OfColor
-
ChangeArray1
()¶ Return type: Quantity_Array1OfColor
-
ChangeValue
()¶ Parameters: Index (int) – Return type: Quantity_Color
-
GetHandle
()¶
-
Value
()¶ Parameters: Index (int) – Return type: Quantity_Color
-
thisown
¶ The membership flag
-
-
class
Quantity_Period
(*args)¶ Bases:
object
- Creates a Period With: 0 <= dd 0 <= hh 0 <= mn 0 <= ss 0 <= mis 0 <= mics
Parameters: Return type: - Creates a Period with a number of seconds and microseconds. Exceptions Quantity_PeriodDefinitionError: - if the number of seconds expressed either by: - dd days, hh hours, mn minutes and ss seconds, or - Ss is less than 0. - if the number of microseconds expressed either by: - mis milliseconds and mics microseconds, or - Mics is less than 0.
Parameters: Return type: Return type: -
Add
()¶ - Adds one Period to another one.
Parameters: anOther (Quantity_Period &) – Return type: Quantity_Period
-
IsEqual
()¶ - Returns True if both <self> and <other> are equal.
Parameters: anOther (Quantity_Period &) – Return type: bool
-
IsLonger
()¶ - Returns True if <self> is longer then <other>.
Parameters: anOther (Quantity_Period &) – Return type: bool
-
IsShorter
()¶ - Returns True if <self> is shorter than <other>.
Parameters: anOther (Quantity_Period &) – Return type: bool
-
static
IsValid
()¶ - Checks the validity of a Period in form (dd,hh,mn,ss,mil,mic) With: 0 <= dd 0 <= hh 0 <= mn 0 <= ss 0 <= mis 0 <= mics
Parameters: Return type: - Checks the validity of a Period in form (ss,mic) With: 0 <= ss 0 <= mics
Parameters: Return type:
-
SetValues
()¶ - Assigns to this period the time interval defined - with dd days, hh hours, mn minutes, ss seconds, mis (defaulted to 0) milliseconds and mics (defaulted to 0) microseconds; or
Parameters: Return type: - Assigns to this period the time interval defined - with Ss seconds and Mics (defaulted to 0) microseconds. Exceptions Quantity_PeriodDefinitionError: - if the number of seconds expressed either by: - dd days, hh hours, mn minutes and ss seconds, or - Ss is less than 0. - if the number of microseconds expressed either by: - mis milliseconds and mics microseconds, or - Mics is less than 0.
Parameters: Return type:
-
Subtract
()¶ - Subtracts one Period from another and returns the difference.
Parameters: anOther (Quantity_Period &) – Return type: Quantity_Period
-
Values
()¶ - Decomposes this period into a number of days,hours, minutes,seconds,milliseconds and microseconds Example of return values: 2 days, 15 hours, 0 minute , 0 second 0 millisecond and 0 microsecond
Parameters: - dd (int &) –
- hh (int &) –
- mn (int &) –
- ss (int &) –
- mis (int &) –
- mics (int &) –
Return type: - Returns the number of seconds in Ss and the number of remainding microseconds in Mics of this period. Example of return values: 3600 seconds and 0 microseconds
Parameters: - ss (int &) –
- mics (int &) –
Return type:
-
thisown
¶ The membership flag
-
Quantity_Period_IsValid
()¶ - Checks the validity of a Period in form (dd,hh,mn,ss,mil,mic) With: 0 <= dd 0 <= hh 0 <= mn 0 <= ss 0 <= mis 0 <= mics
Parameters: Return type: - Checks the validity of a Period in form (ss,mic) With: 0 <= ss 0 <= mics
Parameters: Return type:
-
class
SwigPyIterator
(*args, **kwargs)¶ Bases:
object
-
advance
()¶
-
copy
()¶
-
decr
()¶
-
distance
()¶
-
equal
()¶
-
incr
()¶
-
next
()¶
-
previous
()¶
-
thisown
¶ The membership flag
-
value
()¶
-
-
new_instancemethod
(func, inst, cls)¶
-
register_handle
(handle, base_object)¶ Inserts the handle into the base object to prevent memory corruption in certain cases