1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

2
src/Quantity/FILES Executable file
View File

@@ -0,0 +1,2 @@
Quantity_Color_1.hxx
Quantity_Period.lxx

1301
src/Quantity/Quantity.cdl Executable file

File diff suppressed because it is too large Load Diff

353
src/Quantity/Quantity_Color.cdl Executable file
View File

@@ -0,0 +1,353 @@
--
-- File: Quantity_Color.cdl
-- Created: Jeudi 22 Aout 1991
-- Author: NW,JPB,CAL
--
---Copyright: MatraDatavision 1991,1992
--
class Color from Quantity
inherits Storable
---Purpose: This class allows the definition of a colour.
-- The names of the colours are from the X11 specification.
-- color object may be used for numerous applicative purposes.
-- A color is defined by:
-- - its respective quantities of red, green and blue (R-G-B values), or
-- - its hue angle and its values of lightness and saturation (H-L-S values).
-- These two color definition systems are equivalent.
-- Use this class in conjunction with:
-- - the Quantity_TypeOfColor enumeration
-- which identifies the color definition system you are using,
-- - the Quantity_NameOfColor enumeration
-- which lists numerous predefined colors and
-- identifies them by their name.
uses
NameOfColor from Quantity,
Parameter from Quantity,
Rate from Quantity,
TypeOfColor from Quantity
raises
ColorDefinitionError from Quantity
is
Create
returns Color
---Purpose: Creates a colour with the default value of
-- Colour name : YELLOW
--
raises ColorDefinitionError from Quantity;
-- if the maximum number of colours is exceeded
Create ( AName : NameOfColor from Quantity )
returns Color
---Purpose: Creates the colour <AName>.
--
raises ColorDefinitionError from Quantity;
-- if the given name is unknown or the maximum number
-- of colours is exceeded
Create ( R1, R2, R3 : Parameter from Quantity;
AType : TypeOfColor from Quantity )
returns Color
---Purpose: 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.
--
raises ColorDefinitionError from Quantity;
-- if the values are not in the allowed interval or
-- maximum number of colours is exceeded.
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
Assign ( me : in out;
Other : Color from Quantity )
returns Color from Quantity is static;
---Purpose: Updates the colour <me> from the definition of the
-- colour <Other>.
---Category: Methods to modify the class definition
---C++: alias operator =
---C++: return &
ChangeContrast ( me : in out;
ADelta : Rate from Quantity ) is static;
---Purpose: 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.
ChangeIntensity ( me : in out;
ADelta : Rate from Quantity ) is static;
---Purpose: 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.
SetValues ( me : in out;
AName : NameOfColor from Quantity ) is static;
---Purpose: Updates the colour <me> from the definition of the
-- colour <AName>.
---Category: Methods to modify the class definition
SetValues ( me : in out;
R1, R2, R3 : Parameter from Quantity;
AType : TypeOfColor from Quantity )
---Purpose: 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.
--
raises ColorDefinitionError from Quantity is static;
-- if the values do not fall in the allowed interval
---Category: Methods to modify the class definition
------------------------------------------
-- Category: Methods to compare two colors
------------------------------------------
Delta ( me;
AColor : Color from Quantity;
DC, DI : out Parameter from Quantity ) is static;
---Purpose: Returns the percentage change of contrast and intensity
-- between <me> and <AColor>.
-- <DC> and <DI> are percentages, either positive or negative.
-- The calculation is with respect to the current value of <me>
-- If <DC> is positive then <me> is more contrasty.
-- If <DI> is positive then <me> is more intense.
---Category: Methods to compare two colors
Distance ( me;
AColor : Color from Quantity )
returns Real from Standard is static;
---Purpose: Returns the distance between two colours. It's a
-- value between 0 and the square root of 3
-- (the black/white distance)
---Category: Methods to compare two colors
SquareDistance ( me;
AColor : Color from Quantity )
returns Real from Standard is static;
---Purpose: Returns the square of distance between two colours.
---Category: Methods to compare two colors
----------------------------
-- Category: Inquire methods
----------------------------
Blue ( me )
returns Parameter from Quantity is static;
---Purpose: Returns the Blue component (quantity of blue) of the
-- color <me>.
---Category: Inquire methods
Green ( me )
returns Parameter from Quantity is static;
---Purpose: Returns the Green component (quantity of green) of the
-- color <me>.
---Category: Inquire methods
Hue ( me )
returns Parameter from Quantity is static;
---Purpose: Returns the Hue component (hue angle) of the
-- color <me>.
---Category: Inquire methods
IsDifferent ( me;
Other : Color from Quantity )
returns Boolean from Standard is static;
---Purpose: Returns Standard_True if the distance between <me> and
-- <Other> is greater than Epsilon ().
---Category: Inquire methods
---C++: alias operator !=
IsEqual ( me;
Other : Color from Quantity )
returns Boolean from Standard is static;
---Purpose: 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 ==.
---C++: alias operator ==
Light ( me )
returns Parameter from Quantity is static;
---Purpose: Returns the Light component (value of the lightness) of the
-- color <me>.
---Category: Inquire methods
Name ( me )
returns NameOfColor from Quantity is static;
---Purpose: 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.
Red ( me )
returns Parameter from Quantity is static;
---Purpose: Returns the Red component (quantity of red) of the
-- color <me>.
---Category: Inquire methods
Saturation ( me )
returns Parameter from Quantity is static;
---Purpose: Returns the Saturation component (value of the saturation)
-- of the color <me>.
---Category: Inquire methods
Values ( me;
R1, R2, R3 : out Parameter from Quantity;
AType : TypeOfColor from Quantity )
---Purpose: 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.
--Exception
-- Raises ColorDefinitionError if the values are not in the allowed interval
raises ColorDefinitionError from Quantity is static;
--------------------------
-- Category: Class methods
--------------------------
SetEpsilon ( myclass;
AnEpsilon : Parameter from Quantity );
---Purpose: Sets the specified value used to compare <me> and
-- an other color in IsDifferent and in IsEqual methods.
-- Warning: The default value is 0.0001
---Category: Class methods
Epsilon ( myclass )
returns Parameter from Quantity;
---Purpose: Returns the specified value used to compare <me> and
-- an other color in IsDifferent and in IsEqual methods.
---Category: Class methods
Name ( myclass;
R, G, B : Parameter from Quantity )
returns NameOfColor from Quantity;
---Purpose: Returns the name of the colour for which the RGB components
-- are nearest to <R>, <G> and <B>.
---Category: Class methods
StringName ( myclass;
AColor : NameOfColor from Quantity )
returns CString;
---Purpose: 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.
HlsRgb ( myclass;
H, L, S : Parameter from Quantity;
R , G , B : out Parameter from Quantity ) ;
---Purpose: Converts HLS components into RGB ones.
---Category: Class methods
RgbHls ( myclass;
R, G, B : Parameter from Quantity;
H , L , S : out Parameter from Quantity ) ;
---Purpose: Converts RGB components into HLS ones.
---Category: Class methods
Color2argb ( myclass; theColor: Color from Quantity;
theARGB : out Integer from Standard );
---Purpose: Convert the Color value to ARGB integer value.
-- theARGB has Alpha equal to zero, so the output is
-- formatted as 0x00RRGGBB
Argb2color ( myclass; theARGB : Integer from Standard;
theColor: out Color from Quantity );
---Purpose: Convert integer ARGB value to Color. Alpha bits are ignored
----------------------------
-- Category: Private methods
----------------------------
hlsrgb ( myclass;
H, L, S : ShortReal from Standard;
R , G , B : out ShortReal from Standard )
is private ;
---Purpose: Converts HLS components into RGB ones.
---Category: Private methods
rgbhls ( myclass;
R, G, B : ShortReal from Standard;
H , L , S : out ShortReal from Standard )
is private ;
---Purpose: Converts RGB components into HLS ones.
---Category: Private methods
ValuesOf ( myclass;
AName : NameOfColor from Quantity;
AType : TypeOfColor from Quantity;
R1, R2, R3 : out ShortReal from Standard )
is private;
---Purpose: Returns the values of a predefined 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.
---Category: Private methods
Test ( myclass );
---Purpose: Internal test
---Category: Private methods
--
fields
--
-- Class : Quantity_Color
--
-- Purpose : Declaration of variables specific to colours
--
-- Reminder : A colour is defined, either in RGB or HLS,
-- or by a name defined in the X11 specification.
--
-- RGB components
MyRed : ShortReal from Standard;
MyGreen : ShortReal from Standard;
MyBlue : ShortReal from Standard;
end Color;

3909
src/Quantity/Quantity_Color.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
#ifndef COLOR_PXX_INCLUDED
#define COLOR_PXX_INCLUDED
#define RGBHLS_H_UNDEFINED -1.0
static Quantity_Parameter TheEpsilon = 0.0001;
#endif

163
src/Quantity/Quantity_Convert.cdl Executable file
View File

@@ -0,0 +1,163 @@
-- File: Quantity_Convert.cdl
-- Created: Tue Jul 19 16:36:20 1994
-- Author: Guest Kernel
-- <g_kernel@bibox>
---Copyright: Matra Datavision 1994
class Convert from Quantity
---Purpose: Services to manage units conversion between Front-ends and Engines.
-- This conversion is managed by a table of correspondance between the quantities
-- and their "conversion coefficient".
-- This table is implemented like an external array (TCollection_Array1) regarding
-- to the quantities enumeration.
uses
AsciiString from TCollection,
PhysicalQuantity from Quantity,
Coefficient from Quantity
is
Create returns Convert from Quantity;
---Purpose: Creates an object;
SetQuantity(myclass ;
aQuantity : PhysicalQuantity from Quantity ;
aCoef: Coefficient from Quantity);
---Purpose: Updates the conversion table (correspondances between
-- Quantities and conversion coefficients).
---C++: inline
ConvertUserToSI(myclass ;
aQuantity : PhysicalQuantity from Quantity ;
aVal : Real from Standard)
returns Real from Standard;
---Purpose: Converts, from the conversion table, the value <aVal>
-- from the user system to the SI system.
---C++: inline
ConvertSIToUser(myclass ;
aQuantity : PhysicalQuantity from Quantity ;
aVal : Real from Standard)
returns Real from Standard;
---Purpose: Converts, from the conversion table, the value <aVal>
-- from the SI system to the user system.
---C++: inline
IsPhysicalQuantity(myclass;
aTypeName : AsciiString from TCollection ;
anEnum : in out AsciiString from TCollection)
returns Boolean from Standard;
---Purpose:
-- if (aType is a physical quantity)
-- returns True and the name of the associated PhysicalQuantity .
-- else
-- returns False.
end Convert from Quantity;

113
src/Quantity/Quantity_Convert.cxx Executable file
View File

@@ -0,0 +1,113 @@
#include <Quantity_Convert.ixx>
#include <TCollection_AsciiString.hxx>
#include <Quantity_Array1OfCoefficient.hxx>
Standard_EXPORT Quantity_Array1OfCoefficient ConvertTable(1,68);
static Standard_CString theEnums[] = { // En attendant la methode "Elements" de Standard_Type
"Quantity_MASS",
"Quantity_PLANEANGLE",
"Quantity_SOLIDANGLE",
"Quantity_LENGTH",
"Quantity_AREA",
"Quantity_VOLUME",
"Quantity_SPEED",
"Quantity_VELOCITY",
"Quantity_ACCELERATION",
"Quantity_ANGULARVELOCITY",
"Quantity_FREQUENCY",
"Quantity_TEMPERATURE",
"Quantity_AMOUNTOFSUBSTANCE",
"Quantity_DENSITY",
"Quantity_MASSFLOW",
"Quantity_VOLUMEFLOW",
"Quantity_CONSUMPTION",
"Quantity_MOMENTUM",
"Quantity_KINETICMOMENT",
"Quantity_MOMENTOFINERTIA",
"Quantity_FORCE",
"Quantity_MOMENTOFAFORCE",
"Quantity_TORQUE",
"Quantity_WEIGHT",
"Quantity_PRESSURE",
"Quantity_VISCOSITY",
"Quantity_KINEMATICVISCOSITY",
"Quantity_ENERGY",
"Quantity_WORK",
"Quantity_POWER",
"Quantity_SURFACETENSION",
"Quantity_COEFFICIENTOFEXPANSION",
"Quantity_THERMALCONDUCTIVITY",
"Quantity_SPECIFICHEATCAPACITY",
"Quantity_ENTROPY",
"Quantity_ENTHALPY",
"Quantity_LUMINOUSINTENSITY",
"Quantity_LUMINOUSFLUX",
"Quantity_LUMINANCE",
"Quantity_ILLUMINANCE",
"Quantity_LUMINOUSEXPOSITION",
"Quantity_LUMINOUSEFFICACITY",
"Quantity_ELECTRICCHARGE",
"Quantity_ELECTRICCURRENT",
"Quantity_ELECTRICFIELDSTRENGTH",
"Quantity_ELECTRICPOTENTIAL",
"Quantity_ELECTRICCAPACITANCE",
"Quantity_MAGNETICFLUX",
"Quantity_MAGNETICFLUXDENSITY",
"Quantity_MAGNETICFIELDSTRENGTH",
"Quantity_RELUCTANCE",
"Quantity_RESISTANCE",
"Quantity_INDUCTANCE",
"Quantity_CAPACITANCE",
"Quantity_IMPEDANCE",
"Quantity_ADMITTANCE",
"Quantity_RESISTIVITY",
"Quantity_CONDUCTIVITY",
"Quantity_MOLARMASS",
"Quantity_MOLARVOLUME",
"Quantity_CONCENTRATION",
"Quantity_MOLARCONCENTRATION",
"Quantity_MOLARITY",
"Quantity_SOUNDINTENSITY",
"Quantity_ACOUSTICINTENSITY",
"Quantity_ACTIVITY",
"Quantity_ABSORBEDDOSE",
"Quantity_DOSEEQUIVALENT" };
//----------------------------------------------------------------------------
// Create
//----------------------------------------------------------------------------
Quantity_Convert::Quantity_Convert () {
// ...On se fixe sur un nombre de grandeurs physiques egal a 68 (temporaire)
// ...Initialisation de la table de correspondance a 1 (Coefficient de conversion
// ...par defaut)
for (Standard_Integer i = 1 ; i <= 68 ; i++) ConvertTable(i) = 1;
}
//----------------------------------------------------------------------------
// IsPhysicalQuantity
//----------------------------------------------------------------------------
Standard_Boolean Quantity_Convert::IsPhysicalQuantity
(const TCollection_AsciiString& aTypeName, TCollection_AsciiString& anEnum)
{
// ... Fabriquer le nom de l'enumeration (Quantity_LENGTH par exemple).
TCollection_AsciiString aPrefixe("Quantity_");
anEnum = aTypeName;
anEnum.UpperCase();
anEnum.Prepend(aPrefixe);
// ... Rechercher si il existe existe une valeur d'enum correspondante a <aTypeName>
Standard_Integer i = 1;
Standard_Boolean Find = Standard_False;
while (i <= 68 && !Find)
{
if (IsSimilar(anEnum.ToCString(),theEnums[i-1]))
Find = Standard_True;
else
i++;
}
return Find;
}

View File

@@ -0,0 +1,59 @@
//-----------------------------------------------------------------------------
//
// inline methods for Convert from Quantity
//
// Author : M. MERCIEN
//-----------------------------------------------------------------------------
#include <Quantity_Array1OfCoefficient.hxx>
#ifndef __Quantity_API
# if defined(WNT) && !defined(HAVE_NO_DLL)
# ifdef __Quantity_DLL
# define __Quantity_API __declspec( dllexport )
# else
# define __Quantity_API __declspec( dllimport )
# endif // __Quantity_DLL
# else
# define __Quantity_API
# endif // WNT
#endif // __Quantity_API
extern __Quantity_API Quantity_Array1OfCoefficient ConvertTable;
//----------------------------------------------------------------------------
// SetQuantity
//----------------------------------------------------------------------------
inline void Quantity_Convert::SetQuantity (const Quantity_PhysicalQuantity aQuantity,
const Quantity_Coefficient aCoef) {
// ...Update du coefficient de conversion
if (aQuantity > 0 && aQuantity <= 68) ConvertTable(aQuantity) = aCoef;
}
//----------------------------------------------------------------------------
// ConvertUserToSI
//----------------------------------------------------------------------------
inline Quantity_Coefficient Quantity_Convert::ConvertUserToSI
(const Quantity_PhysicalQuantity aQuantity ,
const Standard_Real aVal) {
// ...Conversion de la valeur aVal, du Systeme Utilisateur en Systeme International
if (aQuantity > 0 && aQuantity <= 68)
return (aVal*ConvertTable(aQuantity));
else
return aVal;
}
//----------------------------------------------------------------------------
// ConvertSIToUser
//----------------------------------------------------------------------------
inline Quantity_Coefficient Quantity_Convert::ConvertSIToUser
(const Quantity_PhysicalQuantity aQuantity ,
const Standard_Real aVal) {
// ...Conversion de la valeur aVal, du Systeme International au Systeme Utilisateur
if (aQuantity > 0 && aQuantity <= 68)
return (aVal/ConvertTable(aQuantity));
else
return aVal;
}

159
src/Quantity/Quantity_Date.cdl Executable file
View File

@@ -0,0 +1,159 @@
--Copyright: Matra Datavision 1993
-- File: Quantity_Date.cdl
-- Created: January 4th, 1993
-- Author: J.P. BOUDIER - J.P. TIRAULT
--
class Date from Quantity
inherits Storable from Standard
---Purpose: This class provides services to manage date information.
-- A date represents the following time intervals:
-- year, month, day, hour, minute, second,
-- millisecond and microsecond.
-- Current time is expressed in elapsed seconds
-- and microseconds beginning from 00:00 GMT,
-- January 1, 1979 (zero hour). The valid date can
-- only be later than this one.
-- Note: a Period object gives the interval between two dates.
uses Period
raises DateDefinitionError from Quantity , OutOfRange from Standard
is
Create returns Date;
---Purpose: Constructs a default date
-- (00:00 GMT, January 1, 1979 (zero hour)); use the function
-- SetValues to define the required date; or
Create ( mm, dd, yyyy, hh, mn, ss : Integer ; mis , mics : Integer = 0)
returns Date
---Purpose: 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.
raises DateDefinitionError;
Values (me ; mm, dd, yy, hh, mn, ss, mis, mics : out Integer) is static;
---Purpose: 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
SetValues (me : out; mm, dd, yy, hh, mn, ss : Integer;
mis, mics : Integer = 0)
---Purpose: 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.
raises DateDefinitionError is static;
Difference (me : out; anOther : Date) returns Period is static;
---Purpose: 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.
Subtract (me : out; aPeriod : Period) returns Date
---Purpose: Subtracts a period from a Date and returns the new Date.
-- Raises an exception if the result date is anterior to
-- Jan 1, 1979.
---C++: alias operator -
raises OutOfRange is static;
Add(me : out; aPeriod : Period) returns Date is static;
---Purpose: Adds a Period to a Date and returns the new Date.
---C++: alias operator +
Year (me : out) returns Integer is static;
---Purpose: Returns year of a Date.
Month (me : out) returns Integer is static;
---Purpose: Returns month of a Date.
Day (me : out) returns Integer is static;
---Purpose: Returns Day of a Date.
Hour (me : out) returns Integer is static;
---Purpose: Returns Hour of a Date.
Minute (me : out) returns Integer is static;
---Purpose: Returns minute of a Date.
Second (me : out) returns Integer is static;
---Purpose: Returns seconde of a Date.
MilliSecond (me : out) returns Integer is static;
---Purpose: Returns millisecond of a Date.
MicroSecond (me : out) returns Integer is static;
---Purpose: Returns microsecond of a Date.
IsEqual (me ; anOther : Date) returns Boolean is static;
---Purpose: Returns TRUE if both <me> and <other> are equal.
-- This method is an alias of operator ==.
---C++: alias operator ==
IsEarlier (me ; anOther : Date) returns Boolean is static;
---Purpose: Returns TRUE if <me> is earlier than <other>.
---C++: alias operator <
IsLater (me ; anOther : Date) returns Boolean is static;
---Purpose: Returns TRUE if <me> is later then <other>.
---C++: alias operator >
IsValid (myclass ; mm, dd, yy, hh, mn, ss : Integer;
mis, mics : Integer = 0) returns Boolean;
---Purpose: 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
IsLeap (myclass ; yy : Integer ) returns Boolean;
---Purpose: 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.
---C++: inline
fields
mySec : Integer;
myUSec : Integer;
end Date from Quantity;

427
src/Quantity/Quantity_Date.cxx Executable file
View File

@@ -0,0 +1,427 @@
// -------------------------------------------------------------
//
// Created by J.P BOUDIER J.P. TIRAULT Jan,5th 1993
// C matra datavision 1993
//
// Date class implementation.
//
// Updated :
//
// -------------------------------------------------------------
#include <Quantity_DateDefinitionError.hxx>
#include <Standard_OutOfRange.hxx>
#include <Quantity_Date.ixx>
static int month_table[12] = {
31, // January
28, // February
31, // March
30, // April
31, // May
30, // June
31, // July
31, // August
30, // September
31, // October
30, // November
31}; // December
static int SecondsByYear = 365 * 24 * 3600 ; // Normal Year
static int SecondsByLeapYear = 366 * 24 * 3600 ; // Leap Year
// -----------------------------------------
// Initialize a date to January,1 1979 00:00
// -----------------------------------------
Quantity_Date::Quantity_Date(): mySec(0),myUSec(0) {}
// -----------------------------------------------------------
// IsValid : Checks the validity of a date
// This is the complete way month, day, year, ... micro second
// -----------------------------------------------------------
Standard_Boolean Quantity_Date::IsValid(const Standard_Integer mm,
const Standard_Integer dd,
const Standard_Integer yy,
const Standard_Integer hh,
const Standard_Integer mn,
const Standard_Integer ss,
const Standard_Integer mis,
const Standard_Integer mics){
if (mm < 1 || mm > 12) return Standard_False;
if (yy < 1979 ) return Standard_False;
if ( Quantity_Date::IsLeap (yy) ) month_table[1] = 29;
else month_table[1] = 28;
if (dd < 1 || dd > month_table[mm-1]) return Standard_False;
if (hh < 0 || hh > 23) return Standard_False;
if (mn < 0 || mn > 59) return Standard_False;
if (ss < 0 || ss > 59) return Standard_False;
if (mis < 0 || mis > 999) return Standard_False;
if (mics < 0 || mics > 999) return Standard_False;
return Standard_True;
}
// -----------------------------------------------------------
// Initialize a Date :
// This is the complete way month, day, year, ... micro second
// -----------------------------------------------------------
Quantity_Date::Quantity_Date(const Standard_Integer mm,
const Standard_Integer dd,
const Standard_Integer yy,
const Standard_Integer hh,
const Standard_Integer mn,
const Standard_Integer ss,
const Standard_Integer mis,
const Standard_Integer mics){
SetValues (mm,dd,yy,hh,mn,ss,mis,mics);
}
// ------------------------------------------------------------
// Set values of a Date :
// This is the complete way month, day, year, ... micro second
// ------------------------------------------------------------
void Quantity_Date::SetValues(const Standard_Integer mm,
const Standard_Integer dd,
const Standard_Integer yy,
const Standard_Integer hh,
const Standard_Integer mn,
const Standard_Integer ss,
const Standard_Integer mis,
const Standard_Integer mics){
Standard_Integer i;
if ( ! Quantity_Date::IsValid (mm,dd,yy,hh,mn,ss,mis,mics))
Quantity_DateDefinitionError::Raise(
"Quantity_Date::Quantity_Date invalid parameters");
if ( Quantity_Date::IsLeap (yy) ) month_table[1] = 29;
else month_table[1] = 28;
mySec = 0;
myUSec = 0;
for(i = 1979; i < yy; i++) {
if ( ! Quantity_Date::IsLeap (i) ) mySec += SecondsByYear;
else mySec += SecondsByLeapYear;
}
for(i = 1; i< mm; i++) {
mySec += month_table[i-1] * 3600 * 24 ;
}
mySec += 3600 * 24 * (dd-1);
mySec += 3600 * hh;
mySec += 60 * mn;
mySec += ss;
myUSec += mis * 1000;
myUSec += mics;
}
// ---------------------------------------------
// Values : Returns the values of a date
// ~~~~~~
// ---------------------------------------------
void Quantity_Date::Values(Standard_Integer& mm,
Standard_Integer& dd,
Standard_Integer& yy,
Standard_Integer& hh,
Standard_Integer& mn,
Standard_Integer& ss,
Standard_Integer& mis,
Standard_Integer& mics)const{
Standard_Integer i,carry;
for(yy = 1979, carry = mySec ;; yy++) {
if ( ! Quantity_Date::IsLeap (yy) )
{
month_table[1] = 28; // normal year
if (carry >= SecondsByYear ) carry -= SecondsByYear;
else break;
}
else
{
month_table[1] = 29; // Leap year
if (carry >= SecondsByLeapYear) carry -= SecondsByLeapYear;
else break;
}
}
for(mm = 1 ; ; mm++) {
i = month_table[mm-1] * 3600 * 24;
if ( carry >= i ) carry -= i;
else break;
}
i = 3600 * 24;
for(dd = 1 ; ; dd++) {
if ( carry >= i ) carry -= i;
else break;
}
for(hh = 0 ; ; hh++) {
if ( carry >= 3600 ) carry -= 3600;
else break;
}
for(mn = 0 ; ; mn++) {
if ( carry >= 60 ) carry -= 60;
else break;
}
ss = carry;
mis = myUSec / 1000;
mics = myUSec - ( mis * 1000);
}
// ---------------------------------------------------------------------
// Difference : Subtract a date to a given date; the result is a period
// ~~~~~~~~~~ of time
// ---------------------------------------------------------------------
Quantity_Period Quantity_Date::Difference(const Quantity_Date& OtherDate){
Standard_Integer i1,i2;
if (mySec == 0 && myUSec == 0)
{
i1 = OtherDate.mySec;
i2 = OtherDate.myUSec;
}
else {
i1 = mySec - OtherDate.mySec ;
i2 = myUSec - OtherDate.myUSec;
}
if ( i1 >= 0 && i2 < 0 ) {
i1--;
i2 = 1000000 + i2 ;
}
else if ( i1 <0 && i2 >= 0 ) {
i1 = Abs(i1);
if ( i2 > 0 ){
i1--;
i2 = 1000000 - i2 ;
}
}
else if ( i1 <0 && i2 < 0 ) {
i1 = Abs(i1);
i2 = Abs(i2);
}
Quantity_Period result ( i1 , i2 );
return (result);
}
// ------------------------------------------------------------------
// Subtract : subtracts a period to a date and returns a date.
// ~~~~~~~~
// ------------------------------------------------------------------
Quantity_Date Quantity_Date::Subtract(const Quantity_Period& During){
Standard_Integer ss,mics;
Quantity_Date result;
result.mySec = mySec;
result.myUSec = myUSec;
During.Values (ss,mics);
result.mySec -= ss;
result.myUSec -= mics;
if ( result.mySec >= 0 && result.myUSec < 0 ) {
result.mySec--;
result.myUSec = 1000000 + result.myUSec ;
}
if ( result.mySec <0 )
Quantity_DateDefinitionError::Raise(
"Quantity_Date::Subtract : The result date is anterior to Jan,1 1979");
return (result);
}
// ----------------------------------------------------------------------
// Add : Adds a period of time to a date
// ~~~
// ----------------------------------------------------------------------
Quantity_Date Quantity_Date::Add(const Quantity_Period& During){
Quantity_Date result;
During.Values (result.mySec,result.myUSec);
result.mySec += mySec;
result.myUSec += myUSec;
if ( result.myUSec >= 1000000 ) {
result.mySec++;
result.myUSec -= 1000000;
}
return (result);
}
// ----------------------------------------------------------------------
// Year : Return the year of a date
// ~~~~
// ----------------------------------------------------------------------
Standard_Integer Quantity_Date::Year(){
Standard_Integer dummy, year;
Values(dummy, dummy, year, dummy, dummy, dummy, dummy, dummy);
return (year);
}
// ----------------------------------------------------------------------
// Month : Return the month of a date
// ~~~~~
// ----------------------------------------------------------------------
Standard_Integer Quantity_Date::Month(){
Standard_Integer dummy, month;
Values(month, dummy, dummy, dummy, dummy, dummy, dummy, dummy);
return(month);
}
// ----------------------------------------------------------------------
// Day : Return the day of a date
// ~~~
// ----------------------------------------------------------------------
Standard_Integer Quantity_Date::Day(){
Standard_Integer dummy, day;
Values(dummy, day, dummy, dummy, dummy, dummy, dummy, dummy);
return(day);
}
// ----------------------------------------------------------------------
// hour : Return the hour of a date
// ~~~~
// ----------------------------------------------------------------------
Standard_Integer Quantity_Date::Hour(){
Standard_Integer dummy, hour;
Values(dummy, dummy, dummy, hour, dummy, dummy, dummy, dummy);
return(hour);
}
// ----------------------------------------------------------------------
// Minute : Return the minute of a date
// ~~~~~~
// ----------------------------------------------------------------------
Standard_Integer Quantity_Date::Minute(){
Standard_Integer dummy, min;
Values(dummy, dummy, dummy, dummy, min, dummy, dummy, dummy);
return(min);
}
// ----------------------------------------------------------------------
// Second : Return the second of a date
// ~~~~~~
// ----------------------------------------------------------------------
Standard_Integer Quantity_Date::Second(){
Standard_Integer dummy, sec;
Values(dummy, dummy, dummy, dummy, dummy, sec , dummy, dummy);
return(sec);
}
// ----------------------------------------------------------------------
// millisecond : Return the millisecond of a date
// ~~~~~~~~~~~
// ----------------------------------------------------------------------
Standard_Integer Quantity_Date::MilliSecond(){
Standard_Integer dummy, msec;
Values(dummy, dummy, dummy, dummy, dummy, dummy, msec, dummy);
return(msec);
}
// ----------------------------------------------------------------------
// Day : Return the day of a date
// ~~~
// ----------------------------------------------------------------------
Standard_Integer Quantity_Date::MicroSecond(){
Standard_Integer dummy, msec;
Values(dummy, dummy, dummy, dummy, dummy, dummy, dummy, msec);
return(msec);
}
// ----------------------------------------------------------------------
// IsEarlier : Return true if the date is earlier than an other date
// ~~~~~~~~~
// ----------------------------------------------------------------------
Standard_Boolean Quantity_Date::IsEarlier(const Quantity_Date& other)const{
if (mySec < other.mySec) return Standard_True;
else if (mySec > other.mySec) return Standard_False;
else return ( ( myUSec < other.myUSec ) ? Standard_True : Standard_False);
}
// ----------------------------------------------------------------------
// IsLater : Return true if the date is later than an other date
// ~~~~~~~
// ----------------------------------------------------------------------
Standard_Boolean Quantity_Date::IsLater(const Quantity_Date& other)const{
if (mySec > other.mySec) return Standard_True;
else if (mySec < other.mySec) return Standard_False;
else return ( ( myUSec > other.myUSec ) ? Standard_True : Standard_False);
}
// ----------------------------------------------------------------------
// IsEqual : Return true if the date is the same than an other date
// ~~~~~~~
// ----------------------------------------------------------------------
Standard_Boolean Quantity_Date::IsEqual(const Quantity_Date& other)const{
return ( ( myUSec == other.myUSec &&
mySec == other.mySec ) ? Standard_True : Standard_False);
}

5
src/Quantity/Quantity_Date.lxx Executable file
View File

@@ -0,0 +1,5 @@
inline Standard_Boolean Quantity_Date::IsLeap (const Standard_Integer yy){
return ( ( yy % 4 == 0 && yy % 100 != 0 || yy % 400 == 0)
? Standard_True : Standard_False );
}

121
src/Quantity/Quantity_Period.cdl Executable file
View File

@@ -0,0 +1,121 @@
--Copyright: Matra Datavision 1993
-- File: Quantity_Period.cdl
-- Created: January 4th, 1993
-- Author: J.P. BOUDIER - J.P. TIRAULT
--
class Period from Quantity
---Purpose: Manages date intervals. For example, a Period object
-- gives the interval between two dates.
-- A period is expressed in seconds and microseconds.
inherits Storable from Standard
raises PeriodDefinitionError
is
Create ( dd, hh, mn, ss : Integer ; mis , mics : Integer = 0)
returns Period
raises PeriodDefinitionError;
---Purpose: Creates a Period
-- With: 0 <= dd
-- 0 <= hh
-- 0 <= mn
-- 0 <= ss
-- 0 <= mis
-- 0 <= mics
Create ( ss : Integer; mics : Integer = 0 )
returns Period
raises PeriodDefinitionError;
---Purpose: 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.
Values (me ; dd, hh, mn, ss, mis, mics : out Integer) is static;
---Purpose: 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
Values (me; ss , mics : out Integer) is static;
---Purpose: 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
SetValues (me : out; dd,hh, mn, ss : Integer; mis, mics : Integer = 0)
is static;
---Purpose: 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
SetValues (me : out; ss : Integer ; mics : Integer = 0 ) is static ;
---Purpose: 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.
Subtract (me ; anOther : Period) returns Period is static;
---Purpose: Subtracts one Period from another and returns the difference.
---C++: alias operator -
Add (me ; anOther : Period) returns Period is static;
---Purpose: Adds one Period to another one.
---C++: alias operator +
IsEqual (me ; anOther : Period) returns Boolean is static ;
---Purpose: Returns TRUE if both <me> and <other> are equal.
---C++: alias operator ==
IsShorter (me ; anOther : Period) returns Boolean is static;
---Purpose: Returns TRUE if <me> is shorter than <other>.
---C++: alias operator <
IsLonger (me ; anOther : Period) returns Boolean is static;
---Purpose: Returns TRUE if <me> is longer then <other>.
---C++: alias operator >
IsValid (myclass ; dd, hh, mn, ss : Integer ; mis , mics : Integer = 0)
returns Boolean;
---Purpose: 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
IsValid (myclass ; ss : Integer ; mics : Integer = 0)
returns Boolean;
---Purpose: Checks the validity of a Period in form (ss,mic)
-- With: 0 <= ss
-- 0 <= mics
fields
mySec : Integer;
myUSec : Integer;
end Period from Quantity;

239
src/Quantity/Quantity_Period.cxx Executable file
View File

@@ -0,0 +1,239 @@
// -------------------------------------------------------------
//
// Created by J.P BOUDIER J.P. TIRAULT Jan,5th 1993
// C matra datavision 1993
//
// Period class implementation.
//
// Updated :
//
// -------------------------------------------------------------
#include <Quantity_PeriodDefinitionError.hxx>
#include <Quantity_Period.ixx>
// -----------------------------------------------------------
// IsValid : Checks the validity of a date
// With:
// 0 <= dd
// 0 <= hh
// 0 <= mn
// 0 <= ss
// 0 <= mis
// 0 <= mics
// -----------------------------------------------------------
Standard_Boolean Quantity_Period::IsValid(
const Standard_Integer dd,
const Standard_Integer hh,
const Standard_Integer mn,
const Standard_Integer ss,
const Standard_Integer mis,
const Standard_Integer mics){
return ( (dd < 0 || hh < 0 || mn < 0 ||
ss < 0 || mis < 0 || mics < 0 ) ? Standard_False : Standard_True );
}
// -------------------------------------------------------------
// IsValid : Checks the validity of a date
// With:
// 0 <= ss
// 0 <= mics
// -------------------------------------------------------------
Standard_Boolean Quantity_Period::IsValid(
const Standard_Integer ss,
const Standard_Integer mics){
return ( (ss < 0 || mics < 0 ) ? Standard_False : Standard_True );
}
// -------------------------------------------------------------
// Create : Creates a period with a number of seconds
// ~~~~~~ and microseconds.
//
// -------------------------------------------------------------
Quantity_Period::Quantity_Period(const Standard_Integer dd,
const Standard_Integer hh,
const Standard_Integer mn,
const Standard_Integer ss,
const Standard_Integer mils,
const Standard_Integer mics){
SetValues (dd,hh,mn,ss,mils,mics);
}
// -------------------------------------------------------------
// Create : Creates a period with a number of seconds
// ~~~~~~ and microseconds.
//
// -------------------------------------------------------------
Quantity_Period::Quantity_Period(const Standard_Integer ss,
const Standard_Integer mics){
SetValues(ss,mics);
}
// -------------------------------------------------------------
// Values : Returns a period with the number of days,hours,
// ~~~~~~ minutes,seconds,milliseconds and microseconds.
// -------------------------------------------------------------
void Quantity_Period::Values(
Standard_Integer& dd,
Standard_Integer& hh,
Standard_Integer& mn,
Standard_Integer& ss,
Standard_Integer& mis,
Standard_Integer& mics
)const{
Standard_Integer carry = mySec;
dd = carry / ( 24 * 3600 );
carry -= dd * 24 * 3600 ;
hh = carry / 3600;
carry -= 3600 * hh;
mn = carry / 60;
carry -= mn * 60;
ss = carry;
mis = myUSec / 1000;
mics = myUSec - ( mis * 1000);
}
// -------------------------------------------------------------
// Values : Returns a period with the number of seconds and
// ~~~~~~ microseconds.
// -------------------------------------------------------------
void Quantity_Period::Values(
Standard_Integer& ss,
Standard_Integer& mics
)const{
ss = mySec;
mics = myUSec;
}
// -------------------------------------------------------------
// SetValues : Sets a period with a number of days,hours,minutes,
// ~~~~~~~~~ seconds and microseconds.
// -------------------------------------------------------------
void Quantity_Period::SetValues( const Standard_Integer dd,
const Standard_Integer hh,
const Standard_Integer mn,
const Standard_Integer ss,
const Standard_Integer mils,
const Standard_Integer mics){
SetValues( ( dd * 24 * 3600 ) + ( hh * 3600 ) + ( 60 * mn ) + ss ,
mils * 1000 + mics );
}
// -------------------------------------------------------------
// SetValues : Sets a period with a number of seconds and
// ~~~~~~~~~ microseconds.
// -------------------------------------------------------------
void Quantity_Period::SetValues(
const Standard_Integer ss,
const Standard_Integer mics) {
if ( ! Quantity_Period::IsValid(ss,mics) )
Quantity_PeriodDefinitionError::Raise(
"Quantity_Period::SetValues invalid parameters");
mySec = ss;
myUSec = mics;
while ( myUSec > 1000000 )
{
myUSec -= 1000000;
mySec++;
}
}
// -------------------------------------------------------------
// Subtract : Subtracts a period to another period
// ~~~~~~~~
// -------------------------------------------------------------
Quantity_Period Quantity_Period::Subtract(const Quantity_Period&
OtherPeriod)const{
Quantity_Period result (mySec,myUSec);
result.mySec -= OtherPeriod.mySec;
result.myUSec -= OtherPeriod.myUSec;
if ( result.mySec >= 0 && result.myUSec < 0 ) {
result.mySec--;
result.myUSec = 1000000 + result.myUSec ;
}
else if ( result.mySec <0 && result.myUSec >= 0 ) {
result.mySec = Abs(result.mySec);
if ( result.myUSec > 0 ){
result.mySec--;
result.myUSec = 1000000 - result.myUSec ;
}
}
else if ( result.mySec <0 && result.myUSec < 0 ) {
result.mySec = Abs(result.mySec);
result.myUSec = Abs(result.myUSec);
}
return (result);
}
// -------------------------------------------------------------
// Add : Adds a period to another period
// ~~~
// -------------------------------------------------------------
Quantity_Period Quantity_Period::Add(const Quantity_Period& OtherPeriod)
const{
Quantity_Period result (mySec,myUSec);
result.mySec += OtherPeriod.mySec;
result.myUSec += OtherPeriod.myUSec;
if (result.myUSec > 1000000)
{
result.myUSec -= 1000000;
result.mySec++;
}
return (result);
}
// -------------------------------------------------------------
// IsEqual : returns true if two periods are equal
// ~~~~~~~
// -------------------------------------------------------------
Standard_Boolean Quantity_Period::IsEqual(const Quantity_Period&
OtherPeriod)const{
return
( ( mySec == OtherPeriod.mySec &&
myUSec == OtherPeriod.myUSec ) ? Standard_True : Standard_False);
}
// -------------------------------------------------------------
// IsShorter : returns true if a date is shorter then an other
// ~~~~~~~~~ date
// -------------------------------------------------------------
Standard_Boolean Quantity_Period::IsShorter(
const Quantity_Period& OtherPeriod)const{
if ( mySec < OtherPeriod.mySec ) return Standard_True;
else if ( mySec > OtherPeriod.mySec ) return Standard_False;
else return
( ( myUSec < OtherPeriod.myUSec ) ? Standard_True : Standard_False);
}
// -------------------------------------------------------------
// IsLonger : returns true if a date is longer then an other
// ~~~~~~~~ date
// -------------------------------------------------------------
Standard_Boolean Quantity_Period::IsLonger(
const Quantity_Period& OtherPeriod)const{
if ( mySec > OtherPeriod.mySec ) return Standard_True;
else if ( mySec < OtherPeriod.mySec ) return Standard_False;
else return
( ( myUSec > OtherPeriod.myUSec ) ? Standard_True : Standard_False);
}

View File

@@ -0,0 +1,22 @@
inline Standard_Real Quantity_Period::MillisecondPeriod(){
return (1E+3);
}
inline Standard_Real Quantity_Period::SecondPeriod(){
return (1E+6);
}
inline Standard_Real Quantity_Period::MinutePeriod(){
return (60.0E+6);
}
inline Standard_Real Quantity_Period::HourPeriod(){
return (3600.0E+6);
}
inline Standard_Real Quantity_Period::DayPeriod(){
return (86400.0E+6);
}