(*
   $Id$
   ISO TC184/SC4/WG12 N4236 - ISO/TS 10303-1764 Shape feature - EXPRESS ARM
*)

SCHEMA Shape_feature_arm;
USE FROM Contextual_shape_positioning_arm;
REFERENCE FROM Characterizable_object_arm(bag_to_set);  -- ISO/TS 10303-1765
USE FROM Property_assignment_arm;

  TYPE sf_property_assignment_select = SELECT BASED_ON property_assignment_select WITH 
    (Shape_element, 
     Characterizable_object);
  END_TYPE; 

  ENTITY Shape_feature_definition
    SUBTYPE OF (Characterizable_object);
    DERIVE
      feature_model : SET [1:?] OF Geometric_model := get_geometric_model(of_shape); 
    INVERSE
      of_shape : Item_shape FOR described_element;
    WHERE
      WR1: EXISTS(feature_model);
  END_ENTITY;

ENTITY Shape_feature_occurrence 
  ABSTRACT SUPERTYPE OF (ONEOF (Instanced_feature, Placed_feature))
  SUBTYPE OF (Shape_element);
END_ENTITY;

ENTITY Instanced_feature  
  SUBTYPE OF (Shape_feature_occurrence, Shape_feature_definition);
END_ENTITY;

ENTITY Placed_feature  
  SUBTYPE OF (Shape_feature_occurrence);
   definition : Shape_feature_definition;
END_ENTITY;

 FUNCTION get_geometric_model(input : Item_shape) : SET OF Geometric_model;
 LOCAL
  sda : SET OF Shape_description_association := [];
  gm : SET OF Geometric_model := [];
 END_LOCAL;
 
  sda := bag_to_set(USEDIN(input,
	 	'SHAPE_PROPERTY_ASSIGNMENT_ARM.' + 
	 	'SHAPE_DESCRIPTION_ASSOCIATION.' + 'REPRESENTED_CHARACTERISTIC'));
 
 REPEAT i := 1 to SIZEOF(sda) BY 1;
  gm := gm + sda[i].representation;
 END_REPEAT;
 RETURN(gm);
END_FUNCTION;

END_SCHEMA;
