(*
Copyright by:
buildingSMART International Limited, 1996-2019

Any technical documentation made available by buildingSMART International Limited
is the copyrighted work of buildingSMART International Limited and is owned by the 
buildingSMART International Limited. It may be photocopied, used in software development, 
or translated into another computer language without prior written consent from 
buildingSMART International Limited provided that full attribution is given. 
Prior written consent is required if changes are made to the technical specification.

This material is delivered to you as is and buildingSMART International Limited makes 
no warranty of any kind with regard to it, including, but not limited to, the implied 
warranties as to its accuracy or fitness for a particular purpose. Any use of the 
technical documentation or the information contained therein is at the risk of the user. 
Documentation may include technical or other inaccuracies or typographical errors. 
buildingSMART International Limited shall not be liable for errors contained therein or 
for incidental consequential damages in connection with the furnishing, performance or use 
of the material. The information contained in this document is subject to change without notice.

Issue date:
Friday, July 26, 2019

*)

SCHEMA IFCMEASURERESOURCE;

REFERENCE FROM IFCEXTERNALREFERENCERESOURCE
(
  IfcExternalReferenceRelationship
);

REFERENCE FROM IFCDATETIMERESOURCE
(
  IfcDate,
  IfcDateTime,
  IfcTime,
  IfcDuration,
  IfcTimeStamp
);

TYPE IfcAbsorbedDoseMeasure = REAL;
END_TYPE;

TYPE IfcAccelerationMeasure = REAL;
END_TYPE;

TYPE IfcAmountOfSubstanceMeasure = REAL;
END_TYPE;

TYPE IfcAngularVelocityMeasure = REAL;
END_TYPE;

TYPE IfcAreaDensityMeasure = REAL;
END_TYPE;

TYPE IfcAreaMeasure = REAL;
END_TYPE;

TYPE IfcBinary = BINARY;
END_TYPE;

TYPE IfcBoolean = BOOLEAN;
END_TYPE;

TYPE IfcComplexNumber = ARRAY [1:2] OF REAL;
END_TYPE;

TYPE IfcCompoundPlaneAngleMeasure = LIST [3:4] OF INTEGER;
 WHERE
	MinutesInRange : ABS(SELF[2]) < 60;
	SecondsInRange : ABS(SELF[3]) < 60;
	MicrosecondsInRange : (SIZEOF(SELF) = 3) OR (ABS(SELF[4]) < 1000000);
	ConsistentSign : ((SELF[1] >= 0) AND (SELF[2] >= 0) AND (SELF[3] >= 0) AND ((SIZEOF(SELF) = 3) OR (SELF[4] >= 0)))
OR
((SELF[1] <= 0) AND (SELF[2] <= 0) AND (SELF[3] <= 0) AND ((SIZEOF(SELF) = 3) OR (SELF[4] <= 0)));
END_TYPE;

TYPE IfcContextDependentMeasure = REAL;
END_TYPE;

TYPE IfcCountMeasure = NUMBER;
END_TYPE;

TYPE IfcCurvatureMeasure = REAL;
END_TYPE;

TYPE IfcDescriptiveMeasure = STRING;
END_TYPE;

TYPE IfcDoseEquivalentMeasure = REAL;
END_TYPE;

TYPE IfcDynamicViscosityMeasure = REAL;
END_TYPE;

TYPE IfcElectricCapacitanceMeasure = REAL;
END_TYPE;

TYPE IfcElectricChargeMeasure = REAL;
END_TYPE;

TYPE IfcElectricConductanceMeasure = REAL;
END_TYPE;

TYPE IfcElectricCurrentMeasure = REAL;
END_TYPE;

TYPE IfcElectricResistanceMeasure = REAL;
END_TYPE;

TYPE IfcElectricVoltageMeasure = REAL;
END_TYPE;

TYPE IfcEnergyMeasure = REAL;
END_TYPE;

TYPE IfcForceMeasure = REAL;
END_TYPE;

TYPE IfcFrequencyMeasure = REAL;
END_TYPE;

TYPE IfcHeatFluxDensityMeasure = REAL;
END_TYPE;

TYPE IfcHeatingValueMeasure = REAL;
 WHERE
	WR1 : SELF > 0.;
END_TYPE;

TYPE IfcIdentifier = STRING(255);
END_TYPE;

TYPE IfcIlluminanceMeasure = REAL;
END_TYPE;

TYPE IfcInductanceMeasure = REAL;
END_TYPE;

TYPE IfcInteger = INTEGER;
END_TYPE;

TYPE IfcIntegerCountRateMeasure = INTEGER;
END_TYPE;

TYPE IfcIonConcentrationMeasure = REAL;
END_TYPE;

TYPE IfcIsothermalMoistureCapacityMeasure = REAL;
END_TYPE;

TYPE IfcKinematicViscosityMeasure = REAL;
END_TYPE;

TYPE IfcLabel = STRING(255);
END_TYPE;

TYPE IfcLengthMeasure = REAL;
END_TYPE;

TYPE IfcLinearForceMeasure = REAL;
END_TYPE;

TYPE IfcLinearMomentMeasure = REAL;
END_TYPE;

TYPE IfcLinearStiffnessMeasure = REAL;
END_TYPE;

TYPE IfcLinearVelocityMeasure = REAL;
END_TYPE;

TYPE IfcLogical = LOGICAL;
END_TYPE;

TYPE IfcLuminousFluxMeasure = REAL;
END_TYPE;

TYPE IfcLuminousIntensityDistributionMeasure = REAL;
END_TYPE;

TYPE IfcLuminousIntensityMeasure = REAL;
END_TYPE;

TYPE IfcMagneticFluxDensityMeasure = REAL;
END_TYPE;

TYPE IfcMagneticFluxMeasure = REAL;
END_TYPE;

TYPE IfcMassDensityMeasure = REAL;
END_TYPE;

TYPE IfcMassFlowRateMeasure = REAL;
END_TYPE;

TYPE IfcMassMeasure = REAL;
END_TYPE;

TYPE IfcMassPerLengthMeasure = REAL;
END_TYPE;

TYPE IfcModulusOfElasticityMeasure = REAL;
END_TYPE;

TYPE IfcModulusOfLinearSubgradeReactionMeasure = REAL;
END_TYPE;

TYPE IfcModulusOfRotationalSubgradeReactionMeasure = REAL;
END_TYPE;

TYPE IfcModulusOfSubgradeReactionMeasure = REAL;
END_TYPE;

TYPE IfcMoistureDiffusivityMeasure = REAL;
END_TYPE;

TYPE IfcMolecularWeightMeasure = REAL;
END_TYPE;

TYPE IfcMomentOfInertiaMeasure = REAL;
END_TYPE;

TYPE IfcMonetaryMeasure = REAL;
END_TYPE;

TYPE IfcNonNegativeLengthMeasure = IfcLengthMeasure;
 WHERE
	NotNegative : SELF >= 0.;
END_TYPE;

TYPE IfcNormalisedRatioMeasure = IfcRatioMeasure;
 WHERE
	WR1 : {0.0 <= SELF <= 1.0};
END_TYPE;

TYPE IfcNumericMeasure = NUMBER;
END_TYPE;

TYPE IfcPHMeasure = REAL;
 WHERE
	WR21 : {0.0 <= SELF <= 14.0};
END_TYPE;

TYPE IfcParameterValue = REAL;
END_TYPE;

TYPE IfcPlanarForceMeasure = REAL;
END_TYPE;

TYPE IfcPlaneAngleMeasure = REAL;
END_TYPE;

TYPE IfcPositiveInteger = IfcInteger;
 WHERE
	WR1 : SELF > 0;
END_TYPE;

TYPE IfcPositiveLengthMeasure = IfcLengthMeasure;
 WHERE
	WR1 : SELF > 0.;
END_TYPE;

TYPE IfcPositivePlaneAngleMeasure = IfcPlaneAngleMeasure;
 WHERE
	WR1 : SELF > 0.;
END_TYPE;

TYPE IfcPositiveRatioMeasure = IfcRatioMeasure;
 WHERE
	WR1 : SELF > 0.;
END_TYPE;

TYPE IfcPowerMeasure = REAL;
END_TYPE;

TYPE IfcPressureMeasure = REAL;
END_TYPE;

TYPE IfcRadioActivityMeasure = REAL;
END_TYPE;

TYPE IfcRatioMeasure = REAL;
END_TYPE;

TYPE IfcReal = REAL;
END_TYPE;

TYPE IfcRotationalFrequencyMeasure = REAL;
END_TYPE;

TYPE IfcRotationalMassMeasure = REAL;
END_TYPE;

TYPE IfcRotationalStiffnessMeasure = REAL;
END_TYPE;

TYPE IfcSectionModulusMeasure = REAL;
END_TYPE;

TYPE IfcSectionalAreaIntegralMeasure = REAL;
END_TYPE;

TYPE IfcShearModulusMeasure = REAL;
END_TYPE;

TYPE IfcSolidAngleMeasure = REAL;
END_TYPE;

TYPE IfcSoundPowerLevelMeasure = REAL;
END_TYPE;

TYPE IfcSoundPowerMeasure = REAL;
END_TYPE;

TYPE IfcSoundPressureLevelMeasure = REAL;
END_TYPE;

TYPE IfcSoundPressureMeasure = REAL;
END_TYPE;

TYPE IfcSpecificHeatCapacityMeasure = REAL;
END_TYPE;

TYPE IfcTemperatureGradientMeasure = REAL;
END_TYPE;

TYPE IfcTemperatureRateOfChangeMeasure = REAL;
END_TYPE;

TYPE IfcText = STRING;
END_TYPE;

TYPE IfcThermalAdmittanceMeasure = REAL;
END_TYPE;

TYPE IfcThermalConductivityMeasure = REAL;
END_TYPE;

TYPE IfcThermalExpansionCoefficientMeasure = REAL;
END_TYPE;

TYPE IfcThermalResistanceMeasure = REAL;
END_TYPE;

TYPE IfcThermalTransmittanceMeasure = REAL;
END_TYPE;

TYPE IfcThermodynamicTemperatureMeasure = REAL;
END_TYPE;

TYPE IfcTimeMeasure = REAL;
END_TYPE;

TYPE IfcTorqueMeasure = REAL;
END_TYPE;

TYPE IfcVaporPermeabilityMeasure = REAL;
END_TYPE;

TYPE IfcVolumeMeasure = REAL;
END_TYPE;

TYPE IfcVolumetricFlowRateMeasure = REAL;
END_TYPE;

TYPE IfcWarpingConstantMeasure = REAL;
END_TYPE;

TYPE IfcWarpingMomentMeasure = REAL;
END_TYPE;

TYPE IfcDerivedUnitEnum = ENUMERATION OF
	(ANGULARVELOCITYUNIT
	,AREADENSITYUNIT
	,COMPOUNDPLANEANGLEUNIT
	,DYNAMICVISCOSITYUNIT
	,HEATFLUXDENSITYUNIT
	,INTEGERCOUNTRATEUNIT
	,ISOTHERMALMOISTURECAPACITYUNIT
	,KINEMATICVISCOSITYUNIT
	,LINEARVELOCITYUNIT
	,MASSDENSITYUNIT
	,MASSFLOWRATEUNIT
	,MOISTUREDIFFUSIVITYUNIT
	,MOLECULARWEIGHTUNIT
	,SPECIFICHEATCAPACITYUNIT
	,THERMALADMITTANCEUNIT
	,THERMALCONDUCTANCEUNIT
	,THERMALRESISTANCEUNIT
	,THERMALTRANSMITTANCEUNIT
	,VAPORPERMEABILITYUNIT
	,VOLUMETRICFLOWRATEUNIT
	,ROTATIONALFREQUENCYUNIT
	,TORQUEUNIT
	,MOMENTOFINERTIAUNIT
	,LINEARMOMENTUNIT
	,LINEARFORCEUNIT
	,PLANARFORCEUNIT
	,MODULUSOFELASTICITYUNIT
	,SHEARMODULUSUNIT
	,LINEARSTIFFNESSUNIT
	,ROTATIONALSTIFFNESSUNIT
	,MODULUSOFSUBGRADEREACTIONUNIT
	,ACCELERATIONUNIT
	,CURVATUREUNIT
	,HEATINGVALUEUNIT
	,IONCONCENTRATIONUNIT
	,LUMINOUSINTENSITYDISTRIBUTIONUNIT
	,MASSPERLENGTHUNIT
	,MODULUSOFLINEARSUBGRADEREACTIONUNIT
	,MODULUSOFROTATIONALSUBGRADEREACTIONUNIT
	,PHUNIT
	,ROTATIONALMASSUNIT
	,SECTIONAREAINTEGRALUNIT
	,SECTIONMODULUSUNIT
	,SOUNDPOWERLEVELUNIT
	,SOUNDPOWERUNIT
	,SOUNDPRESSURELEVELUNIT
	,SOUNDPRESSUREUNIT
	,TEMPERATUREGRADIENTUNIT
	,TEMPERATURERATEOFCHANGEUNIT
	,THERMALEXPANSIONCOEFFICIENTUNIT
	,WARPINGCONSTANTUNIT
	,WARPINGMOMENTUNIT
	,USERDEFINED);
END_TYPE;

TYPE IfcSIPrefix = ENUMERATION OF
	(EXA
	,PETA
	,TERA
	,GIGA
	,MEGA
	,KILO
	,HECTO
	,DECA
	,DECI
	,CENTI
	,MILLI
	,MICRO
	,NANO
	,PICO
	,FEMTO
	,ATTO);
END_TYPE;

TYPE IfcSIUnitName = ENUMERATION OF
	(AMPERE
	,BECQUEREL
	,CANDELA
	,COULOMB
	,CUBIC_METRE
	,DEGREE_CELSIUS
	,FARAD
	,GRAM
	,GRAY
	,HENRY
	,HERTZ
	,JOULE
	,KELVIN
	,LUMEN
	,LUX
	,METRE
	,MOLE
	,NEWTON
	,OHM
	,PASCAL
	,RADIAN
	,SECOND
	,SIEMENS
	,SIEVERT
	,SQUARE_METRE
	,STERADIAN
	,TESLA
	,VOLT
	,WATT
	,WEBER);
END_TYPE;

TYPE IfcUnitEnum = ENUMERATION OF
	(ABSORBEDDOSEUNIT
	,AMOUNTOFSUBSTANCEUNIT
	,AREAUNIT
	,DOSEEQUIVALENTUNIT
	,ELECTRICCAPACITANCEUNIT
	,ELECTRICCHARGEUNIT
	,ELECTRICCONDUCTANCEUNIT
	,ELECTRICCURRENTUNIT
	,ELECTRICRESISTANCEUNIT
	,ELECTRICVOLTAGEUNIT
	,ENERGYUNIT
	,FORCEUNIT
	,FREQUENCYUNIT
	,ILLUMINANCEUNIT
	,INDUCTANCEUNIT
	,LENGTHUNIT
	,LUMINOUSFLUXUNIT
	,LUMINOUSINTENSITYUNIT
	,MAGNETICFLUXDENSITYUNIT
	,MAGNETICFLUXUNIT
	,MASSUNIT
	,PLANEANGLEUNIT
	,POWERUNIT
	,PRESSUREUNIT
	,RADIOACTIVITYUNIT
	,SOLIDANGLEUNIT
	,THERMODYNAMICTEMPERATUREUNIT
	,TIMEUNIT
	,VOLUMEUNIT
	,USERDEFINED);
END_TYPE;

TYPE IfcDerivedMeasureValue = SELECT
	(IfcAbsorbedDoseMeasure
	,IfcAccelerationMeasure
	,IfcAngularVelocityMeasure
	,IfcAreaDensityMeasure
	,IfcCompoundPlaneAngleMeasure
	,IfcCurvatureMeasure
	,IfcDoseEquivalentMeasure
	,IfcDynamicViscosityMeasure
	,IfcElectricCapacitanceMeasure
	,IfcElectricChargeMeasure
	,IfcElectricConductanceMeasure
	,IfcElectricResistanceMeasure
	,IfcElectricVoltageMeasure
	,IfcEnergyMeasure
	,IfcForceMeasure
	,IfcFrequencyMeasure
	,IfcHeatFluxDensityMeasure
	,IfcHeatingValueMeasure
	,IfcIlluminanceMeasure
	,IfcInductanceMeasure
	,IfcIntegerCountRateMeasure
	,IfcIonConcentrationMeasure
	,IfcIsothermalMoistureCapacityMeasure
	,IfcKinematicViscosityMeasure
	,IfcLinearForceMeasure
	,IfcLinearMomentMeasure
	,IfcLinearStiffnessMeasure
	,IfcLinearVelocityMeasure
	,IfcLuminousFluxMeasure
	,IfcLuminousIntensityDistributionMeasure
	,IfcMagneticFluxDensityMeasure
	,IfcMagneticFluxMeasure
	,IfcMassDensityMeasure
	,IfcMassFlowRateMeasure
	,IfcMassPerLengthMeasure
	,IfcModulusOfElasticityMeasure
	,IfcModulusOfLinearSubgradeReactionMeasure
	,IfcModulusOfRotationalSubgradeReactionMeasure
	,IfcModulusOfSubgradeReactionMeasure
	,IfcMoistureDiffusivityMeasure
	,IfcMolecularWeightMeasure
	,IfcMomentOfInertiaMeasure
	,IfcMonetaryMeasure
	,IfcPHMeasure
	,IfcPlanarForceMeasure
	,IfcPowerMeasure
	,IfcPressureMeasure
	,IfcRadioActivityMeasure
	,IfcRotationalFrequencyMeasure
	,IfcRotationalMassMeasure
	,IfcRotationalStiffnessMeasure
	,IfcSectionModulusMeasure
	,IfcSectionalAreaIntegralMeasure
	,IfcShearModulusMeasure
	,IfcSoundPowerLevelMeasure
	,IfcSoundPowerMeasure
	,IfcSoundPressureLevelMeasure
	,IfcSoundPressureMeasure
	,IfcSpecificHeatCapacityMeasure
	,IfcTemperatureGradientMeasure
	,IfcTemperatureRateOfChangeMeasure
	,IfcThermalAdmittanceMeasure
	,IfcThermalConductivityMeasure
	,IfcThermalExpansionCoefficientMeasure
	,IfcThermalResistanceMeasure
	,IfcThermalTransmittanceMeasure
	,IfcTorqueMeasure
	,IfcVaporPermeabilityMeasure
	,IfcVolumetricFlowRateMeasure
	,IfcWarpingConstantMeasure
	,IfcWarpingMomentMeasure);
END_TYPE;

TYPE IfcMeasureValue = SELECT
	(IfcAmountOfSubstanceMeasure
	,IfcAreaMeasure
	,IfcComplexNumber
	,IfcContextDependentMeasure
	,IfcCountMeasure
	,IfcDescriptiveMeasure
	,IfcElectricCurrentMeasure
	,IfcLengthMeasure
	,IfcLuminousIntensityMeasure
	,IfcMassMeasure
	,IfcNonNegativeLengthMeasure
	,IfcNormalisedRatioMeasure
	,IfcNumericMeasure
	,IfcParameterValue
	,IfcPlaneAngleMeasure
	,IfcPositiveLengthMeasure
	,IfcPositivePlaneAngleMeasure
	,IfcPositiveRatioMeasure
	,IfcRatioMeasure
	,IfcSolidAngleMeasure
	,IfcThermodynamicTemperatureMeasure
	,IfcTimeMeasure
	,IfcVolumeMeasure);
END_TYPE;

TYPE IfcSimpleValue = SELECT
	(IfcBinary
	,IfcBoolean
	,IfcDate
	,IfcDateTime
	,IfcDuration
	,IfcIdentifier
	,IfcInteger
	,IfcLabel
	,IfcLogical
	,IfcPositiveInteger
	,IfcReal
	,IfcText
	,IfcTime
	,IfcTimeStamp);
END_TYPE;

TYPE IfcUnit = SELECT
	(IfcDerivedUnit
	,IfcMonetaryUnit
	,IfcNamedUnit);
END_TYPE;

TYPE IfcValue = SELECT
	(IfcDerivedMeasureValue
	,IfcMeasureValue
	,IfcSimpleValue);
END_TYPE;

ENTITY IfcContextDependentUnit
 SUBTYPE OF (IfcNamedUnit);
	Name : IfcLabel;
 INVERSE
	HasExternalReference : SET [0:?] OF IfcExternalReferenceRelationship FOR RelatedResourceObjects;
END_ENTITY;

ENTITY IfcConversionBasedUnit
 SUPERTYPE OF (ONEOF
    (IfcConversionBasedUnitWithOffset))
 SUBTYPE OF (IfcNamedUnit);
	Name : IfcLabel;
	ConversionFactor : IfcMeasureWithUnit;
 INVERSE
	HasExternalReference : SET [0:?] OF IfcExternalReferenceRelationship FOR RelatedResourceObjects;
END_ENTITY;

ENTITY IfcConversionBasedUnitWithOffset
 SUBTYPE OF (IfcConversionBasedUnit);
	ConversionOffset : IfcReal;
END_ENTITY;

ENTITY IfcDerivedUnit;
	Elements : SET [1:?] OF IfcDerivedUnitElement;
	UnitType : IfcDerivedUnitEnum;
	UserDefinedType : OPTIONAL IfcLabel;
 DERIVE
	Dimensions : IfcDimensionalExponents := IfcDeriveDimensionalExponents(Elements);
 WHERE
	WR1 : (SIZEOF (Elements) > 1) OR ((SIZEOF (Elements) = 1) AND (Elements[1].Exponent <> 1 ));
	WR2 : (UnitType <> IfcDerivedUnitEnum.USERDEFINED) OR
((UnitType = IfcDerivedUnitEnum.USERDEFINED) AND 
 (EXISTS(SELF.UserDefinedType)));
END_ENTITY;

ENTITY IfcDerivedUnitElement;
	Unit : IfcNamedUnit;
	Exponent : INTEGER;
END_ENTITY;

ENTITY IfcDimensionalExponents;
	LengthExponent : INTEGER;
	MassExponent : INTEGER;
	TimeExponent : INTEGER;
	ElectricCurrentExponent : INTEGER;
	ThermodynamicTemperatureExponent : INTEGER;
	AmountOfSubstanceExponent : INTEGER;
	LuminousIntensityExponent : INTEGER;
END_ENTITY;

ENTITY IfcMeasureWithUnit;
	ValueComponent : IfcValue;
	UnitComponent : IfcUnit;
END_ENTITY;

ENTITY IfcMonetaryUnit;
	Currency : IfcLabel;
END_ENTITY;

ENTITY IfcNamedUnit
 ABSTRACT SUPERTYPE OF (ONEOF
    (IfcContextDependentUnit
    ,IfcConversionBasedUnit
    ,IfcSIUnit));
	Dimensions : IfcDimensionalExponents;
	UnitType : IfcUnitEnum;
 WHERE
	WR1 : IfcCorrectDimensions (SELF.UnitType, SELF.Dimensions);
END_ENTITY;

ENTITY IfcSIUnit
 SUBTYPE OF (IfcNamedUnit);
	Prefix : OPTIONAL IfcSIPrefix;
	Name : IfcSIUnitName;
 DERIVE
	SELF\IfcNamedUnit.Dimensions : IfcDimensionalExponents := IfcDimensionsForSiUnit (SELF.Name);
END_ENTITY;

ENTITY IfcUnitAssignment;
	Units : SET [1:?] OF IfcUnit;
 WHERE
	WR01 : IfcCorrectUnitAssignment(Units);
END_ENTITY;

FUNCTION IfcCorrectDimensions
(m   : IfcUnitEnum; Dim : IfcDimensionalExponents) : LOGICAL;  
CASE m OF
  LENGTHUNIT : IF
    Dim = (IfcDimensionalExponents (1, 0, 0, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  MASSUNIT : IF
    Dim = (IfcDimensionalExponents (0, 1, 0, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  TIMEUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 1, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  ELECTRICCURRENTUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 0, 1, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  THERMODYNAMICTEMPERATUREUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 0, 0, 1, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  AMOUNTOFSUBSTANCEUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 0, 0, 0, 1, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  LUMINOUSINTENSITYUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 0, 0, 0, 0, 1))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  PLANEANGLEUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 0, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  SOLIDANGLEUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 0, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  AREAUNIT : IF
    Dim = (IfcDimensionalExponents (2, 0, 0, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  VOLUMEUNIT : IF
    Dim = (IfcDimensionalExponents (3, 0, 0, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;

  ABSORBEDDOSEUNIT : IF
    Dim = (IfcDimensionalExponents (2, 0, -2, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  RADIOACTIVITYUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, -1, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  ELECTRICCAPACITANCEUNIT : IF
    Dim = (IfcDimensionalExponents (-2, -1, 4, 2, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  DOSEEQUIVALENTUNIT : IF
    Dim = (IfcDimensionalExponents (2, 0, -2, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  ELECTRICCHARGEUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 1, 1, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  ELECTRICCONDUCTANCEUNIT : IF
    Dim = (IfcDimensionalExponents (-2, -1, 3, 2, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  ELECTRICVOLTAGEUNIT : IF
    Dim = (IfcDimensionalExponents (2, 1, -3, -1, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  ELECTRICRESISTANCEUNIT : IF
    Dim = (IfcDimensionalExponents (2, 1, -3, -2, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  ENERGYUNIT : IF
    Dim = (IfcDimensionalExponents (2, 1, -2, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  FORCEUNIT : IF
    Dim = (IfcDimensionalExponents (1, 1, -2, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  FREQUENCYUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, -1, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  INDUCTANCEUNIT : IF
    Dim = (IfcDimensionalExponents (2, 1, -2, -2, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  ILLUMINANCEUNIT : IF
    Dim = (IfcDimensionalExponents (-2, 0, 0, 0, 0, 0, 1))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  LUMINOUSFLUXUNIT : IF
    Dim = (IfcDimensionalExponents (0, 0, 0, 0, 0, 0, 1))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  MAGNETICFLUXUNIT : IF
    Dim = (IfcDimensionalExponents (2, 1, -2, -1, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  MAGNETICFLUXDENSITYUNIT : IF
    Dim = (IfcDimensionalExponents (0, 1, -2, -1, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  POWERUNIT : IF
    Dim = (IfcDimensionalExponents (2, 1, -3, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;
  PRESSUREUNIT : IF
    Dim = (IfcDimensionalExponents (-1, 1, -2, 0, 0, 0, 0))
      THEN RETURN(TRUE);
      ELSE RETURN(FALSE);
    END_IF;

  OTHERWISE :
    RETURN (UNKNOWN);
END_CASE;
END_FUNCTION;

FUNCTION IfcCorrectUnitAssignment
  (Units : SET [1:?] OF IfcUnit)
   : LOGICAL;

  LOCAL
    NamedUnitNumber    : INTEGER := 0;
    DerivedUnitNumber  : INTEGER := 0;
    MonetaryUnitNumber : INTEGER := 0;
    NamedUnitNames     : SET OF IfcUnitEnum := [];
    DerivedUnitNames   : SET OF IfcDerivedUnitEnum := [];
  END_LOCAL;

  NamedUnitNumber    := SIZEOF(QUERY(temp <* Units | ('IFCMEASURERESOURCE.IFCNAMEDUNIT' IN TYPEOF(temp)) AND NOT(temp\IfcNamedUnit.UnitType = IfcUnitEnum.USERDEFINED)));
  DerivedUnitNumber  := SIZEOF(QUERY(temp <* Units | ('IFCMEASURERESOURCE.IFCDERIVEDUNIT' IN TYPEOF(temp)) AND NOT(temp\IfcDerivedUnit.UnitType = IfcDerivedUnitEnum.USERDEFINED)));
  MonetaryUnitNumber := SIZEOF(QUERY(temp <* Units |  'IFCMEASURERESOURCE.IFCMONETARYUNIT' IN TYPEOF(temp)));

  REPEAT i := 1 TO SIZEOF(Units);
    IF (('IFCMEASURERESOURCE.IFCNAMEDUNIT' IN TYPEOF(Units[i])) AND NOT(Units[i]\IfcNamedUnit.UnitType = IfcUnitEnum.USERDEFINED)) THEN
        NamedUnitNames := NamedUnitNames + Units[i]\IfcNamedUnit.UnitType;
    END_IF;
    IF (('IFCMEASURERESOURCE.IFCDERIVEDUNIT' IN TYPEOF(Units[i])) AND NOT(Units[i]\IfcDerivedUnit.UnitType = IfcDerivedUnitEnum.USERDEFINED)) THEN
        DerivedUnitNames := DerivedUnitNames + Units[i]\IfcDerivedUnit.UnitType;
    END_IF;
  END_REPEAT;

  RETURN((SIZEOF(NamedUnitNames) = NamedUnitNumber) AND (SIZEOF(DerivedUnitNames) = DerivedUnitNumber) AND (MonetaryUnitNumber <= 1));
END_FUNCTION;

FUNCTION IfcDeriveDimensionalExponents
    (UnitElements : SET [1:?] OF IfcDerivedUnitElement)
    : IfcDimensionalExponents;  
    LOCAL
    Result : IfcDimensionalExponents :=
            IfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0);  
    END_LOCAL;
    REPEAT i := LOINDEX(UnitElements) TO HIINDEX(UnitElements);
        Result.LengthExponent := Result.LengthExponent +
          (UnitElements[i].Exponent *
           UnitElements[i].Unit.Dimensions.LengthExponent);
        Result.MassExponent := Result.MassExponent  +
          (UnitElements[i].Exponent *
           UnitElements[i].Unit.Dimensions.MassExponent);
        Result.TimeExponent := Result.TimeExponent +
          (UnitElements[i].Exponent *
           UnitElements[i].Unit.Dimensions.TimeExponent);
        Result.ElectricCurrentExponent := Result.ElectricCurrentExponent +
          (UnitElements[i].Exponent *
           UnitElements[i].Unit.Dimensions.ElectricCurrentExponent);
        Result.ThermodynamicTemperatureExponent := Result.ThermodynamicTemperatureExponent +
          (UnitElements[i].Exponent *
           UnitElements[i].Unit.Dimensions.ThermodynamicTemperatureExponent);
        Result.AmountOfSubstanceExponent := Result.AmountOfSubstanceExponent +
          (UnitElements[i].Exponent *
           UnitElements[i].Unit.Dimensions.AmountOfSubstanceExponent);
        Result.LuminousIntensityExponent := Result.LuminousIntensityExponent +
          (UnitElements[i].Exponent *
           UnitElements[i].Unit.Dimensions.LuminousIntensityExponent);
    END_REPEAT;  
    RETURN (Result);
END_FUNCTION;

FUNCTION IfcDimensionsForSiUnit
(n : IfcSiUnitName )     : IfcDimensionalExponents;
  CASE n OF
    METRE          : RETURN (IfcDimensionalExponents
                             (1, 0, 0, 0, 0, 0, 0));
    SQUARE_METRE   : RETURN (IfcDimensionalExponents
                             (2, 0, 0, 0, 0, 0, 0));
    CUBIC_METRE    : RETURN (IfcDimensionalExponents
                             (3, 0, 0, 0, 0, 0, 0));
    GRAM           : RETURN (IfcDimensionalExponents
                             (0, 1, 0, 0, 0, 0, 0));
    SECOND         : RETURN (IfcDimensionalExponents
                             (0, 0, 1, 0, 0, 0, 0));
    AMPERE         : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 1, 0, 0, 0));
    KELVIN         : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 0, 1, 0, 0));
    MOLE           : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 0, 0, 1, 0));
    CANDELA        : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 0, 0, 0, 1));
    RADIAN         : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 0, 0, 0, 0));
    STERADIAN      : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 0, 0, 0, 0));
    HERTZ          : RETURN (IfcDimensionalExponents
                             (0, 0, -1, 0, 0, 0, 0));
    NEWTON         : RETURN (IfcDimensionalExponents
                             (1, 1, -2, 0, 0, 0, 0));
    PASCAL         : RETURN (IfcDimensionalExponents
                             (-1, 1, -2, 0, 0, 0, 0));
    JOULE          : RETURN (IfcDimensionalExponents
                             (2, 1, -2, 0, 0, 0, 0));
    WATT           : RETURN (IfcDimensionalExponents
                             (2, 1, -3, 0, 0, 0, 0));
    COULOMB        : RETURN (IfcDimensionalExponents
                             (0, 0, 1, 1, 0, 0, 0));
    VOLT           : RETURN (IfcDimensionalExponents
                             (2, 1, -3, -1, 0, 0, 0));
    FARAD          : RETURN (IfcDimensionalExponents
                             (-2, -1, 4, 2, 0, 0, 0));
    OHM            : RETURN (IfcDimensionalExponents
                             (2, 1, -3, -2, 0, 0, 0));
    SIEMENS        : RETURN (IfcDimensionalExponents
                             (-2, -1, 3, 2, 0, 0, 0));
    WEBER          : RETURN (IfcDimensionalExponents
                             (2, 1, -2, -1, 0, 0, 0));
    TESLA          : RETURN (IfcDimensionalExponents
                             (0, 1, -2, -1, 0, 0, 0));
    HENRY          : RETURN (IfcDimensionalExponents
                             (2, 1, -2, -2, 0, 0, 0));
    DEGREE_CELSIUS : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 0, 1, 0, 0));
    LUMEN          : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 0, 0, 0, 1));
    LUX            : RETURN (IfcDimensionalExponents
                             (-2, 0, 0, 0, 0, 0, 1));
    BECQUEREL      : RETURN (IfcDimensionalExponents
                             (0, 0, -1, 0, 0, 0, 0));
    GRAY           : RETURN (IfcDimensionalExponents
                             (2, 0, -2, 0, 0, 0, 0));
    SIEVERT        : RETURN (IfcDimensionalExponents
                             (2, 0, -2, 0, 0, 0, 0));
    OTHERWISE      : RETURN (IfcDimensionalExponents
                             (0, 0, 0, 0, 0, 0, 0));
  END_CASE;
END_FUNCTION;

END_SCHEMA;
