(*
   $Id$
   ISO TC184/SC4/WG12 N4065 - ISO/TS 10303-1706 Non feature shape element - EXPRESS ARM
   Supersedes ISO TC184/SC4/WG12 N3495
*)

SCHEMA Non_feature_shape_element_arm; 

	USE FROM Physical_unit_shape_with_parameters_arm;	-- ISO/TS 10303-1730
  
  TYPE ee_product_definition_with_annotation_elements = EXTENSIBLE GENERIC_ENTITY SELECT;
  END_TYPE;

	TYPE nfse_usage_concept = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON usage_concept WITH 
		(Non_feature_shape_element);
	END_TYPE;

    TYPE nfse_feature_or_non_feature_usage = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON feature_or_non_feature_usage WITH 
		(Usage_view_level_non_feature_shape_model);
	END_TYPE;
	
  TYPE view_shape_select = EXTENSIBLE GENERIC_ENTITY SELECT
        (Physical_unit_shape_model);
  END_TYPE;
  
  ENTITY Design_view_level_non_feature_shape_model
    SUBTYPE OF (Non_feature_shape_model);
      SELF\Non_feature_shape_model.model_shape        : Physical_unit_shape_model;
    WHERE
      WR1 : SELF\Geometric_model.context_of_items :=: SELF\Non_feature_shape_model.model_shape\Geometric_model.context_of_items;
      WR2: SIZEOF(USEDIN(SELF, 'EXTENDED_BASIC_GEOMETRY_ARM.GEOMETRIC_MODEL_RELATIONSHIP.REP_1')) = 0;
      WR3: SIZEOF(USEDIN(SELF, 'CONTEXTUAL_SHAPE_POSITIONING_ARM.GEOMETRIC_PLACEMENT_OPERATION.TEMPLATE_DEFINITION')) = 0;
      WR4: SELF\Non_feature_shape_model.associated_element.scope :=:
           SELF\Non_feature_shape_model.model_shape\Physical_unit_shape_model.shape_characterized_definition;
  END_ENTITY;
  
  ENTITY Interface_plane
    SUBTYPE OF (Non_feature_shape_element);
   WHERE
    WR1 : (SELF\Shape_element.element_name = 'interface plane');
  END_ENTITY;

  ENTITY Non_feature_shape_model
  SUPERTYPE OF (ONEOF (Design_view_level_non_feature_shape_model,
	    Usage_view_level_non_feature_shape_model))   
    SUBTYPE OF (Geometric_model);
      associated_element : Non_feature_shape_element;
      model_shape        : OPTIONAL Geometric_model;
    WHERE
      WR1 : TYPEOF(SELF) <> TYPEOF(model_shape);
      WR2 : NOT EXISTS(SELF\Representation.id);
      WR3 : SIZEOF(USEDIN(SELF, 'SHAPE_PROPERTY_ASSIGNMENT_ARM.SHAPE_DESCRIPTION_ASSOCIATION.REPRESENTATION'))=0;            
  END_ENTITY;

  ENTITY Non_feature_shape_element
    SUBTYPE OF (Shape_element);
      SELF\Shape_element.element_name : STRING;
      SELF\Shape_element.containing_shape RENAMED scope : ee_product_definition_with_annotation_elements;
    INVERSE
      element_shape            : SET[0:?] OF non_feature_shape_model FOR associated_element;
      associated_usage_concept : SET[0:?] OF usage_concept_usage_relationship FOR associated_usage;
    UNIQUE
      UR1 : SELF\Shape_element.element_name, scope;
    WHERE
      WR1 : NOT ((SIZEOF(associated_usage_concept) > 0) OR (SIZEOF(element_shape) > 0));
      WR2 : 'SHAPE_PROPERTY_ASSIGNMENT_ARM.ITEM_SHAPE' IN TYPEOF(scope);
  END_ENTITY;

  ENTITY Non_feature_shape_element_relationship
    SUBTYPE OF (Shape_element_relationship);
      SELF\Shape_element_relationship.relating : Non_feature_shape_element;    
      SELF\Shape_element_relationship.related : Non_feature_shape_element;
    UNIQUE
      UR1 : SELF\Shape_element_relationship.related, SELF\Shape_element_relationship.relating;
  END_ENTITY;

   ENTITY Reference_graphic_registration_mark
    SUBTYPE OF (Non_feature_shape_element);
  END_ENTITY;

  ENTITY Seating_plane
    SUBTYPE OF (Non_feature_shape_element);
   WHERE
    WR1 : (SELF\Shape_element.element_name = 'seating plane');
  END_ENTITY;

  ENTITY Usage_view_level_non_feature_shape_model
    ABSTRACT SUPERTYPE
    SUBTYPE OF (Non_feature_shape_model);
      SELF\Non_feature_shape_model.associated_element : View_level_non_feature_shape_element;    
      SELF\Non_feature_shape_model.model_shape        : view_shape_select;
    WHERE
      WR1 : SELF\Geometric_model.context_of_items = SELF\Non_feature_shape_model.model_shape\Geometric_model.context_of_items;
  END_ENTITY;

  ENTITY View_level_non_feature_shape_element
    SUBTYPE OF (Non_feature_shape_element);
     WHERE
      WR1: NOT(SIZEOF(SELF\Non_feature_shape_element.element_shape) > 0) OR
      valid_es('NON_FEATURE_SHAPE_ELEMENT_ARM.USAGE_VIEW_LEVEL_NON_FEATURE_SHAPE_MODEL',
      (SELF\Non_feature_shape_element.element_shape));
      WR2 : NOT EXISTS(SELF\Shape_element.description);
  END_ENTITY;
  
  FUNCTION valid_es(input1 : STRING;
                  input2 : SET OF NON_FEATURE_SHAPE_MODEL) : BOOLEAN;
   REPEAT i := 1 to HIINDEX(input2);
    IF NOT (input1 IN TYPEOF(input2)) THEN RETURN(FALSE);
    END_IF;
   END_REPEAT;
    RETURN(TRUE);
  END_FUNCTION;

END_SCHEMA;
