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

REFERENCE FROM IFCPROPERTYRESOURCE
(
  IfcPropertySingleValue,
  IfcPropertyBoundedValue,
  IfcPropertyTableValue,
  IfcExtendedProperties
);

REFERENCE FROM IFCMEASURERESOURCE
(
  IfcLengthMeasure,
  IfcPositiveLengthMeasure,
  IfcLogical,
  IfcLabel,
  IfcSiUnit,
  IfcText,
  IfcNormalisedRatioMeasure,
  IfcNonNegativeLengthMeasure,
  IfcInteger
);

REFERENCE FROM IFCREPRESENTATIONRESOURCE
(
  IfcMaterialDefinitionRepresentation
);

REFERENCE FROM IFCEXTERNALREFERENCERESOURCE
(
  IfcClassificationSelect,
  IfcClassificationReference,
  IfcExternalReferenceRelationship,
  IfcResourceLevelRelationship
);

REFERENCE FROM IFCPROFILERESOURCE
(
  IfcProfileDef,
  IfcCompositeProfileDef
);

REFERENCE FROM IFCPRODUCTEXTENSION
(
  IfcRelAssociatesMaterial
);

REFERENCE FROM IFCGEOMETRYRESOURCE
(
);

REFERENCE FROM IFCPRESENTATIONAPPEARANCERESOURCE
(
  IfcNullStyle
);

TYPE IfcCardinalPointReference = INTEGER;
 WHERE
	GreaterThanZero : SELF > 0;
END_TYPE;

TYPE IfcDirectionSenseEnum = ENUMERATION OF
	(POSITIVE
	,NEGATIVE);
END_TYPE;

TYPE IfcLayerSetDirectionEnum = ENUMERATION OF
	(AXIS1
	,AXIS2
	,AXIS3);
END_TYPE;

TYPE IfcMaterialSelect = SELECT
	(IfcMaterialDefinition
	,IfcMaterialList
	,IfcMaterialUsageDefinition);
END_TYPE;

ENTITY IfcMaterial
 SUBTYPE OF (IfcMaterialDefinition);
	Name : IfcLabel;
	Description : OPTIONAL IfcText;
	Category : OPTIONAL IfcLabel;
 INVERSE
	HasRepresentation : SET [0:1] OF IfcMaterialDefinitionRepresentation FOR RepresentedMaterial;
	IsRelatedWith : SET [0:?] OF IfcMaterialRelationship FOR RelatedMaterials;
	RelatesTo : SET [0:1] OF IfcMaterialRelationship FOR RelatingMaterial;
END_ENTITY;

ENTITY IfcMaterialClassificationRelationship;
	MaterialClassifications : SET [1:?] OF IfcClassificationSelect;
	ClassifiedMaterial : IfcMaterial;
END_ENTITY;

ENTITY IfcMaterialConstituent
 SUBTYPE OF (IfcMaterialDefinition);
	Name : OPTIONAL IfcLabel;
	Description : OPTIONAL IfcText;
	Material : IfcMaterial;
	Fraction : OPTIONAL IfcNormalisedRatioMeasure;
	Category : OPTIONAL IfcLabel;
 INVERSE
	ToMaterialConstituentSet : IfcMaterialConstituentSet FOR MaterialConstituents;
END_ENTITY;

ENTITY IfcMaterialConstituentSet
 SUBTYPE OF (IfcMaterialDefinition);
	Name : OPTIONAL IfcLabel;
	Description : OPTIONAL IfcText;
	MaterialConstituents : OPTIONAL SET [1:?] OF IfcMaterialConstituent;
END_ENTITY;

ENTITY IfcMaterialDefinition
 ABSTRACT SUPERTYPE OF (ONEOF
    (IfcMaterial
    ,IfcMaterialConstituent
    ,IfcMaterialConstituentSet
    ,IfcMaterialLayer
    ,IfcMaterialLayerSet
    ,IfcMaterialProfile
    ,IfcMaterialProfileSet));
 INVERSE
	AssociatedTo : SET [0:?] OF IfcRelAssociatesMaterial FOR RelatingMaterial;
	HasExternalReferences : SET [0:?] OF IfcExternalReferenceRelationship FOR RelatedResourceObjects;
	HasProperties : SET [0:?] OF IfcMaterialProperties FOR Material;
END_ENTITY;

ENTITY IfcMaterialLayer
 SUPERTYPE OF (ONEOF
    (IfcMaterialLayerWithOffsets))
 SUBTYPE OF (IfcMaterialDefinition);
	Material : OPTIONAL IfcMaterial;
	LayerThickness : IfcNonNegativeLengthMeasure;
	IsVentilated : OPTIONAL IfcLogical;
	Name : OPTIONAL IfcLabel;
	Description : OPTIONAL IfcText;
	Category : OPTIONAL IfcLabel;
	Priority : OPTIONAL IfcInteger;
 INVERSE
	ToMaterialLayerSet : IfcMaterialLayerSet FOR MaterialLayers;
 WHERE
	NormalizedPriority : NOT(EXISTS(Priority)) OR {0 <= Priority <= 100};
END_ENTITY;

ENTITY IfcMaterialLayerSet
 SUBTYPE OF (IfcMaterialDefinition);
	MaterialLayers : LIST [1:?] OF IfcMaterialLayer;
	LayerSetName : OPTIONAL IfcLabel;
	Description : OPTIONAL IfcText;
 DERIVE
	TotalThickness : IfcLengthMeasure := IfcMlsTotalThickness(SELF);
END_ENTITY;

ENTITY IfcMaterialLayerSetUsage
 SUBTYPE OF (IfcMaterialUsageDefinition);
	ForLayerSet : IfcMaterialLayerSet;
	LayerSetDirection : IfcLayerSetDirectionEnum;
	DirectionSense : IfcDirectionSenseEnum;
	OffsetFromReferenceLine : IfcLengthMeasure;
	ReferenceExtent : OPTIONAL IfcPositiveLengthMeasure;
END_ENTITY;

ENTITY IfcMaterialLayerWithOffsets
 SUBTYPE OF (IfcMaterialLayer);
	OffsetDirection : IfcLayerSetDirectionEnum;
	OffsetValues : ARRAY [1:2] OF IfcLengthMeasure;
END_ENTITY;

ENTITY IfcMaterialList;
	Materials : LIST [1:?] OF IfcMaterial;
END_ENTITY;

ENTITY IfcMaterialProfile
 SUPERTYPE OF (ONEOF
    (IfcMaterialProfileWithOffsets))
 SUBTYPE OF (IfcMaterialDefinition);
	Name : OPTIONAL IfcLabel;
	Description : OPTIONAL IfcText;
	Material : OPTIONAL IfcMaterial;
	Profile : IfcProfileDef;
	Priority : OPTIONAL IfcInteger;
	Category : OPTIONAL IfcLabel;
 INVERSE
	ToMaterialProfileSet : IfcMaterialProfileSet FOR MaterialProfiles;
 WHERE
	NormalizedPriority : NOT(EXISTS(Priority)) OR {0 <= Priority <= 100};
END_ENTITY;

ENTITY IfcMaterialProfileSet
 SUBTYPE OF (IfcMaterialDefinition);
	Name : OPTIONAL IfcLabel;
	Description : OPTIONAL IfcText;
	MaterialProfiles : LIST [1:?] OF IfcMaterialProfile;
	CompositeProfile : OPTIONAL IfcCompositeProfileDef;
END_ENTITY;

ENTITY IfcMaterialProfileSetUsage
 SUPERTYPE OF (ONEOF
    (IfcMaterialProfileSetUsageTapering))
 SUBTYPE OF (IfcMaterialUsageDefinition);
	ForProfileSet : IfcMaterialProfileSet;
	CardinalPoint : OPTIONAL IfcCardinalPointReference;
	ReferenceExtent : OPTIONAL IfcPositiveLengthMeasure;
END_ENTITY;

ENTITY IfcMaterialProfileSetUsageTapering
 SUBTYPE OF (IfcMaterialProfileSetUsage);
	ForProfileEndSet : IfcMaterialProfileSet;
	CardinalEndPoint : OPTIONAL IfcCardinalPointReference;
END_ENTITY;

ENTITY IfcMaterialProfileWithOffsets
 SUBTYPE OF (IfcMaterialProfile);
	OffsetValues : ARRAY [1:2] OF IfcLengthMeasure;
END_ENTITY;

ENTITY IfcMaterialProperties
 SUBTYPE OF (IfcExtendedProperties);
	Material : IfcMaterialDefinition;
END_ENTITY;

ENTITY IfcMaterialRelationship
 SUBTYPE OF (IfcResourceLevelRelationship);
	RelatingMaterial : IfcMaterial;
	RelatedMaterials : SET [1:?] OF IfcMaterial;
	Expression : OPTIONAL IfcLabel;
END_ENTITY;

ENTITY IfcMaterialUsageDefinition
 ABSTRACT SUPERTYPE OF (ONEOF
    (IfcMaterialLayerSetUsage
    ,IfcMaterialProfileSetUsage));
 INVERSE
	AssociatedTo : SET [1:?] OF IfcRelAssociatesMaterial FOR RelatingMaterial;
END_ENTITY;

FUNCTION IfcMlsTotalThickness
(LayerSet : IfcMaterialLayerSet) : IfcLengthMeasure;
  LOCAL
    Max : IfcLengthMeasure := LayerSet.MaterialLayers[1].LayerThickness;    
  END_LOCAL;

  IF SIZEOF(LayerSet.MaterialLayers) > 1 THEN
    REPEAT i := 2 TO HIINDEX(LayerSet.MaterialLayers);
       Max := Max + LayerSet.MaterialLayers[i].LayerThickness;
    END_REPEAT;
  END_IF;
  RETURN (Max);
END_FUNCTION;

END_SCHEMA;
