Schema: product_property_representation_schema

Source : ISO 10303-41



SCHEMA product_property_representation_schema;

REFERENCE FROM basic_attribute_schema   -- ISO 10303-41
  (description_attribute,
   description_attribute_select,
   get_description_value,
   get_name_value,
   name_attribute,
   name_attribute_select);

REFERENCE FROM material_property_definition_schema   -- ISO 10303-45
  (property_definition_relationship);

REFERENCE FROM product_definition_schema   -- ISO 10303-41
  (product_definition,
   product_definition_relationship);

REFERENCE FROM product_property_definition_schema   -- ISO 10303-41
  (characterized_object,
   characterized_definition,
   general_property,
   product_definition_shape,
   property_definition,
   shape_aspect,
   shape_aspect_relationship);

REFERENCE FROM product_structure_schema   -- ISO 10303-44
  (product_definition_specified_occurrence);

REFERENCE FROM representation_schema   -- ISO 10303-43
  (representation,
   representation_item,
   representation_relationship,
   representation_reference,
   using_representations,
   mapped_item,
   representation_context,
   representation_map,
   list_representation_item,
   set_representation_item,
   get_representations_for_items);

REFERENCE FROM support_resource_schema   -- ISO 10303-41
  (bag_to_set,
   label,
   text);


TYPE chained_representation_link = SELECT
   (mapped_item,
    representation_context,
    representation_relationship);
END_TYPE;

TYPE item_identified_representation_usage_definition = EXTENSIBLE GENERIC_ENTITY SELECT
   (represented_definition);
END_TYPE;

TYPE item_identified_representation_usage_select = SELECT
   (representation_item,
    list_representation_item,
    set_representation_item);
END_TYPE;

TYPE pprs_description_attribute_select = SELECT BASED_ON description_attribute_select WITH
   (context_dependent_shape_representation,
    property_definition_representation);
END_TYPE;

TYPE pprs_name_attribute_select = SELECT BASED_ON name_attribute_select WITH
   (context_dependent_shape_representation,
    property_definition_representation);
END_TYPE;

TYPE represented_definition = SELECT
   (general_property,
    property_definition,
    property_definition_relationship,
    shape_aspect,
    shape_aspect_relationship);
END_TYPE;

ENTITY chain_based_item_identified_representation_usage
  SUBTYPE OF (item_identified_representation_usage);
  nodes : LIST[2:?] OF UNIQUE representation;
  undirected_link : LIST[1:?] OF chained_representation_link;
DERIVE
  root : representation := nodes[1];
  SELF\item_identified_representation_usage.used_representation RENAMED leaf : representation := nodes[HIINDEX(nodes)];
  directed_link : LIST[1:?] OF representation_relationship := get_directed_link(nodes, undirected_link);
WHERE
  WR1: EXISTS(directed_link);
END_ENTITY;

ENTITY characterized_chain_based_item_within_representation
  SUBTYPE OF (characterized_item_within_representation);
  nodes : LIST[2:?] OF UNIQUE representation;
  undirected_link : LIST[1:?] OF chained_representation_link;
DERIVE
  root : representation := nodes[1];
  SELF\characterized_item_within_representation.rep RENAMED leaf : representation := nodes[HIINDEX(nodes)];
  directed_link : LIST[1:?] OF representation_relationship := get_directed_link(nodes, undirected_link);
WHERE
  WR1: EXISTS(directed_link);
END_ENTITY;

ENTITY characterized_item_within_representation
  SUBTYPE OF (characterized_object);
  item : representation_item;
  rep : representation;
UNIQUE
  UR1: item, rep;
WHERE
  WR1: rep IN using_representations(item);
END_ENTITY;

ENTITY context_dependent_shape_representation;
  representation_relation : shape_representation_relationship;
  represented_product_relation : product_definition_shape;
DERIVE
  description : text := get_description_value(SELF);
  name : label := get_name_value(SELF);
WHERE
  WR1: 'PRODUCT_DEFINITION_SCHEMA.PRODUCT_DEFINITION_RELATIONSHIP' IN TYPEOF(represented_product_relation\property_definition.definition);
  WR2: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.DESCRIPTION_ATTRIBUTE.DESCRIBED_ITEM')) <= 1;
  WR3: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.NAME_ATTRIBUTE.NAMED_ITEM')) <= 1;
END_ENTITY;

ENTITY item_identified_representation_usage;
  name : label;
  description : OPTIONAL text;
  definition : item_identified_representation_usage_definition;
  used_representation : representation;
  identified_item : item_identified_representation_usage_select;
UNIQUE
  UR1: used_representation, identified_item;
  UR2: used_representation, definition;
WHERE
  WR1: valid_identified_item_in_representation(identified_item, used_representation);
END_ENTITY;

ENTITY property_definition_representation;
  definition : represented_definition;
  used_representation : representation;
DERIVE
  description : text := get_description_value(SELF);
  name : label := get_name_value(SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.DESCRIPTION_ATTRIBUTE.DESCRIBED_ITEM')) <= 1;
  WR2: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.NAME_ATTRIBUTE.NAMED_ITEM')) <= 1;
END_ENTITY;

ENTITY shape_definition_representation
  SUBTYPE OF (property_definition_representation);
  SELF\property_definition_representation.definition : property_definition;
  SELF\property_definition_representation.used_representation : shape_representation;
WHERE
  WR1: ('PRODUCT_PROPERTY_DEFINITION_SCHEMA.PRODUCT_DEFINITION_SHAPE' IN TYPEOF(definition)) OR ('PRODUCT_PROPERTY_DEFINITION_SCHEMA.SHAPE_DEFINITION' IN TYPEOF(definition\property_definition.definition));
END_ENTITY;

ENTITY shape_representation
  SUBTYPE OF (representation);
END_ENTITY;

ENTITY shape_representation_reference
  SUBTYPE OF (representation_reference);
END_ENTITY;

ENTITY shape_representation_relationship
  SUBTYPE OF (representation_relationship);
WHERE
  WR1: SIZEOF(['PRODUCT_PROPERTY_REPRESENTATION_SCHEMA.SHAPE_REPRESENTATION', 'PRODUCT_PROPERTY_REPRESENTATION_SCHEMA.SHAPE_REPRESENTATION_REFERENCE'] * (TYPEOF(SELF\representation_relationship.rep_1) + TYPEOF(SELF\representation_relationship.rep_2))) >= 1;
END_ENTITY;

ENTITY specified_occurrence_context_dependent_shape_representation
  SUBTYPE OF (context_dependent_shape_representation);
  sub_element : product_definition_specified_occurrence;
WHERE
  WR1: 'PRODUCT_DEFINITION_SCHEMA.PRODUCT_DEFINITION_OCCURRENCE' IN TYPEOF(SELF.represented_product_relation.definition.related_product_definition);
  WR2: sub_element IN represented_product_relation.definition.related_product_definition.descendant_occurrences;
END_ENTITY;

FUNCTION get_directed_link
 (nodes : LIST OF representation; undirected_link : LIST OF chained_representation_link) : LIST OF representation_relationship;
  LOCAL
  directed_link : LIST OF representation_relationship := [];
    END_LOCAL;
      IF (SIZEOF(nodes) <> SIZEOF(undirected_link) + 1) OR (VALUE_UNIQUE(nodes) = FALSE)
  THEN
    RETURN(?);
  END_IF;
      REPEAT i := 1 TO SIZEOF(undirected_link);
    CASE TRUE OF
      ('REPRESENTATION_SCHEMA.REPRESENTATION_CONTEXT' IN TYPEOF(undirected_link[i])) : BEGIN  
                                                                                              IF ((nodes[i]\representation.context_of_items :=:
                                                                                                   undirected_link[i]) AND
                                                                                                  (nodes[i +
                                                                                                         1]\representation.context_of_items :=:
                                                                                                   undirected_link[i]))
                                                                                              THEN
                                                                                                INSERT(directed_link,
                                                                                                       representation_relationship('',
                                                                                                                                   '',
                                                                                                                                   nodes[i +
                                                                                                                                         1],
                                                                                                                                   nodes[i]),
                                                                                                       (i - 1));
                                                                                              ELSE
                                                                                                RETURN(?);
                                                                                              END_IF;
      END;
      ('REPRESENTATION_SCHEMA.REPRESENTATION_RELATIONSHIP' IN TYPEOF(undirected_link[i])) : BEGIN  
                                                                                                   IF (((nodes[i] :=:
                                                                                                         undirected_link[i]\representation_relationship.rep_1) AND
                                                                                                        (nodes[i +
                                                                                                               1] :=:
                                                                                                         undirected_link[i]\representation_relationship.rep_2)) OR
                                                                                                       ((nodes[i] :=:
                                                                                                         undirected_link[i]\representation_relationship.rep_2) AND
                                                                                                        (nodes[i +
                                                                                                               1] :=:
                                                                                                         undirected_link[i]\representation_relationship.rep_1)))
                                                                                                   THEN
                                                                                                     INSERT(directed_link,
                                                                                                            representation_relationship('',
                                                                                                                                        '',
                                                                                                                                        nodes[i +
                                                                                                                                              1],
                                                                                                                                        nodes[i]),
                                                                                                            (i - 1));
                                                                                                   ELSE
                                                                                                     RETURN(?);
                                                                                                   END_IF;
      END;
      ('REPRESENTATION_SCHEMA.MAPPED_ITEM' IN TYPEOF(undirected_link[i])) : BEGIN  
                                                                                   IF ((nodes[i] IN
                                                                                        using_representations(undirected_link[i])) AND
                                                                                       (nodes[i + 1] :=:
                                                                                        undirected_link[i]\mapped_item.mapping_source\representation_map.mapped_representation))
                                                                                   THEN
                                                                                     INSERT(directed_link,
                                                                                            representation_relationship('',
                                                                                                                        '',
                                                                                                                        nodes[i +
                                                                                                                              1],
                                                                                                                        nodes[i]),
                                                                                            (i - 1));
                                                                                   ELSE
                                                                                     RETURN(?);
                                                                                   END_IF;
      END;
      OTHERWISE: RETURN(?);
    END_CASE;
  END_REPEAT;
      IF (VALUE_UNIQUE(directed_link) = FALSE)
  THEN
    RETURN(?);
  END_IF;
      RETURN(directed_link);
END_FUNCTION;

FUNCTION get_property_definition_representations
 (c_def_instance : characterized_definition) : SET OF property_definition_representation;
  LOCAL
  pd_set : SET OF property_definition := [];
  pdr_set : SET OF property_definition_representation := [];
    END_LOCAL;
      pd_set := bag_to_set(USEDIN(c_def_instance, 'PRODUCT_PROPERTY_DEFINITION_SCHEMA.PROPERTY_DEFINITION.DEFINITION'));
      IF (SIZEOF(pd_set) < 1)
  THEN
    RETURN(pdr_set);
  END_IF;
      REPEAT i := 1 TO HIINDEX(pd_set);
    pdr_set := pdr_set +
               bag_to_set(USEDIN(pd_set[i], 'PRODUCT_PROPERTY_REPRESENTATION_SCHEMA.PROPERTY_DEFINITION_REPRESENTATION.DEFINITION'));
  END_REPEAT;
      RETURN(pdr_set);
END_FUNCTION;

FUNCTION relatives_of_product_definitions
 (definition_set : SET OF product_definition; relation_subtype : STRING) : SET OF product_definition;
FUNCTION local_relatives_of_product_definitions(definition_set : SET OF product_definition;
                                                                 total_definitions : SET OF product_definition;
                                                                 relation_subtype : STRING) : SET OF product_definition;
  LOCAL
    local_def   : SET OF product_definition              := [];
    local_pdr   : SET OF product_definition_relationship := [];
    local_total : SET OF product_definition              := [];
  END_LOCAL;
    REPEAT i := 1 TO HIINDEX(definition_set);
      local_pdr := local_pdr + bag_to_set(USEDIN(definition_set[i], relation_subtype + '.RELATING_PRODUCT_DEFINITION'));
    END_REPEAT;
    REPEAT i := 1 TO HIINDEX(local_pdr);
      local_def := local_def + local_pdr[i].related_product_definition;
    END_REPEAT;
    IF (SIZEOF(local_def) - SIZEOF(total_definitions)) = 0
    THEN
      RETURN(local_def);
    ELSE
      local_total := total_definitions + local_def;
      RETURN(local_def +
             (local_relatives_of_product_definitions(local_def - total_definitions, local_total, relation_subtype)));
    END_IF;
  END_FUNCTION;
      RETURN(local_relatives_of_product_definitions(definition_set, definition_set, relation_subtype));
END_FUNCTION;

FUNCTION relatives_of_shape_representations
 (shape_representation_set : SET OF shape_representation) : SET OF shape_representation;
FUNCTION local_relatives_of_shape_representations(shape_representation_set : SET OF shape_representation;
                                                                   total_reps : SET OF shape_representation) : SET OF shape_representation;
  LOCAL
    local_shape_rep : SET OF shape_representation              := [];
    local_srr       : SET OF shape_representation_relationship := [];
    local_total     : SET OF shape_representation              := [];
  END_LOCAL;
    REPEAT i := 1 TO HIINDEX(shape_representation_set);
      local_srr := local_srr +
                   QUERY(rr
                         <* bag_to_set(USEDIN(shape_representation_set[i], 'REPRESENTATION_SCHEMA.REPRESENTATION_RELATIONSHIP.REP_1'))
                         | 'PRODUCT_PROPERTY_REPRESENTATION_SCHEMA.SHAPE_REPRESENTATION_RELATIONSHIP' IN TYPEOF(rr));
    END_REPEAT;
    REPEAT i := 1 TO HIINDEX(local_srr);
      IF 'PRODUCT_PROPERTY_REPRESENTATION_SCHEMA.SHAPE_REPRESENTATION_RELATIONSHIP' IN TYPEOF(local_srr[i])
      THEN
        local_shape_rep := local_shape_rep + local_srr[i].rep_2;
      END_IF;
    END_REPEAT;
    IF SIZEOF(local_shape_rep - total_reps) = 0
    THEN
      RETURN(shape_representation_set);
    ELSE
      local_total := total_reps + local_shape_rep;
      RETURN(local_shape_rep + (local_relatives_of_shape_representations(local_shape_rep - total_reps, local_total)));
    END_IF;
  END_FUNCTION;
      RETURN(local_relatives_of_shape_representations(shape_representation_set, shape_representation_set));
END_FUNCTION;

FUNCTION valid_identified_item_in_representation
 (identified_item : item_identified_representation_usage_select; used_representation : representation) : BOOLEAN;
  LOCAL
  i : INTEGER := 1;
    END_LOCAL;
      IF 'REPRESENTATION_SCHEMA.REPRESENTATION_ITEM' IN TYPEOF(identified_item)
  THEN
    RETURN(used_representation IN using_representations(identified_item));
  END_IF;
      IF ('REPRESENTATION_SCHEMA.LIST_REPRESENTATION_ITEM' IN TYPEOF(identified_item)) OR
         ('REPRESENTATION_SCHEMA.SET_REPRESENTATION_ITEM' IN TYPEOF(identified_item))
  THEN
    REPEAT WHILE (EXISTS(identified_item[i]));
      IF NOT (used_representation IN using_representations(identified_item[i]))
      THEN
        RETURN(FALSE);
      END_IF;
      i := i + 1;
    END_REPEAT;
    RETURN(TRUE);
  END_IF;
      RETURN(?);
END_FUNCTION;

END_SCHEMA;  -- product_property_representation_schema