(*
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 IFCQUANTITYRESOURCE;

REFERENCE FROM IFCMEASURERESOURCE
(
  IfcLengthMeasure,
  IfcAreaMeasure,
  IfcVolumeMeasure,
  IfcCountMeasure,
  IfcMassMeasure,
  IfcLabel,
  IfcText,
  IfcNamedUnit,
  IfcSiUnit,
  IfcUnitEnum,
  IfcTimeMeasure
);

REFERENCE FROM IFCEXTERNALREFERENCERESOURCE
(
  IfcExternalReferenceRelationship
);

ENTITY IfcPhysicalComplexQuantity
 SUBTYPE OF (IfcPhysicalQuantity);
	HasQuantities : SET [1:?] OF IfcPhysicalQuantity;
	Discrimination : IfcLabel;
	Quality : OPTIONAL IfcLabel;
	Usage : OPTIONAL IfcLabel;
 WHERE
	NoSelfReference : SIZEOF(QUERY(temp <* HasQuantities | SELF :=: temp)) = 0;
	UniqueQuantityNames : IfcUniqueQuantityNames(HasQuantities);
END_ENTITY;

ENTITY IfcPhysicalQuantity
 ABSTRACT SUPERTYPE OF (ONEOF
    (IfcPhysicalComplexQuantity
    ,IfcPhysicalSimpleQuantity));
	Name : IfcLabel;
	Description : OPTIONAL IfcText;
 INVERSE
	HasExternalReferences : SET [0:?] OF IfcExternalReferenceRelationship FOR RelatedResourceObjects;
	PartOfComplex : SET [0:1] OF IfcPhysicalComplexQuantity FOR HasQuantities;
END_ENTITY;

ENTITY IfcPhysicalSimpleQuantity
 ABSTRACT SUPERTYPE OF (ONEOF
    (IfcQuantityArea
    ,IfcQuantityCount
    ,IfcQuantityLength
    ,IfcQuantityTime
    ,IfcQuantityVolume
    ,IfcQuantityWeight))
 SUBTYPE OF (IfcPhysicalQuantity);
	Unit : OPTIONAL IfcNamedUnit;
END_ENTITY;

ENTITY IfcQuantityArea
 SUBTYPE OF (IfcPhysicalSimpleQuantity);
	AreaValue : IfcAreaMeasure;
	Formula : OPTIONAL IfcLabel;
 WHERE
	WR21 : NOT(EXISTS(SELF\IfcPhysicalSimpleQuantity.Unit)) OR
   (SELF\IfcPhysicalSimpleQuantity.Unit.UnitType = IfcUnitEnum.AREAUNIT);
	WR22 : AreaValue >= 0.;
END_ENTITY;

ENTITY IfcQuantityCount
 SUBTYPE OF (IfcPhysicalSimpleQuantity);
	CountValue : IfcCountMeasure;
	Formula : OPTIONAL IfcLabel;
 WHERE
	WR21 : CountValue >= 0.;
END_ENTITY;

ENTITY IfcQuantityLength
 SUBTYPE OF (IfcPhysicalSimpleQuantity);
	LengthValue : IfcLengthMeasure;
	Formula : OPTIONAL IfcLabel;
 WHERE
	WR21 : NOT(EXISTS(SELF\IfcPhysicalSimpleQuantity.Unit)) OR
   (SELF\IfcPhysicalSimpleQuantity.Unit.UnitType = IfcUnitEnum.LENGTHUNIT);
	WR22 : LengthValue >= 0.;
END_ENTITY;

ENTITY IfcQuantityTime
 SUBTYPE OF (IfcPhysicalSimpleQuantity);
	TimeValue : IfcTimeMeasure;
	Formula : OPTIONAL IfcLabel;
 WHERE
	WR21 : NOT(EXISTS(SELF\IfcPhysicalSimpleQuantity.Unit)) OR
   (SELF\IfcPhysicalSimpleQuantity.Unit.UnitType = IfcUnitEnum.TIMEUNIT);
	WR22 : TimeValue >= 0.;
END_ENTITY;

ENTITY IfcQuantityVolume
 SUBTYPE OF (IfcPhysicalSimpleQuantity);
	VolumeValue : IfcVolumeMeasure;
	Formula : OPTIONAL IfcLabel;
 WHERE
	WR21 : NOT(EXISTS(SELF\IfcPhysicalSimpleQuantity.Unit)) OR
   (SELF\IfcPhysicalSimpleQuantity.Unit.UnitType = IfcUnitEnum.VOLUMEUNIT);
	WR22 : VolumeValue >= 0.;
END_ENTITY;

ENTITY IfcQuantityWeight
 SUBTYPE OF (IfcPhysicalSimpleQuantity);
	WeightValue : IfcMassMeasure;
	Formula : OPTIONAL IfcLabel;
 WHERE
	WR21 : NOT(EXISTS(SELF\IfcPhysicalSimpleQuantity.Unit)) OR
   (SELF\IfcPhysicalSimpleQuantity.Unit.UnitType = IfcUnitEnum.MASSUNIT);
	WR22 : WeightValue >= 0.;
END_ENTITY;

FUNCTION IfcUniqueQuantityNames
(Properties : SET [1:?] OF IfcPhysicalQuantity)
:LOGICAL;

LOCAL
  Names : SET OF IfcLabel := [];
END_LOCAL;

REPEAT i:=1 TO HIINDEX(Properties);
  Names := Names + Properties[i].Name;
END_REPEAT;
RETURN (SIZEOF(Names) = SIZEOF(Properties));
END_FUNCTION;

END_SCHEMA;
