(* Annex A
(normative)

AIM EXPRESS expanded listing
The following EXPRESS is the expanded form of the short form schema given in 5.2. In the event of 
any discrepancy between the short form and this expanded listing, the expanded listing shall be 
used.

*)
SCHEMA plant_spatial_configuration;

  TYPE ahead_or_behind = ENUMERATION OF
    (ahead,
     behind);
  END_TYPE; -- ahead_or_behind

  TYPE amount_of_substance_measure = REAL;
  END_TYPE; -- amount_of_substance_measure

  TYPE angle_relator = ENUMERATION OF
    (equal,
     large,
     small);
  END_TYPE; -- angle_relator

  TYPE approval_item = SELECT
    (change_action,
     versioned_action_request);
  END_TYPE; -- approval_item

  TYPE area_measure = REAL;
  END_TYPE; -- area_measure

  TYPE axis2_placement = SELECT
    (axis2_placement_2d,
     axis2_placement_3d);
  END_TYPE; -- axis2_placement

  TYPE b_spline_curve_form = ENUMERATION OF
    (polyline_form,
     circular_arc,
     elliptic_arc,
     parabolic_arc,
     hyperbolic_arc,
     unspecified);
  END_TYPE; -- b_spline_curve_form

  TYPE b_spline_surface_form = ENUMERATION OF
    (plane_surf,
     cylindrical_surf,
     conical_surf,
     spherical_surf,
     toroidal_surf,
     surf_of_revolution,
     ruled_surf,
     generalised_cone,
     quadric_surf,
     surf_of_linear_extrusion,
     unspecified);
  END_TYPE; -- b_spline_surface_form

  TYPE boolean_operand = SELECT
    (solid_model,
     half_space_solid,
     csg_primitive,
     boolean_result);
  END_TYPE; -- boolean_operand

  TYPE boolean_operator = ENUMERATION OF
    (union,
     intersection,
     difference);
  END_TYPE; -- boolean_operator

  TYPE change_delta_item = SELECT
    (assembly_component_usage,
     axis2_placement_2d,
     axis2_placement_3d,
     line_branch_connection,
     line_plant_item_branch_connection,
     line_plant_item_connection,
     line_termination_connection,
     plant,
     product,
     product_definition_relationship);
  END_TYPE; -- change_delta_item

  TYPE change_item = SELECT
    (change_delta_item,
     document,
     ducting_system,
     electrical_system,
     externally_defined_plant_item_definition,
     instrumentation_and_control_system,
     piping_system,
     plant_item_connection,
     plant_item_connector,
     plant_line_definition,
     plant_line_segment_definition,
     plant_line_segment_termination,
     process_capability,
     product_definition,
     product_definition_shape,
     property_definition,
     reference_geometry,
     site,
     site_feature,
     structural_system);
  END_TYPE; -- change_item

  TYPE characterized_definition = SELECT
    (characterized_object,
     characterized_product_definition,
     shape_definition);
  END_TYPE; -- characterized_definition

  TYPE characterized_material_property = SELECT
    (material_property_representation,
     product_material_composition_relationship);
  END_TYPE; -- characterized_material_property

  TYPE characterized_product_definition = SELECT
    (product_definition,
     product_definition_relationship);
  END_TYPE; -- characterized_product_definition

  TYPE classification_item = SELECT
    (ducting_system,
     electrical_system,
     instrumentation_and_control_system,
     piping_component_definition,
     piping_system,
     plant_item_connection,
     plant_item_connector,
     plant_spatial_configuration_document_reference,
     product,
     product_definition,
     structural_system);
  END_TYPE; -- classification_item

  TYPE context_dependent_measure = REAL;
  END_TYPE; -- context_dependent_measure

  TYPE count_measure = NUMBER;
  END_TYPE; -- count_measure

  TYPE csg_primitive = SELECT
    (sphere,
     block,
     torus,
     right_circular_cone,
     right_circular_cylinder);
  END_TYPE; -- csg_primitive

  TYPE csg_select = SELECT
    (boolean_result,
     csg_primitive);
  END_TYPE; -- csg_select

  TYPE curve_on_surface = SELECT
    (pcurve,
     surface_curve,
     composite_curve_on_surface);
  END_TYPE; -- curve_on_surface

  TYPE date_time_select = SELECT
    (date,
     local_time,
     date_and_time);
  END_TYPE; -- date_time_select

  TYPE day_in_month_number = INTEGER;
  END_TYPE; -- day_in_month_number

  TYPE design_project_item = SELECT
    (product_definition);
  END_TYPE; -- design_project_item

  TYPE dimension_count = INTEGER;
  WHERE
    wr1: SELF > 0;
  END_TYPE; -- dimension_count

  TYPE dimensional_characteristic = SELECT
    (dimensional_location,
     dimensional_size);
  END_TYPE; -- dimensional_characteristic

  TYPE geometric_set_select = SELECT
    (point,
     curve,
     surface);
  END_TYPE; -- geometric_set_select

  TYPE hour_in_day = INTEGER;
  WHERE
    wr1: (0 <= SELF) AND (SELF < 24);
  END_TYPE; -- hour_in_day

  TYPE identifier = STRING;
  END_TYPE; -- identifier

  TYPE knot_type = ENUMERATION OF
    (uniform_knots,
     unspecified,
     quasi_uniform_knots,
     piecewise_bezier_knots);
  END_TYPE; -- knot_type

  TYPE label = STRING;
  END_TYPE; -- label

  TYPE layered_item = SELECT
    (representation_item);
  END_TYPE; -- layered_item

  TYPE length_measure = REAL;
  END_TYPE; -- length_measure

  TYPE list_of_reversible_topology_item = LIST [0:?] OF
              reversible_topology_item;
  END_TYPE; -- list_of_reversible_topology_item

  TYPE mass_measure = REAL;
  END_TYPE; -- mass_measure

  TYPE measure_value = SELECT
    (length_measure,
     mass_measure,
     time_measure,
     thermodynamic_temperature_measure,
     amount_of_substance_measure,
     plane_angle_measure,
     solid_angle_measure,
     area_measure,
     volume_measure,
     ratio_measure,
     parameter_value,
     numeric_measure,
     context_dependent_measure,
     positive_length_measure,
     positive_plane_angle_measure,
     positive_ratio_measure,
     count_measure);
  END_TYPE; -- measure_value

  TYPE minute_in_hour = INTEGER;
  WHERE
    wr1: (0 <= SELF) AND (SELF <= 59);
  END_TYPE; -- minute_in_hour

  TYPE month_in_year_number = INTEGER;
  WHERE
    wr1: (1 <= SELF) AND (SELF <= 12);
  END_TYPE; -- month_in_year_number

  TYPE numeric_measure = NUMBER;
  END_TYPE; -- numeric_measure

  TYPE parameter_value = REAL;
  END_TYPE; -- parameter_value

  TYPE pcurve_or_surface = SELECT
    (pcurve,
     surface);
  END_TYPE; -- pcurve_or_surface

  TYPE person_organization_select = SELECT
    (person,
     organization,
     person_and_organization);
  END_TYPE; -- person_organization_select

  TYPE plane_angle_measure = REAL;
  END_TYPE; -- plane_angle_measure

  TYPE plant_spatial_configuration_action_request_item = SELECT
    (product);
  END_TYPE; -- plant_spatial_configuration_action_request_item

  TYPE plant_spatial_configuration_date_and_time_item = SELECT
    (product);
  END_TYPE; -- plant_spatial_configuration_date_and_time_item

  TYPE plant_spatial_configuration_dated_item = SELECT
    (action_directive,
     change_action,
     change_item,
     product);
  END_TYPE; -- plant_spatial_configuration_dated_item

  TYPE plant_spatial_configuration_document_item = SELECT
    (heat_tracing_representation,
     piping_component_class,
     piping_system,
     plant_item_connector,
     plant_line_segment_definition,
     product,
     product_definition,
     product_definition_relationship,
     property_definition,
     representation,
     representation_item,
     site);
  END_TYPE; -- plant_spatial_configuration_document_item

  TYPE plant_spatial_configuration_organization_item = SELECT
    (catalogue,
     change_action,
     design_project,
     document,
     plant,
     product_definition_formation,
     product_definition_relationship,
     site);
  END_TYPE; -- plant_spatial_configuration_organization_item

  TYPE plant_spatial_configuration_person_and_organization_item = SELECT
    (change_item,
     plant,
     site);
  END_TYPE; -- plant_spatial_configuration_person_and_organization_item

  TYPE plant_spatial_configuration_person_item = SELECT
    (document,
     plant,
     product_definition_relationship,
     site);
  END_TYPE; -- plant_spatial_configuration_person_item

  TYPE positive_length_measure = length_measure;
  WHERE
    wr1: SELF > 0;
  END_TYPE; -- positive_length_measure

  TYPE positive_plane_angle_measure = plane_angle_measure;
  WHERE
    wr1: SELF > 0;
  END_TYPE; -- positive_plane_angle_measure

  TYPE positive_ratio_measure = ratio_measure;
  WHERE
    wr1: SELF > 0;
  END_TYPE; -- positive_ratio_measure

  TYPE preferred_surface_curve_representation = ENUMERATION OF
    (curve_3d,
     pcurve_s1,
     pcurve_s2);
  END_TYPE; -- preferred_surface_curve_representation

  TYPE purchase_item = SELECT
    (product);
  END_TYPE; -- purchase_item

  TYPE ratio_measure = REAL;
  END_TYPE; -- ratio_measure

  TYPE reversible_topology = SELECT
    (reversible_topology_item,
     list_of_reversible_topology_item,
     set_of_reversible_topology_item);
  END_TYPE; -- reversible_topology

  TYPE reversible_topology_item = SELECT
    (edge,
     path,
     face,
     face_bound,
     closed_shell,
     open_shell);
  END_TYPE; -- reversible_topology_item

  TYPE second_in_minute = REAL;
  WHERE
    wr1: (0 <= SELF) AND (SELF < 60);
  END_TYPE; -- second_in_minute

  TYPE set_of_reversible_topology_item = SET [0:?] OF
              reversible_topology_item;
  END_TYPE; -- set_of_reversible_topology_item

  TYPE shape_definition = SELECT
    (product_definition_shape,
     shape_aspect,
     shape_aspect_relationship);
  END_TYPE; -- shape_definition

  TYPE shell = SELECT
    (open_shell,
     closed_shell);
  END_TYPE; -- shell

  TYPE si_prefix = ENUMERATION OF
    (exa,
     peta,
     tera,
     giga,
     mega,
     kilo,
     hecto,
     deca,
     deci,
     centi,
     milli,
     micro,
     nano,
     pico,
     femto,
     atto);
  END_TYPE; -- si_prefix

  TYPE si_unit_name = ENUMERATION OF
    (metre,
     gram,
     second,
     ampere,
     kelvin,
     mole,
     candela,
     radian,
     steradian,
     hertz,
     newton,
     pascal,
     joule,
     watt,
     coulomb,
     volt,
     farad,
     ohm,
     siemens,
     weber,
     tesla,
     henry,
     degree_celsius,
     lumen,
     lux,
     becquerel,
     gray,
     sievert);
  END_TYPE; -- si_unit_name

  TYPE solid_angle_measure = REAL;
  END_TYPE; -- solid_angle_measure

  TYPE source = ENUMERATION OF
    (made,
     bought,
     not_known);
  END_TYPE; -- source

  TYPE source_item = SELECT
    (identifier);
  END_TYPE; -- source_item

  TYPE text = STRING;
  END_TYPE; -- text

  TYPE thermodynamic_temperature_measure = REAL;
  END_TYPE; -- thermodynamic_temperature_measure

  TYPE time_measure = REAL;
  END_TYPE; -- time_measure

  TYPE transition_code = ENUMERATION OF
    (discontinuous,
     continuous,
     cont_same_gradient,
     cont_same_gradient_same_curvature);
  END_TYPE; -- transition_code

  TYPE trimming_preference = ENUMERATION OF
    (cartesian,
     parameter,
     unspecified);
  END_TYPE; -- trimming_preference

  TYPE trimming_select = SELECT
    (cartesian_point,
     parameter_value);
  END_TYPE; -- trimming_select

  TYPE unit = SELECT
    (named_unit,
     derived_unit);
  END_TYPE; -- unit

  TYPE value_qualifier = SELECT
    (type_qualifier);
  END_TYPE; -- value_qualifier

  TYPE vector_or_direction = SELECT
    (vector,
     direction);
  END_TYPE; -- vector_or_direction

  TYPE volume_measure = REAL;
  END_TYPE; -- volume_measure

  TYPE year_number = INTEGER;
  END_TYPE; -- year_number

  ENTITY action;
      name          : label;
      description   : text;
      chosen_method : action_method;
  END_ENTITY; -- action

  ENTITY action_assignment
    ABSTRACT SUPERTYPE;
      assigned_action : action;
  END_ENTITY; -- action_assignment

  ENTITY action_directive;
      name        : label;
      description : text;
      analysis    : text;
      comment     : text;
      requests    : SET [1:?] OF versioned_action_request;
  END_ENTITY; -- action_directive

  ENTITY action_method;
      name        : label;
      description : text;
      consequence : text;
      purpose     : text;
  END_ENTITY; -- action_method

  ENTITY action_method_relationship;
      name            : label;
      description     : text;
      relating_method : action_method;
      related_method  : action_method;
  END_ENTITY; -- action_method_relationship

  ENTITY action_relationship;
      name            : label;
      description     : text;
      relating_action : action;
      related_action  : action;
  END_ENTITY; -- action_relationship

  ENTITY action_request_assignment
    ABSTRACT SUPERTYPE;
      assigned_action_request : versioned_action_request;
  END_ENTITY; -- action_request_assignment

  ENTITY action_request_solution;
      method  : action_method;
      request : versioned_action_request;
  END_ENTITY; -- action_request_solution

  ENTITY action_request_status;
      status           : label;
      assigned_request : versioned_action_request;
  END_ENTITY; -- action_request_status

  ENTITY action_status;
      status          : label;
      assigned_action : executed_action;
  END_ENTITY; -- action_status

  ENTITY advanced_csg_shape_representation
    SUBTYPE OF (shape_representation);
    WHERE
      wr1: SIZEOF(QUERY ( item <* SELF.items | (NOT (SIZEOF([
               'PLANT_SPATIAL_CONFIGURATION.CSG_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.EXTRUDED_AREA_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.REVOLVED_AREA_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.AXIS2_PLACEMENT_3D',
               'PLANT_SPATIAL_CONFIGURATION.MAPPED_ITEM'] * TYPEOF(item)) =
                1)) )) = 0;
      wr2: SIZEOF(QUERY ( item <* SELF.items | (SIZEOF([
               'PLANT_SPATIAL_CONFIGURATION.CSG_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.EXTRUDED_AREA_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.REVOLVED_AREA_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.MAPPED_ITEM'] * TYPEOF(item)) =
                1) )) >= 1;
      wr3: SIZEOF(QUERY ( item <* SELF.items | ((
               'PLANT_SPATIAL_CONFIGURATION.CSG_SOLID' IN TYPEOF(item)) AND
                (NOT valid_advanced_csg_tree(item\csg_solid.
               tree_root_expression))) )) = 0;
      wr4: SIZEOF(QUERY ( mi <* QUERY ( item <* SELF.items | (
               'PLANT_SPATIAL_CONFIGURATION.MAPPED_ITEM' IN TYPEOF(item)) )
                | (NOT ('PLANT_SPATIAL_CONFIGURATION.' +
                'ADVANCED_CSG_SHAPE_REPRESENTATION' 
               IN TYPEOF(mi\mapped_item.mapping_source.
               mapped_representation))) )) = 0;
  END_ENTITY; -- advanced_csg_shape_representation

  ENTITY amount_of_substance_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.AMOUNT_OF_SUBSTANCE_UNIT' IN 
               TYPEOF(SELF\measure_with_unit.unit_component);
  END_ENTITY; -- amount_of_substance_measure_with_unit

  ENTITY amount_of_substance_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 0) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 1) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- amount_of_substance_unit

  ENTITY angular_location
    SUBTYPE OF (dimensional_location);
      angle_selection : angle_relator;
  END_ENTITY; -- angular_location

  ENTITY application_context;
      application : text;
    INVERSE
      context_elements : SET [1:?] OF application_context_element FOR 
                            frame_of_reference;
  END_ENTITY; -- application_context

  ENTITY application_context_element
    SUPERTYPE OF (ONEOF (product_context,product_definition_context));
      name               : label;
      frame_of_reference : application_context;
  END_ENTITY; -- application_context_element

  ENTITY application_protocol_definition;
      status                                    : label;
      application_interpreted_model_schema_name : label;
      application_protocol_year                 : year_number;
      application                               : application_context;
  END_ENTITY; -- application_protocol_definition

  ENTITY approval;
      status : approval_status;
      level  : label;
  END_ENTITY; -- approval

  ENTITY approval_assignment
    ABSTRACT SUPERTYPE;
      assigned_approval : approval;
  END_ENTITY; -- approval_assignment

  ENTITY approval_date_time;
      date_time      : date_time_select;
      dated_approval : approval;
  END_ENTITY; -- approval_date_time

  ENTITY approval_person_organization;
      person_organization : person_organization_select;
      authorized_approval : approval;
      role                : approval_role;
  END_ENTITY; -- approval_person_organization

  ENTITY approval_role;
      role : label;
  END_ENTITY; -- approval_role

  ENTITY approval_status;
      name : label;
  END_ENTITY; -- approval_status

  ENTITY area_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.AREA_UNIT' IN TYPEOF(SELF\
               measure_with_unit.unit_component);
  END_ENTITY; -- area_measure_with_unit

  ENTITY area_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 2) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- area_unit

  ENTITY assembly_component_usage
    SUBTYPE OF (product_definition_usage);
      reference_designator : OPTIONAL identifier;
  END_ENTITY; -- assembly_component_usage

  ENTITY axis1_placement
    SUBTYPE OF (placement);
      axis : OPTIONAL direction;
    DERIVE
      z : direction := NVL(normalise(axis),direction([0,0,1]));
    WHERE
      wr1: SELF\geometric_representation_item.dim = 3;
  END_ENTITY; -- axis1_placement

  ENTITY axis2_placement_2d
    SUBTYPE OF (placement);
      ref_direction : OPTIONAL direction;
    DERIVE
      p : LIST [2:2] OF direction := build_2axes(ref_direction);
    WHERE
      wr1: SELF\geometric_representation_item.dim = 2;
  END_ENTITY; -- axis2_placement_2d

  ENTITY axis2_placement_3d
    SUBTYPE OF (placement);
      axis          : OPTIONAL direction;
      ref_direction : OPTIONAL direction;
    DERIVE
      p : LIST [3:3] OF direction := build_axes(axis,ref_direction);
    WHERE
      wr1: SELF\placement.location.dim = 3;
      wr2: (NOT EXISTS(axis)) OR (axis.dim = 3);
      wr3: (NOT EXISTS(ref_direction)) OR (ref_direction.dim = 3);
      wr4: (NOT EXISTS(axis)) OR (NOT EXISTS(ref_direction)) OR (
               cross_product(axis,ref_direction).magnitude > 0);
  END_ENTITY; -- axis2_placement_3d

  ENTITY b_spline_curve
    SUPERTYPE OF (ONEOF (uniform_curve,b_spline_curve_with_knots,
        quasi_uniform_curve,bezier_curve) ANDOR rational_b_spline_curve)
    SUBTYPE OF (bounded_curve);
      degree              : INTEGER;
      control_points_list : LIST [2:?] OF cartesian_point;
      curve_form          : b_spline_curve_form;
      closed_curve        : LOGICAL;
      self_intersect      : LOGICAL;
    DERIVE
      upper_index_on_control_points : INTEGER := SIZEOF(
                                         control_points_list) - 1;
      control_points                : ARRAY [0:
                                         upper_index_on_control_points] OF
                                          cartesian_point := list_to_array(
                                         control_points_list,0,
                                         upper_index_on_control_points);
    WHERE
      wr1: ('PLANT_SPATIAL_CONFIGURATION.UNIFORM_CURVE' IN TYPEOF(SELF)) 
               OR ('PLANT_SPATIAL_CONFIGURATION.QUASI_UNIFORM_CURVE' IN 
               TYPEOF(SELF)) OR ('PLANT_SPATIAL_CONFIGURATION.BEZIER_CURVE' 
               IN TYPEOF(SELF)) OR (
               'PLANT_SPATIAL_CONFIGURATION.B_SPLINE_CURVE_WITH_KNOTS' IN 
               TYPEOF(SELF));
  END_ENTITY; -- b_spline_curve

  ENTITY b_spline_curve_with_knots
    SUBTYPE OF (b_spline_curve);
      knot_multiplicities : LIST [2:?] OF INTEGER;
      knots               : LIST [2:?] OF parameter_value;
      knot_spec           : knot_type;
    DERIVE
      upper_index_on_knots : INTEGER := SIZEOF(knots);
    WHERE
      wr1: constraints_param_b_spline(degree,upper_index_on_knots,
               upper_index_on_control_points,knot_multiplicities,knots);
      wr2: SIZEOF(knot_multiplicities) = upper_index_on_knots;
  END_ENTITY; -- b_spline_curve_with_knots

  ENTITY b_spline_surface
    SUPERTYPE OF (ONEOF (b_spline_surface_with_knots,uniform_surface,
        quasi_uniform_surface,bezier_surface) ANDOR 
        rational_b_spline_surface)
    SUBTYPE OF (bounded_surface);
      u_degree            : INTEGER;
      v_degree            : INTEGER;
      control_points_list : LIST [2:?] OF LIST [2:?] OF cartesian_point;
      surface_form        : b_spline_surface_form;
      u_closed            : LOGICAL;
      v_closed            : LOGICAL;
      self_intersect      : LOGICAL;
    DERIVE
      u_upper        : INTEGER := SIZEOF(control_points_list) - 1;
      v_upper        : INTEGER := SIZEOF(control_points_list[1]) - 1;
      control_points : ARRAY [0:u_upper] OF ARRAY [0:v_upper] OF
                           cartesian_point := make_array_of_array(
                          control_points_list,0,u_upper,0,v_upper);
    WHERE
      wr1: ('PLANT_SPATIAL_CONFIGURATION.UNIFORM_SURFACE' IN TYPEOF(SELF)) 
               OR ('PLANT_SPATIAL_CONFIGURATION.QUASI_UNIFORM_SURFACE' IN 
               TYPEOF(SELF)) OR (
               'PLANT_SPATIAL_CONFIGURATION.BEZIER_SURFACE' IN TYPEOF(SELF)) 
               OR (
               'PLANT_SPATIAL_CONFIGURATION.B_SPLINE_SURFACE_WITH_KNOTS' IN
                TYPEOF(SELF));
  END_ENTITY; -- b_spline_surface

  ENTITY b_spline_surface_with_knots
    SUBTYPE OF (b_spline_surface);
      u_multiplicities : LIST [2:?] OF INTEGER;
      v_multiplicities : LIST [2:?] OF INTEGER;
      u_knots          : LIST [2:?] OF parameter_value;
      v_knots          : LIST [2:?] OF parameter_value;
      knot_spec        : knot_type;
    DERIVE
      knot_u_upper : INTEGER := SIZEOF(u_knots);
      knot_v_upper : INTEGER := SIZEOF(v_knots);
    WHERE
      wr1: constraints_param_b_spline(SELF\b_spline_surface.u_degree,
               knot_u_upper,SELF\b_spline_surface.u_upper,u_multiplicities,
               u_knots);
      wr2: constraints_param_b_spline(SELF\b_spline_surface.v_degree,
               knot_v_upper,SELF\b_spline_surface.v_upper,v_multiplicities,
               v_knots);
      wr3: SIZEOF(u_multiplicities) = knot_u_upper;
      wr4: SIZEOF(v_multiplicities) = knot_v_upper;
  END_ENTITY; -- b_spline_surface_with_knots

  ENTITY bezier_curve
    SUBTYPE OF (b_spline_curve);
  END_ENTITY; -- bezier_curve

  ENTITY bezier_surface
    SUBTYPE OF (b_spline_surface);
  END_ENTITY; -- bezier_surface

  ENTITY blank_fitting_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'blank') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- blank_fitting_classification

  ENTITY block
    SUBTYPE OF (geometric_representation_item);
      position : axis2_placement_3d;
      x        : positive_length_measure;
      y        : positive_length_measure;
      z        : positive_length_measure;
  END_ENTITY; -- block

  ENTITY boolean_result
    SUBTYPE OF (geometric_representation_item);
      operator       : boolean_operator;
      first_operand  : boolean_operand;
      second_operand : boolean_operand;
  END_ENTITY; -- boolean_result

  ENTITY boundary_curve
    SUBTYPE OF (composite_curve_on_surface);
    WHERE
      wr1: SELF\composite_curve.closed_curve;
  END_ENTITY; -- boundary_curve

  ENTITY bounded_curve
    SUPERTYPE OF (ONEOF (polyline,b_spline_curve,trimmed_curve,
        bounded_pcurve,bounded_surface_curve,composite_curve))
    SUBTYPE OF (curve);
  END_ENTITY; -- bounded_curve

  ENTITY bounded_pcurve
    SUBTYPE OF (pcurve, bounded_curve);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.BOUNDED_CURVE' IN TYPEOF(SELF\
               pcurve.reference_to_curve.items[1]);
  END_ENTITY; -- bounded_pcurve

  ENTITY bounded_surface
    SUPERTYPE OF (ONEOF (b_spline_surface,rectangular_trimmed_surface,
        curve_bounded_surface,rectangular_composite_surface))
    SUBTYPE OF (surface);
  END_ENTITY; -- bounded_surface

  ENTITY bounded_surface_curve
    SUBTYPE OF (surface_curve, bounded_curve);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.BOUNDED_CURVE' IN TYPEOF(SELF\
               surface_curve.curve_3d);
  END_ENTITY; -- bounded_surface_curve

  ENTITY brep_with_voids
    SUBTYPE OF (manifold_solid_brep);
      voids : SET [1:?] OF oriented_closed_shell;
  END_ENTITY; -- brep_with_voids

  ENTITY calendar_date
    SUBTYPE OF (date);
      day_component   : day_in_month_number;
      month_component : month_in_year_number;
    WHERE
      wr1: valid_calendar_date(SELF);
  END_ENTITY; -- calendar_date

  ENTITY cartesian_point
    SUBTYPE OF (point);
      coordinates : LIST [1:3] OF length_measure;
  END_ENTITY; -- cartesian_point

  ENTITY cartesian_transformation_operator
    SUPERTYPE OF (cartesian_transformation_operator_3d)
    SUBTYPE OF (geometric_representation_item, 
        functionally_defined_transformation);
      axis1        : OPTIONAL direction;
      axis2        : OPTIONAL direction;
      local_origin : cartesian_point;
      scale        : OPTIONAL REAL;
    DERIVE
      scl : REAL := NVL(scale,1);
    WHERE
      wr1: scl > 0;
  END_ENTITY; -- cartesian_transformation_operator

  ENTITY cartesian_transformation_operator_3d
    SUBTYPE OF (cartesian_transformation_operator);
      axis3 : OPTIONAL direction;
    DERIVE
      u : LIST [3:3] OF direction := base_axis(3,SELF\
             cartesian_transformation_operator.axis1,SELF\
             cartesian_transformation_operator.axis2,axis3);
    WHERE
      wr1: SELF\cartesian_transformation_operator.dim = 3;
  END_ENTITY; -- cartesian_transformation_operator_3d

  ENTITY catalogue
    SUBTYPE OF (document, external_source);
  END_ENTITY; -- catalogue

  ENTITY catalogue_connector
    SUBTYPE OF (shape_aspect, externally_defined_item);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.CHARACTERIZED_OBJECT' IN TYPEOF(
               SELF.of_shape);
      wr2: 'PLANT_SPATIAL_CONFIGURATION.CATALOGUE' IN TYPEOF(SELF.source);
  END_ENTITY; -- catalogue_connector

  ENTITY catalogue_item
    SUBTYPE OF (externally_defined_plant_item_definition);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.CATALOGUE' IN TYPEOF(SELF.source);
      wr2: SELF.frame_of_reference.name = 'catalogue definition';
  END_ENTITY; -- catalogue_item

  ENTITY centre_of_symmetry
    SUBTYPE OF (derived_shape_aspect);
    WHERE
      wr1: SIZEOF(QUERY ( sadr <* deriving_relationships | (NOT (
               'PLANT_SPATIAL_CONFIGURATION.SYMMETRIC_SHAPE_ASPECT' IN 
               TYPEOF(sadr.related_shape_aspect))) )) = 0;
  END_ENTITY; -- centre_of_symmetry

  ENTITY change_action
    SUBTYPE OF (directed_action);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.' 
               + 'ACTION_ASSIGNMENT.ASSIGNED_ACTION') | ((
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PLANT_SPATIAL_CONFIGURATION_CHANGE_ASSIGNMENT') IN TYPEOF(
               ca)) )) >= 1;
      wr2: SIZEOF(QUERY ( ar <* SELF\directed_action.directive.requests | 
               (NOT (SIZEOF(USEDIN(ar,'PLANT_SPATIAL_CONFIGURATION.' + 
               'ACTION_REQUEST_SOLUTION.SOLUTION')) = 1)) )) = 0;
      wr3: SIZEOF(USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.ACTION_STATUS.' 
               + 'ASSIGNED_ACTION')) = 1;
  END_ENTITY; -- change_action

  ENTITY change_from_assignment
    SUBTYPE OF (action_assignment);
      items : SET [1:?] OF change_delta_item;
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.CHANGE_ACTION' IN TYPEOF(SELF.
               assigned_action);
  END_ENTITY; -- change_from_assignment

  ENTITY change_item_id_assignment
    SUBTYPE OF (name_assignment);
      items : SET [1:?] OF change_item;
  END_ENTITY; -- change_item_id_assignment

  ENTITY change_to_assignment
    SUBTYPE OF (action_assignment);
      items : SET [1:?] OF change_delta_item;
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.CHANGE_ACTION' IN TYPEOF(SELF.
               assigned_action);
  END_ENTITY; -- change_to_assignment

  ENTITY characterized_object;
      name        : label;
      description : text;
  END_ENTITY; -- characterized_object

  ENTITY circle
    SUBTYPE OF (conic);
      radius : positive_length_measure;
  END_ENTITY; -- circle

  ENTITY classification_assignment
    SUBTYPE OF (group_assignment);
      items : SET [1:?] OF classification_item;
    WHERE
      wr1: (NOT (SIZEOF(QUERY ( item <* SELF.items | (NOT (
               'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTION' IN 
               TYPEOF(item))) )) = 0)) OR (SIZEOF(TYPEOF(SELF.
               assigned_group) * ['PLANT_SPATIAL_CONFIGURATION.' +
               'CONNECTION_FUNCTIONAL_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'CONNECTION_MOTION_CLASSIFICATION']) 
               >= 1);
      wr2: (NOT (SIZEOF(QUERY ( item <* SELF.items | (NOT (
               'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTOR' IN 
               TYPEOF(item))) )) = 0)) OR (SIZEOF(TYPEOF(SELF.
               assigned_group) *
               ['PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'ELECTRICAL_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'EXTERNALLY_DEFINED_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'STRUCTURAL_LOAD_CONNECTOR_CLASSIFICATION']) >= 1);
      wr3: (NOT (SIZEOF(QUERY ( item <* SELF.items | (NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(item))) )) = 0)) OR (SIZEOF(TYPEOF(SELF.
               assigned_group) * [
               'PLANT_SPATIAL_CONFIGURATION.BLANK_FITTING_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.ELBOW_FITTING_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.FLANGE_FITTING_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'FLANGE_FITTING_NECK_TYPE_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PIPE_CLOSURE_FITTING_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.PIPE_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'REDUCER_FITTING_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.SPACER_FITTING_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.SPECIALTY_ITEM_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.SWAGE_FITTING_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.VALVE_CLASSIFICATION']) >= 1);
  END_ENTITY; -- classification_assignment

  ENTITY closed_shell
    SUBTYPE OF (connected_face_set);
  END_ENTITY; -- closed_shell

  ENTITY colour;
  END_ENTITY; -- colour

  ENTITY colour_rgb
    SUBTYPE OF (colour_specification);
      red   : REAL;
      green : REAL;
      blue  : REAL;
    WHERE
      wr1: (0 <= red) AND (red <= 1);
      wr2: (0 <= green) AND (green <= 1);
      wr3: (0 <= blue) AND (blue <= 1);
  END_ENTITY; -- colour_rgb

  ENTITY colour_specification
    SUBTYPE OF (colour);
      name : label;
  END_ENTITY; -- colour_specification

  ENTITY composite_curve
    SUBTYPE OF (bounded_curve);
      segments       : LIST [1:?] OF composite_curve_segment;
      self_intersect : LOGICAL;
    DERIVE
      n_segments   : INTEGER := SIZEOF(segments);
      closed_curve : LOGICAL := segments[n_segments].transition <> 
                        discontinuous;
    WHERE
      wr1: ((NOT closed_curve) AND (SIZEOF(QUERY ( temp <* segments | (
               temp.transition = discontinuous) )) = 1)) OR (closed_curve 
               AND (SIZEOF(QUERY ( temp <* segments | (temp.transition = 
               discontinuous) )) = 0));
  END_ENTITY; -- composite_curve

  ENTITY composite_curve_on_surface
    SUPERTYPE OF (boundary_curve)
    SUBTYPE OF (composite_curve);
    DERIVE
      basis_surface : SET [0:2] OF surface := get_basis_surface(SELF);
    WHERE
      wr1: SIZEOF(basis_surface) > 0;
      wr2: constraints_composite_curve_on_surface(SELF);
  END_ENTITY; -- composite_curve_on_surface

  ENTITY composite_curve_segment;
      transition   : transition_code;
      same_sense   : BOOLEAN;
      parent_curve : curve;
    INVERSE
      using_curves : BAG [1:?] OF composite_curve FOR segments;
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.BOUNDED_CURVE' IN TYPEOF(
               parent_curve);
  END_ENTITY; -- composite_curve_segment

  ENTITY conic
    SUPERTYPE OF (ONEOF (circle,ellipse,hyperbola,parabola))
    SUBTYPE OF (curve);
      position : axis2_placement;
  END_ENTITY; -- conic

  ENTITY conical_surface
    SUBTYPE OF (elementary_surface);
      radius     : length_measure;
      semi_angle : plane_angle_measure;
    WHERE
      wr1: radius >= 0;
  END_ENTITY; -- conical_surface

  ENTITY connected_face_set
    SUPERTYPE OF (ONEOF (closed_shell,open_shell))
    SUBTYPE OF (topological_representation_item);
      cfs_faces : SET [1:?] OF face;
  END_ENTITY; -- connected_face_set

  ENTITY connection_functional_classification
    SUBTYPE OF (group);
  END_ENTITY; -- connection_functional_classification

  ENTITY connection_motion_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SELF.name IN ['flexible','locked orientation'];
  END_ENTITY; -- connection_motion_classification

  ENTITY connection_node
    SUBTYPE OF (shape_aspect);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PIPING_SYSTEM' IN TYPEOF(SELF.
               of_shape.definition);
      wr2: SIZEOF(QUERY ( sar <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.SHAPE_ASPECT_RELATIONSHIP.' + 
               'RELATING_SHAPE_ASPECT') | (
               'PLANT_SPATIAL_CONFIGURATION.LINE_TERMINATION_CONNECTION' IN
                TYPEOF(sar)) )) >= 3;
  END_ENTITY; -- connection_node

  ENTITY connector_end_type_classification
    SUBTYPE OF (group);
  END_ENTITY; -- connector_end_type_classification

  ENTITY context_dependent_unit
    SUBTYPE OF (named_unit);
      name : label;
  END_ENTITY; -- context_dependent_unit

  ENTITY conversion_based_unit
    SUBTYPE OF (named_unit);
      name              : label;
      conversion_factor : measure_with_unit;
  END_ENTITY; -- conversion_based_unit

  ENTITY coordinated_universal_time_offset;
      hour_offset   : hour_in_day;
      minute_offset : OPTIONAL minute_in_hour;
      sense         : ahead_or_behind;
  END_ENTITY; -- coordinated_universal_time_offset

  ENTITY csg_solid
    SUBTYPE OF (solid_model);
      tree_root_expression : csg_select;
  END_ENTITY; -- csg_solid

  ENTITY curve
    SUPERTYPE OF (ONEOF (line,conic,pcurve,surface_curve,offset_curve_2d,
        offset_curve_3d,curve_replica))
    SUBTYPE OF (geometric_representation_item);
  END_ENTITY; -- curve

  ENTITY curve_bounded_surface
    SUBTYPE OF (bounded_surface);
      basis_surface  : surface;
      boundaries     : SET [1:?] OF boundary_curve;
      implicit_outer : BOOLEAN;
    WHERE
      wr1: NOT (implicit_outer AND (
               'PLANT_SPATIAL_CONFIGURATION.OUTER_BOUNDARY_CURVE' IN 
               TYPEOF(boundaries)));
      wr2: (NOT implicit_outer) OR (
               'PLANT_SPATIAL_CONFIGURATION.BOUNDED_SURFACE' IN TYPEOF(
               basis_surface));
      wr3: SIZEOF(QUERY ( temp <* boundaries | (
               'PLANT_SPATIAL_CONFIGURATION.OUTER_BOUNDARY_CURVE' IN 
               TYPEOF(temp)) )) <= 1;
      wr4: SIZEOF(QUERY ( temp <* boundaries | (temp\
               composite_curve_on_surface.basis_surface[1] :<>: SELF.
               basis_surface) )) = 0;
  END_ENTITY; -- curve_bounded_surface

  ENTITY curve_replica
    SUBTYPE OF (curve);
      parent_curve   : curve;
      transformation : cartesian_transformation_operator;
    WHERE
      wr1: transformation.dim = parent_curve.dim;
      wr2: acyclic_curve_replica(SELF,parent_curve);
  END_ENTITY; -- curve_replica

  ENTITY cylindrical_surface
    SUBTYPE OF (elementary_surface);
      radius : positive_length_measure;
  END_ENTITY; -- cylindrical_surface

  ENTITY data_environment;
      name        : label;
      description : text;
      elements    : SET [1:?] OF property_definition_representation;
  END_ENTITY; -- data_environment

  ENTITY date
    SUPERTYPE OF (calendar_date);
      year_component : year_number;
  END_ENTITY; -- date

  ENTITY date_and_time;
      date_component : date;
      time_component : local_time;
  END_ENTITY; -- date_and_time

  ENTITY date_and_time_assignment
    ABSTRACT SUPERTYPE;
      assigned_date_and_time : date_and_time;
      role                   : date_time_role;
  END_ENTITY; -- date_and_time_assignment

  ENTITY date_assignment
    ABSTRACT SUPERTYPE;
      assigned_date : date;
      role          : date_role;
  END_ENTITY; -- date_assignment

  ENTITY date_role;
      name : label;
  END_ENTITY; -- date_role

  ENTITY date_time_role;
      name : label;
  END_ENTITY; -- date_time_role

  ENTITY definitional_representation
    SUBTYPE OF (representation);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PARAMETRIC_REPRESENTATION_CONTEXT' 
               IN TYPEOF(SELF\representation.context_of_items);
  END_ENTITY; -- definitional_representation

  ENTITY degenerate_pcurve
    SUBTYPE OF (point);
      basis_surface      : surface;
      reference_to_curve : definitional_representation;
    WHERE
      wr1: SIZEOF(reference_to_curve\representation.items) = 1;
      wr2: 'PLANT_SPATIAL_CONFIGURATION.CURVE' IN TYPEOF(
               reference_to_curve\representation.items[1]);
      wr3: reference_to_curve\representation.items[1]\
               geometric_representation_item.dim = 2;
  END_ENTITY; -- degenerate_pcurve

  ENTITY degenerate_toroidal_surface
    SUBTYPE OF (toroidal_surface);
      select_outer : BOOLEAN;
    WHERE
      wr1: major_radius < minor_radius;
  END_ENTITY; -- degenerate_toroidal_surface

  ENTITY derived_shape_aspect
    SUPERTYPE OF (centre_of_symmetry)
    SUBTYPE OF (shape_aspect);
    INVERSE
      deriving_relationships : SET [1:?] OF
                                   shape_aspect_deriving_relationship FOR 
                                  relating_shape_aspect;
  END_ENTITY; -- derived_shape_aspect

  ENTITY derived_unit;
      elements : SET [1:?] OF derived_unit_element;
    WHERE
      wr1: (SIZEOF(elements) > 1) OR ((SIZEOF(elements) = 1) AND (elements
               [1].exponent <> 1));
  END_ENTITY; -- derived_unit

  ENTITY derived_unit_element;
      unit     : named_unit;
      exponent : REAL;
  END_ENTITY; -- derived_unit_element

  ENTITY descriptive_colour
    SUBTYPE OF (colour, descriptive_representation_item);
  END_ENTITY; -- descriptive_colour

  ENTITY descriptive_representation_item
    SUBTYPE OF (representation_item);
      description : text;
  END_ENTITY; -- descriptive_representation_item

  ENTITY design_project
    SUBTYPE OF (organization);
    WHERE
      wr1: SIZEOF(USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.' + 
               'ORGANIZATION_ASSIGNMENT.ASSIGNED_ORGANIZATION')) >= 1;
  END_ENTITY; -- design_project

  ENTITY design_project_assignment
    SUBTYPE OF (organization_assignment);
      items : SET [1:?] OF design_project_item;
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.DESIGN_PROJECT' IN TYPEOF(SELF.
               assigned_organization);
  END_ENTITY; -- design_project_assignment

  ENTITY dimensional_characteristic_representation;
      dimension      : dimensional_characteristic;
      representation : shape_dimension_representation;
  END_ENTITY; -- dimensional_characteristic_representation

  ENTITY dimensional_exponents;
      length_exponent                    : REAL;
      mass_exponent                      : REAL;
      time_exponent                      : REAL;
      electric_current_exponent          : REAL;
      thermodynamic_temperature_exponent : REAL;
      amount_of_substance_exponent       : REAL;
      luminous_intensity_exponent        : REAL;
  END_ENTITY; -- dimensional_exponents

  ENTITY dimensional_location
    SUPERTYPE OF (angular_location)
    SUBTYPE OF (shape_aspect_relationship);
  END_ENTITY; -- dimensional_location

  ENTITY dimensional_size;
      applies_to : shape_aspect;
      name       : label;
    WHERE
      wr1: applies_to.product_definitional = TRUE;
  END_ENTITY; -- dimensional_size

  ENTITY directed_action
    SUBTYPE OF (executed_action);
      directive : action_directive;
  END_ENTITY; -- directed_action

  ENTITY direction
    SUBTYPE OF (geometric_representation_item);
      direction_ratios : LIST [2:3] OF REAL;
    WHERE
      wr1: SIZEOF(QUERY ( tmp <* direction_ratios | (tmp <> 0) )) > 0;
  END_ENTITY; -- direction

  ENTITY document;
      id          : identifier;
      name        : label;
      description : text;
      kind        : document_type;
    UNIQUE
      ur1 : id;
  END_ENTITY; -- document

  ENTITY document_reference
    ABSTRACT SUPERTYPE;
      assigned_document : document;
      source            : label;
  END_ENTITY; -- document_reference

  ENTITY document_relationship;
      name              : label;
      description       : text;
      relating_document : document;
      related_document  : document;
  END_ENTITY; -- document_relationship

  ENTITY document_type;
      product_data_type : label;
  END_ENTITY; -- document_type

  ENTITY document_usage_constraint;
      source                : document;
      subject_element       : label;
      subject_element_value : text;
  END_ENTITY; -- document_usage_constraint

  ENTITY ducting_system
    SUBTYPE OF (product_definition);
    WHERE
      wr1: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATED_PRODUCT_DEFINITION')
                | (('PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(pdr.
               relating_product_definition.formation.of_product)) AND (pdr.
               relating_product_definition.frame_of_reference.name = 
               'functional occurrence')) )) = 1;
  END_ENTITY; -- ducting_system

  ENTITY edge
    SUPERTYPE OF (ONEOF (edge_curve,oriented_edge))
    SUBTYPE OF (topological_representation_item);
      edge_start : vertex;
      edge_end   : vertex;
  END_ENTITY; -- edge

  ENTITY edge_curve
    SUBTYPE OF (edge, geometric_representation_item);
      edge_geometry : curve;
      same_sense    : BOOLEAN;
  END_ENTITY; -- edge_curve

  ENTITY edge_loop
    SUBTYPE OF (loop, path);
    DERIVE
      ne : INTEGER := SIZEOF(SELF\path.edge_list);
    WHERE
      wr1: SELF\path.edge_list[1].edge_start :=: SELF\path.edge_list[ne].
               edge_end;
  END_ENTITY; -- edge_loop

  ENTITY elbow_fitting_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'elbow') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- elbow_fitting_classification

  ENTITY electric_current_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.ELECTRIC_CURRENT_UNIT' IN TYPEOF(
               SELF\measure_with_unit.unit_component);
  END_ENTITY; -- electric_current_measure_with_unit

  ENTITY electric_current_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 0) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 1) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- electric_current_unit

  ENTITY electrical_connector_classification
    SUBTYPE OF (group);
  END_ENTITY; -- electrical_connector_classification

  ENTITY electrical_system
    SUBTYPE OF (product_definition);
    WHERE
      wr1: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATED_PRODUCT_DEFINITION')
                | (('PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(pdr.
               relating_product_definition.formation.of_product)) AND (pdr.
               relating_product_definition.frame_of_reference.name = 
               'functional occurrence')) )) = 1;
  END_ENTITY; -- electrical_system

  ENTITY elementary_surface
    SUPERTYPE OF (ONEOF (plane,cylindrical_surface,conical_surface,
        spherical_surface,toroidal_surface))
    SUBTYPE OF (surface);
      position : axis2_placement_3d;
  END_ENTITY; -- elementary_surface

  ENTITY ellipse
    SUBTYPE OF (conic);
      semi_axis_1 : positive_length_measure;
      semi_axis_2 : positive_length_measure;
  END_ENTITY; -- ellipse

  ENTITY evaluated_degenerate_pcurve
    SUBTYPE OF (degenerate_pcurve);
      equivalent_point : cartesian_point;
  END_ENTITY; -- evaluated_degenerate_pcurve

  ENTITY executed_action
    SUBTYPE OF (action);
  END_ENTITY; -- executed_action

  ENTITY external_source;
      source_id : source_item;
  END_ENTITY; -- external_source

  ENTITY externally_defined_classification
    SUBTYPE OF (group, externally_defined_item);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT ((SIZEOF(TYPEOF(it) * [
               'PLANT_SPATIAL_CONFIGURATION.ELECTRICAL_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.DUCTING_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'INSTRUMENTATION_AND_CONTROL_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.PIPING_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.PLANT',
               'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTOR',
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION',
               'PLANT_SPATIAL_CONFIGURATION.STRUCTURAL_SYSTEM']) = 1) OR ((
               'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION' IN TYPEOF(
               it)) AND (SIZEOF(QUERY ( pc <* it.formation.of_product.
               frame_of_reference |
               (pc.discipline_type = 'process plant') )) 
               = 1)))) )) = 0)) )) = 0;
  END_ENTITY; -- externally_defined_classification

  ENTITY externally_defined_item;
      item_id : source_item;
      source  : external_source;
  END_ENTITY; -- externally_defined_item

  ENTITY externally_defined_plant_item_definition
    SUBTYPE OF (product_definition, externally_defined_item);
  END_ENTITY; -- externally_defined_plant_item_definition

  ENTITY extruded_area_solid
    SUBTYPE OF (swept_area_solid);
      extruded_direction : direction;
      depth              : positive_length_measure;
    WHERE
      wr1: dot_product(SELF\swept_area_solid.swept_area.basis_surface\
               elementary_surface.position.p[3],extruded_direction) <> 0;
  END_ENTITY; -- extruded_area_solid

  ENTITY extruded_face_solid
    SUBTYPE OF (swept_face_solid);
      extruded_direction : direction;
      depth              : positive_length_measure;
    WHERE
      wr1: dot_product(SELF\swept_face_solid.swept_face.face_geometry\
               elementary_surface.position.p[3],extruded_direction) <> 0;
  END_ENTITY; -- extruded_face_solid

  ENTITY face
    SUPERTYPE OF (ONEOF (face_surface,oriented_face))
    SUBTYPE OF (topological_representation_item);
      bounds : SET [1:?] OF face_bound;
    WHERE
      wr1: NOT mixed_loop_type_set(list_to_set(list_face_loops(SELF)));
      wr2: SIZEOF(QUERY ( temp <* bounds | (
               'PLANT_SPATIAL_CONFIGURATION.FACE_OUTER_BOUND' IN TYPEOF(
               temp)) )) <= 1;
  END_ENTITY; -- face

  ENTITY face_bound
    SUBTYPE OF (topological_representation_item);
      bound       : loop;
      orientation : BOOLEAN;
  END_ENTITY; -- face_bound

  ENTITY face_surface
    SUBTYPE OF (face, geometric_representation_item);
      face_geometry : surface;
      same_sense    : BOOLEAN;
  END_ENTITY; -- face_surface

  ENTITY faceted_brep
    SUBTYPE OF (manifold_solid_brep);
  END_ENTITY; -- faceted_brep

  ENTITY flange_fitting_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'flange') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- flange_fitting_classification

  ENTITY flange_fitting_neck_type_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'flange') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- flange_fitting_neck_type_classification

  ENTITY functionally_defined_transformation;
      name        : label;
      description : text;
  END_ENTITY; -- functionally_defined_transformation

  ENTITY geometric_curve_set
    SUBTYPE OF (geometric_set);
    WHERE
      wr1: SIZEOF(QUERY ( temp <* SELF\geometric_set.elements | (
               'PLANT_SPATIAL_CONFIGURATION.SURFACE' IN TYPEOF(temp)) )) = 
               0;
  END_ENTITY; -- geometric_curve_set

  ENTITY geometric_representation_context
    SUBTYPE OF (representation_context);
      coordinate_space_dimension : dimension_count;
  END_ENTITY; -- geometric_representation_context

  ENTITY geometric_representation_item
    SUPERTYPE OF (ONEOF (point,direction,vector,placement,
        cartesian_transformation_operator,curve,surface,edge_curve,
        face_surface,poly_loop,solid_model,boolean_result,sphere,
        right_circular_cone,right_circular_cylinder,torus,block,
        half_space_solid,shell_based_wireframe_model,geometric_set))
    SUBTYPE OF (representation_item);
    DERIVE
      dim : dimension_count := dimension_of(SELF);
    WHERE
      wr1: SIZEOF(QUERY ( using_rep <* using_representations(SELF) | (NOT 
               ('PLANT_SPATIAL_CONFIGURATION.' +
               'GEOMETRIC_REPRESENTATION_CONTEXT' 
               IN TYPEOF(using_rep.context_of_items))) )) = 0;
  END_ENTITY; -- geometric_representation_item

  ENTITY geometric_set
    SUPERTYPE OF (ONEOF (geometric_curve_set,geometric_set_replica))
    SUBTYPE OF (geometric_representation_item);
      elements : SET [1:?] OF geometric_set_select;
  END_ENTITY; -- geometric_set

  ENTITY geometric_set_replica
    SUBTYPE OF (geometric_set);
      parent_set     : geometric_set;
      transformation : cartesian_transformation_operator;
    DERIVE
      SELF\geometric_set.elements : SET [1:?] OF geometric_set_select := 
                                     build_transformed_set(transformation,
                                     parent_set);
    WHERE
      wr1: acyclic_set_replica(SELF,parent_set);
  END_ENTITY; -- geometric_set_replica

  ENTITY global_unit_assigned_context
    SUBTYPE OF (representation_context);
      units : SET [1:?] OF unit;
  END_ENTITY; -- global_unit_assigned_context

  ENTITY group;
      name        : label;
      description : text;
  END_ENTITY; -- group

  ENTITY group_assignment
    ABSTRACT SUPERTYPE;
      assigned_group : group;
  END_ENTITY; -- group_assignment

  ENTITY group_relationship;
      name           : label;
      description    : text;
      relating_group : group;
      related_group  : group;
  END_ENTITY; -- group_relationship

  ENTITY half_space_solid
    SUBTYPE OF (geometric_representation_item);
      base_surface   : surface;
      agreement_flag : BOOLEAN;
  END_ENTITY; -- half_space_solid

  ENTITY heat_tracing_representation
    SUBTYPE OF (representation);
  END_ENTITY; -- heat_tracing_representation

  ENTITY hybrid_shape_representation
    SUBTYPE OF (shape_representation);
    WHERE
      wr1: SIZEOF(QUERY ( i <* SELF\representation.items | (NOT (SIZEOF([
               'PLANT_SPATIAL_CONFIGURATION.BOOLEAN_RESULT',
               'PLANT_SPATIAL_CONFIGURATION.CSG_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.TRUNCATED_PYRAMID',
               'PLANT_SPATIAL_CONFIGURATION.BLOCK',
               'PLANT_SPATIAL_CONFIGURATION.TORUS',
               'PLANT_SPATIAL_CONFIGURATION.RIGHT_CIRCULAR_CYLINDER',
               'PLANT_SPATIAL_CONFIGURATION.SPHERE',
               'PLANT_SPATIAL_CONFIGURATION.RIGHT_CIRCULAR_CONE',
               'PLANT_SPATIAL_CONFIGURATION.EXTRUDED_AREA_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.REVOLVED_AREA_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.AXIS2_PLACEMENT_3D',
               'PLANT_SPATIAL_CONFIGURATION.MANIFOLD_SOLID_BREP',
               'PLANT_SPATIAL_CONFIGURATION.SHELL_BASED_WIREFRAME_MODEL',
               'PLANT_SPATIAL_CONFIGURATION.CONIC',
               'PLANT_SPATIAL_CONFIGURATION.CURVE',
               'PLANT_SPATIAL_CONFIGURATION.B_SPLINE_CURVE',
               'PLANT_SPATIAL_CONFIGURATION.LINE',
               'PLANT_SPATIAL_CONFIGURATION.POINT',
               'PLANT_SPATIAL_CONFIGURATION.POLYLINE',
               'PLANT_SPATIAL_CONFIGURATION.SURFACE',
               'PLANT_SPATIAL_CONFIGURATION.VECTOR',
               'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
               'PLANT_SPATIAL_CONFIGURATION.MAPPED_ITEM'] * 
               TYPEOF(i)) = 1)) )) = 0;
      wr2: SIZEOF(QUERY ( mi <* QUERY ( item <* SELF\representation.items
                | ('PLANT_SPATIAL_CONFIGURATION.MAPPED_ITEM' IN
                TYPEOF(item)))
                | (NOT (SIZEOF(['PLANT_SPATIAL_CONFIGURATION.' + 
               'ADVANCED_CSG_SHAPE_REPRESENTATION',
               'PLANT_SPATIAL_CONFIGURATION.HYBRID_SHAPE_REPRESENTATION'] *
                TYPEOF(mi\mapped_item.mapping_source.
                mapped_representation)) 
               = 1)) )) = 0;
  END_ENTITY; -- hybrid_shape_representation

  ENTITY hyperbola
    SUBTYPE OF (conic);
      semi_axis      : positive_length_measure;
      semi_imag_axis : positive_length_measure;
  END_ENTITY; -- hyperbola

  ENTITY inline_equipment
    SUBTYPE OF (piping_component_definition);
  END_ENTITY; -- inline_equipment

  ENTITY instrumentation_and_control_system
    SUBTYPE OF (product_definition);
    WHERE
      wr1: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATED_PRODUCT_DEFINITION')
                | (('PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(pdr.
               relating_product_definition.formation.of_product)) AND (pdr.
               relating_product_definition.frame_of_reference.name = 
               'functional occurrence')) )) = 1;
  END_ENTITY; -- instrumentation_and_control_system

  ENTITY interfering_shape_element
    SUBTYPE OF (shape_aspect, shape_aspect_relationship);
  END_ENTITY; -- interfering_shape_element

  ENTITY intersection_curve
    SUBTYPE OF (surface_curve);
    WHERE
      wr1: SIZEOF(SELF\surface_curve.associated_geometry) = 2;
      wr2: associated_surface(SELF\surface_curve.associated_geometry[1]) 
               <> associated_surface(SELF\surface_curve.associated_geometry
               [2]);
  END_ENTITY; -- intersection_curve

  ENTITY known_source
    SUBTYPE OF (external_source, pre_defined_item);
    WHERE
      wr1: SELF\pre_defined_item.name IN ['ISO 13584 Dictionary',
               'ISO 13584 Parts Library'];
  END_ENTITY; -- known_source

  ENTITY length_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.LENGTH_UNIT' IN TYPEOF(SELF\
               measure_with_unit.unit_component);
  END_ENTITY; -- length_measure_with_unit

  ENTITY length_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 1) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- length_unit

  ENTITY line
    SUBTYPE OF (curve);
      pnt : cartesian_point;
      dir : vector;
    WHERE
      wr1: dir.dim = pnt.dim;
  END_ENTITY; -- line

  ENTITY line_branch_connection
    SUBTYPE OF (shape_aspect_relationship);
    WHERE
      wr1: SELF.description = 'branch location';
      wr2: 'PLANT_SPATIAL_CONFIGURATION.PLANT_LINE_SEGMENT_DEFINITION' IN 
               TYPEOF(SELF.relating_shape_aspect.of_shape.definition);
      wr3: 'PLANT_SPATIAL_CONFIGURATION.PLANT_LINE_SEGMENT_TERMINATION' IN
                TYPEOF(SELF.related_shape_aspect);
  END_ENTITY; -- line_branch_connection

  ENTITY line_less_piping_system
    SUBTYPE OF (product_definition);
  END_ENTITY; -- line_less_piping_system

  ENTITY line_plant_item_branch_connection
    SUBTYPE OF (shape_aspect_relationship);
  END_ENTITY; -- line_plant_item_branch_connection

  ENTITY line_plant_item_connection
    SUBTYPE OF (shape_aspect_relationship);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PLANT_LINE_SEGMENT_TERMINATION' IN
               TYPEOF(SELF.relating_shape_aspect);
      wr2: 'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTOR' IN TYPEOF(
               SELF.related_shape_aspect);
      wr3: SELF\shape_aspect_relationship.related_shape_aspect.
               of_shape\property_definition.
               definition\product_definition.
               frame_of_reference\application_context_element.
               name = 'physical occurrence';
  END_ENTITY; -- line_plant_item_connection

  ENTITY line_termination_connection
    SUBTYPE OF (shape_aspect_relationship);
    WHERE
      wr1: SIZEOF(TYPEOF(SELF.relating_shape_aspect) * [
               'PLANT_SPATIAL_CONFIGURATION.CONNECTION_NODE',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PLANT_LINE_SEGMENT_TERMINATION']) 
               >= 1;
      wr2: 'PLANT_SPATIAL_CONFIGURATION.PLANT_LINE_SEGMENT_TERMINATION' IN
                TYPEOF(SELF.related_shape_aspect);
  END_ENTITY; -- line_termination_connection

  ENTITY local_time;
      hour_component   : hour_in_day;
      minute_component : OPTIONAL minute_in_hour;
      second_component : OPTIONAL second_in_minute;
      zone             : coordinated_universal_time_offset;
    WHERE
      wr1: valid_time(SELF);
  END_ENTITY; -- local_time

  ENTITY loop
    SUPERTYPE OF (ONEOF (edge_loop,poly_loop))
    SUBTYPE OF (topological_representation_item);
  END_ENTITY; -- loop

  ENTITY make_from_usage_option
    SUBTYPE OF (product_definition_usage);
      ranking           : INTEGER;
      ranking_rationale : text;
      quantity          : measure_with_unit;
    WHERE
      wr1: ranking > 0;
  END_ENTITY; -- make_from_usage_option

  ENTITY manifold_solid_brep
    SUBTYPE OF (solid_model);
      outer : closed_shell;
  END_ENTITY; -- manifold_solid_brep

  ENTITY mapped_item
    SUBTYPE OF (representation_item);
      mapping_source : representation_map;
      mapping_target : representation_item;
    WHERE
      wr1: acyclic_mapped_representation(using_representations(SELF),
               [SELF]);
  END_ENTITY; -- mapped_item

  ENTITY mass_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.MASS_UNIT' IN TYPEOF(SELF\
               measure_with_unit.unit_component);
  END_ENTITY; -- mass_measure_with_unit

  ENTITY mass_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 0) AND (SELF\
               named_unit.dimensions.mass_exponent = 1) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- mass_unit

  ENTITY material_designation;
      name        : label;
      definitions : SET [1:?] OF characterized_definition;
  END_ENTITY; -- material_designation

  ENTITY material_designation_characterization;
      name        : label;
      description : text;
      designation : material_designation;
      property    : characterized_material_property;
  END_ENTITY; -- material_designation_characterization

  ENTITY material_property
    SUBTYPE OF (property_definition);
    UNIQUE
      ur1 : name, definition;
    WHERE
      wr1: ('PLANT_SPATIAL_CONFIGURATION.CHARACTERIZED_OBJECT' IN (TYPEOF(
               SELF\property_definition.definition) OR SIZEOF(bag_to_set(
               USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION')) - 
               QUERY ( temp <* bag_to_set(USEDIN(SELF,
               'PRODUCT_PROPERTY_REPRESENTATION_SCHEMA.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION')) | ((
               'MATERIAL_PROPERTY_REPRESENTATION_SCHEMA.' + 
               'MATERIAL_PROPERTY_REPRESENTATION') IN TYPEOF(temp)) )))) = 
               0;
  END_ENTITY; -- material_property

  ENTITY material_property_representation
    SUBTYPE OF (property_definition_representation);
      dependent_environment : data_environment;
  END_ENTITY; -- material_property_representation

  ENTITY measure_representation_item
    SUBTYPE OF (representation_item, measure_with_unit);
  END_ENTITY; -- measure_representation_item

  ENTITY measure_with_unit
    SUPERTYPE OF (ONEOF (length_measure_with_unit,mass_measure_with_unit,
        time_measure_with_unit,electric_current_measure_with_unit,
        thermodynamic_temperature_measure_with_unit,
        amount_of_substance_measure_with_unit,
        plane_angle_measure_with_unit,
        solid_angle_measure_with_unit,area_measure_with_unit,
        volume_measure_with_unit,ratio_measure_with_unit));
      value_component : measure_value;
      unit_component  : unit;
    WHERE
      wr1: valid_units(SELF);
  END_ENTITY; -- measure_with_unit

  ENTITY name_assignment
    ABSTRACT SUPERTYPE;
      assigned_name : label;
  END_ENTITY; -- name_assignment

  ENTITY named_unit
    SUPERTYPE OF (ONEOF (si_unit,conversion_based_unit,
        context_dependent_unit) ANDOR ONEOF (length_unit,mass_unit,
        time_unit,electric_current_unit,thermodynamic_temperature_unit,
        amount_of_substance_unit,plane_angle_unit,solid_angle_unit,
        area_unit,volume_unit,ratio_unit));
      dimensions : dimensional_exponents;
  END_ENTITY; -- named_unit

  ENTITY offset_curve_2d
    SUBTYPE OF (curve);
      basis_curve    : curve;
      distance       : length_measure;
      self_intersect : LOGICAL;
    WHERE
      wr1: basis_curve.dim = 2;
  END_ENTITY; -- offset_curve_2d

  ENTITY offset_curve_3d
    SUBTYPE OF (curve);
      basis_curve    : curve;
      distance       : length_measure;
      self_intersect : LOGICAL;
      ref_direction  : direction;
    WHERE
      wr1: (basis_curve.dim = 3) AND (ref_direction.dim = 3);
  END_ENTITY; -- offset_curve_3d

  ENTITY offset_surface
    SUBTYPE OF (surface);
      basis_surface  : surface;
      distance       : length_measure;
      self_intersect : LOGICAL;
  END_ENTITY; -- offset_surface

  ENTITY open_shell
    SUBTYPE OF (connected_face_set);
  END_ENTITY; -- open_shell

  ENTITY organization;
      id          : OPTIONAL identifier;
      name        : label;
      description : text;
  END_ENTITY; -- organization

  ENTITY organization_assignment
    ABSTRACT SUPERTYPE;
      assigned_organization : organization;
      role                  : organization_role;
  END_ENTITY; -- organization_assignment

  ENTITY organization_role;
      name : label;
  END_ENTITY; -- organization_role

  ENTITY organizational_project;
      name                      : label;
      description               : text;
      responsible_organizations : SET [1:?] OF organization;
  END_ENTITY; -- organizational_project

  ENTITY oriented_closed_shell
    SUBTYPE OF (closed_shell);
      closed_shell_element : closed_shell;
      orientation          : BOOLEAN;
    DERIVE
      SELF\connected_face_set.cfs_faces : SET [1:?] OF face := 
                                           conditional_reverse(SELF.
                                           orientation,SELF.
                                           closed_shell_element.cfs_faces);
    WHERE
      wr1: NOT ('PLANT_SPATIAL_CONFIGURATION.ORIENTED_CLOSED_SHELL' IN 
               TYPEOF(SELF.closed_shell_element));
  END_ENTITY; -- oriented_closed_shell

  ENTITY oriented_edge
    SUBTYPE OF (edge);
      edge_element : edge;
      orientation  : BOOLEAN;
    DERIVE
      SELF\edge.edge_start : vertex := boolean_choose(SELF.orientation,
                                SELF.edge_element.edge_start,SELF.
                                edge_element.edge_end);
      SELF\edge.edge_end   : vertex := boolean_choose(SELF.orientation,
                                SELF.edge_element.edge_end,SELF.
                                edge_element.edge_start);
    WHERE
      wr1: NOT ('PLANT_SPATIAL_CONFIGURATION.ORIENTED_EDGE' IN TYPEOF(SELF
               .edge_element));
  END_ENTITY; -- oriented_edge

  ENTITY oriented_face
    SUBTYPE OF (face);
      face_element : face;
      orientation  : BOOLEAN;
    DERIVE
      SELF\face.bounds : SET [1:?] OF face_bound := conditional_reverse(
                            SELF.orientation,SELF.face_element.bounds);
    WHERE
      wr1: NOT ('PLANT_SPATIAL_CONFIGURATION.ORIENTED_FACE' IN TYPEOF(SELF
               .face_element));
  END_ENTITY; -- oriented_face

  ENTITY oriented_open_shell
    SUBTYPE OF (open_shell);
      open_shell_element : open_shell;
      orientation        : BOOLEAN;
    DERIVE
      SELF\connected_face_set.cfs_faces : SET [1:?] OF face := 
                                             conditional_reverse(SELF.
                                             orientation,SELF.
                                             open_shell_element.cfs_faces);
    WHERE
      wr1: NOT ('PLANT_SPATIAL_CONFIGURATION.ORIENTED_OPEN_SHELL' IN 
               TYPEOF(SELF.open_shell_element));
  END_ENTITY; -- oriented_open_shell

  ENTITY oriented_path
    SUBTYPE OF (path);
      path_element : path;
      orientation  : BOOLEAN;
    DERIVE
      SELF\path.edge_list : LIST [1:?] OF UNIQUE oriented_edge := 
                               conditional_reverse(SELF.orientation,SELF.
                               path_element.edge_list);
    WHERE
      wr1: NOT ('PLANT_SPATIAL_CONFIGURATION.ORIENTED_PATH' IN TYPEOF(SELF
               .path_element));
  END_ENTITY; -- oriented_path

  ENTITY parabola
    SUBTYPE OF (conic);
      focal_dist : length_measure;
    WHERE
      wr1: focal_dist <> 0;
  END_ENTITY; -- parabola

  ENTITY path
    SUPERTYPE OF (ONEOF (edge_loop,oriented_path))
    SUBTYPE OF (topological_representation_item);
      edge_list : LIST [1:?] OF UNIQUE oriented_edge;
    WHERE
      wr1: path_head_to_tail(SELF);
  END_ENTITY; -- path

  ENTITY pcurve
    SUBTYPE OF (curve);
      basis_surface      : surface;
      reference_to_curve : definitional_representation;
    WHERE
      wr1: SIZEOF(reference_to_curve\representation.items) = 1;
      wr2: 'PLANT_SPATIAL_CONFIGURATION.CURVE' IN TYPEOF(
               reference_to_curve\representation.items[1]);
      wr3: reference_to_curve\representation.items[1]\
               geometric_representation_item.dim = 2;
  END_ENTITY; -- pcurve

  ENTITY person;
      id            : identifier;
      last_name     : OPTIONAL label;
      first_name    : OPTIONAL label;
      middle_names  : OPTIONAL LIST [1:?] OF label;
      prefix_titles : OPTIONAL LIST [1:?] OF label;
      suffix_titles : OPTIONAL LIST [1:?] OF label;
    UNIQUE
      ur1 : id;
    WHERE
      wr1: EXISTS(last_name) OR EXISTS(first_name);
  END_ENTITY; -- person

  ENTITY person_and_organization;
      the_person       : person;
      the_organization : organization;
  END_ENTITY; -- person_and_organization

  ENTITY person_and_organization_assignment
    ABSTRACT SUPERTYPE;
      assigned_person_and_organization : person_and_organization;
      role                             : person_and_organization_role;
  END_ENTITY; -- person_and_organization_assignment

  ENTITY person_and_organization_role;
      name : label;
  END_ENTITY; -- person_and_organization_role

  ENTITY person_assignment
    ABSTRACT SUPERTYPE;
      assigned_person : person;
      role            : person_role;
  END_ENTITY; -- person_assignment

  ENTITY person_role;
      name : label;
  END_ENTITY; -- person_role

  ENTITY pipe_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'pipe') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- pipe_classification

  ENTITY pipe_closure_fitting_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'pipe closure') )) = 1)) )) = 0)) )) =
                0;
  END_ENTITY; -- pipe_closure_fitting_classification

  ENTITY piping_component_class
    SUBTYPE OF (product_category, characterized_object);
  END_ENTITY; -- piping_component_class

  ENTITY piping_component_definition
    SUBTYPE OF (product_definition);
  END_ENTITY; -- piping_component_definition

  ENTITY piping_connector_classification
    SUBTYPE OF (group);
  END_ENTITY; -- piping_connector_classification

  ENTITY piping_design_csg_shape_representation
    SUBTYPE OF (shape_representation);
    WHERE
      wr1: SIZEOF(QUERY ( i <* SELF\representation.items | (NOT (SIZEOF([
               'PLANT_SPATIAL_CONFIGURATION.BOOLEAN_RESULT',
               'PLANT_SPATIAL_CONFIGURATION.CSG_SOLID',
               'PLANT_SPATIAL_CONFIGURATION.AXIS2_PLACEMENT_3D',
               'PLANT_SPATIAL_CONFIGURATION.MAPPED_ITEM'] * TYPEOF(i)) 
               = 1)) )) = 0;
      wr2: SIZEOF(QUERY ( mi <* QUERY ( item <* SELF\representation.items
                | ('PLANT_SPATIAL_CONFIGURATION.MAPPED_ITEM' IN 
                TYPEOF(item))) 
                | (NOT (('PLANT_SPATIAL_CONFIGURATION.' + 
               'PIPING_DESIGN_CSG_SHAPE_REPRESENTATION') IN TYPEOF(mi\
               mapped_item.mapping_source.mapped_representation))) )) = 0;
  END_ENTITY; -- piping_design_csg_shape_representation

  ENTITY piping_system
    SUBTYPE OF (product_definition);
    WHERE
      wr1: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATED_PRODUCT_DEFINITION')
                | (('PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(pdr.
               relating_product_definition.formation.of_product)) AND (pdr.
               relating_product_definition.frame_of_reference.name = 
               'functional occurrence')) )) = 1;
  END_ENTITY; -- piping_system

  ENTITY placement
    SUPERTYPE OF (ONEOF (axis1_placement,axis2_placement_2d,
        axis2_placement_3d))
    SUBTYPE OF (geometric_representation_item);
      location : cartesian_point;
  END_ENTITY; -- placement

  ENTITY plane
    SUBTYPE OF (elementary_surface);
  END_ENTITY; -- plane

  ENTITY plane_angle_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PLANE_ANGLE_UNIT' IN TYPEOF(SELF\
               measure_with_unit.unit_component);
  END_ENTITY; -- plane_angle_measure_with_unit

  ENTITY plane_angle_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 0) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- plane_angle_unit

  ENTITY plant
    SUBTYPE OF (product);
    WHERE
      wr1: (SIZEOF(QUERY ( pscoa <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PLANT_SPATIAL_CONFIGURATION_ORGANIZATION_ASSIGNMENT.ITEMS')
                | (pscoa.role.name = 'plant operator') )) + SIZEOF(
               QUERY ( pscpaoa <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
              'PLANT_SPATIAL_CONFIGURATION_PERSON_AND_ORGANIZATION_ASSIGNMENT.' 
               + 'ITEMS') 
               | (pscpaoa.role.name = 'plant operator') ))) <= 1;
      wr2: (SIZEOF(QUERY ( pscoa <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PLANT_SPATIAL_CONFIGURATION_ORGANIZATION_ASSIGNMENT.ITEMS')
                | (pscoa.role.name = 'plant owner') )) + SIZEOF(
               QUERY ( pscpaoa <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 'PLANT_SPATIAL_CONFIGURATION_PERSON_AND_ORGANIZATION_ASSIGNMENT.' 
               + 'ITEMS') | (pscpaoa.role.name = 'plant owner') )) + 
               SIZEOF(QUERY ( pscpa <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PLANT_SPATIAL_CONFIGURATION_PERSON_ASSIGNMENT.ITEMS') | (
               pscpa.role.name = 'plant owner') ))) >= 1;
      wr3: (SIZEOF(QUERY ( pscoa <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PLANT_SPATIAL_CONFIGURATION_ORGANIZATION_ASSIGNMENT.ITEMS')
                | (pscoa\organization_assignment.role.name = 
               'plant project owner') )) + SIZEOF(QUERY ( pscpaoa <* 
               USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.' +  'PLANT_SPATIAL_CONFIGURATION_PERSON_AND_ORGANIZATION_ASSIGNMENT.' 
               + 'ITEMS') | (pscpaoa\person_and_organization_assignment.
               role.name = 'plant project owner') ))) >= 1;
      wr4: SIZEOF(QUERY ( pdf <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_DEFINITION_FORMATION.OF_PRODUCT') | (NOT (SIZEOF(
               QUERY ( pd <* USEDIN(pdf,
               'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION.FORMATION')
                | (pd.frame_of_reference.name = 'functional occurrence') 
                )) <= 1)) )) = 0;
      wr5: SIZEOF(QUERY ( pdf <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_DEFINITION_FORMATION.OF_PRODUCT') | (NOT (SIZEOF(
               QUERY ( prod_def <* USEDIN(pdf,
               'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION.FORMATION')
                | (SIZEOF(QUERY ( pd <* USEDIN(prod_def,
               'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
               'DEFINITION') | (SIZEOF(QUERY ( pdr <* USEDIN(pd,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (SIZEOF(
               QUERY ( it <* pdr.used_representation.items | ((SIZEOF(
               TYPEOF(it) * [
               'PLANT_SPATIAL_CONFIGURATION.AXIS2_PLACEMENT_2D',
               'PLANT_SPATIAL_CONFIGURATION.AXIS2_PLACEMENT_3D']) = 1) AND 
               (it.name = 'plant placement reference')) )) >= 1) )) >= 
               1) )) >= 1) )) = 1)) )) = 0;
  END_ENTITY; -- plant

  ENTITY plant_item_connection
    SUBTYPE OF (shape_aspect, shape_aspect_relationship);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTOR' IN TYPEOF(
               SELF\shape_aspect_relationship.relating_shape_aspect);
      wr2: 'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTOR' IN TYPEOF(
               SELF\shape_aspect_relationship.related_shape_aspect);
      wr3: SELF\shape_aspect.of_shape\property_definition.
               definition\product_definition.
               frame_of_reference\application_context_element.name IN [
               'functional occurrence','physical occurrence',
               'functional_definition','physical definition'];
      wr4: SELF\shape_aspect_relationship.relating_shape_aspect.
               of_shape\property_definition.
               definition\product_definition.
               frame_of_reference\application_context_element.
               name = SELF\shape_aspect_relationship.related_shape_aspect.
               of_shape\property_definition.
               definition\product_definition.
               frame_of_reference\application_context_element.name;
      wr5: SIZEOF(USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.' + 
               'CLASSIFICATION_ASSIGNMENT.ITEMS')) > 0;
      wr6: SIZEOF(QUERY ( pscca <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
               'ITEMS')
               | (NOT (SIZEOF(['PLANT_SPATIAL_CONFIGURATION.' +
               'CONNECTION_FUNCTIONAL_CLASSIFICATION',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'CONNECTION_MOTION_CLASSIFICATION'] 
               * TYPEOF(pscca.assigned_group)) >= 1)) )) = 0;
      wr7: SIZEOF(QUERY ( pdr <* USEDIN(SELF.of_shape.definition,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PRODUCT_DEFINITION_RELATIONSHIP.' 
               + 'RELATED_PRODUCT_DEFINITION') | (pdr.name = 
               'support usage connection') )) <= 1;
  END_ENTITY; -- plant_item_connection

  ENTITY plant_item_connector
    SUBTYPE OF (shape_aspect);
    WHERE
      wr1 : SELF\shape_aspect.of_shape\property_definition.
                definition\product_definition.
                frame_of_reference\application_context_element.name IN [
                'functional definition','physical definition',
                'functional occurrence','physical occurrence'];
      wr2 : SIZEOF(QUERY ( pic <* (bag_to_set(USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'SHAPE_ASPECT_RELATIONSHIP.RELATED_SHAPE_ASPECT')) + 
                bag_to_set(USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.' + 
                'SHAPE_ASPECT_RELATIONSHIP.RELATING_SHAPE_ASPECT'))) | (
                'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTION' IN 
                TYPEOF(pic)) )) <= 1;
      wr3 : (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( pdr <* USEDIN(sc,'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics')))
                = 1)) )) = 0);
      wr4 : (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS') | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | (SIZEOF(dsc.used_representation.items) >= 2) )) = 1)) 
                )) = 0);
      wr5 : (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | ((1 <= SIZEOF(QUERY ( it <* dsc.used_representation.
                items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name IN ['pressure',
                'minimum pressure','maximum pressure'])) ))) AND (SIZEOF(
                QUERY ( it <* dsc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name IN ['pressure',
                'minimum pressure','maximum pressure'])) )) <= 2)) )) 
                = 1)) )) = 0);
      wr6 : (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | (SIZEOF(QUERY ( it <* dsc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'pressure')) )) <= 1) )) 
                = 1)) )) = 0);
      wr7 : (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | (SIZEOF(QUERY ( it <* dsc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'minimum pressure')) )) 
                <= 1) )) = 1)) )) = 0);
      wr8 : (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | (SIZEOF(QUERY ( it <* dsc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'maximum pressure')) )) 
                <= 1) )) = 1)) )) = 0);
      wr9 : (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
               'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | ((1 <= SIZEOF(QUERY ( it <* dsc.used_representation.
                items | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name IN ['temperature','minimum temperature',
                'maximum temperature'])) ))) AND (SIZEOF(QUERY ( it <* dsc.
                used_representation.items | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name IN ['temperature','minimum temperature',
                'maximum temperature'])) )) <= 2)) )) = 1)) )) = 0);
      wr10: (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | (SIZEOF(QUERY ( it <* dsc.used_representation.items | ((
                SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'temperature')) )) <= 1) )) = 1)) )) = 0);
      wr11: (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | (SIZEOF(QUERY ( it <* dsc.used_representation.items | ((
                SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'minimum temperature')) )) <= 1) )) = 1)) )) 
                = 0);
      wr12: (NOT (SIZEOF(QUERY ( ga <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT.' +
                'ITEMS')
                 | (SIZEOF(TYPEOF(ga.assigned_group) *
                ['PLANT_SPATIAL_CONFIGURATION.' +
                'PIPING_CONNECTOR_CLASSIFICATION',
                'PLANT_SPATIAL_CONFIGURATION.' +
                'CONNECTOR_END_TYPE_CLASSIFICATION']) 
                = 1) )) >= 1)) OR (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') )) >= 1)) OR (
                SIZEOF(QUERY ( sc <* QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (pd.name = 'service characteristics') ) | (NOT (SIZEOF(
                QUERY ( dsc <* QUERY ( pdr <* USEDIN(sc,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'design service characteristics') )
                 | (SIZEOF(QUERY ( it <* dsc.used_representation.items | ((
                SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'maximum temperature')) )) <= 1) )) = 1)) )) 
                = 0);
  END_ENTITY; -- plant_item_connector

  ENTITY plant_item_interference
    SUBTYPE OF (product_definition_relationship);
  END_ENTITY; -- plant_item_interference

  ENTITY plant_item_route
    SUBTYPE OF (product_definition_shape);
    WHERE
      wr1: SELF\property_definition.definition\product_definition.
               frame_of_reference\application_context_element.name =
               'physical occurrence';
      wr2: SIZEOF(TYPEOF(SELF\property_definition.definition) * [
               'PLANT_SPATIAL_CONFIGURATION.PLANT_LINE_DEFINITION',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PLANT_LINE_SEGMENT_DEFINITION']) 
               = 1;
  END_ENTITY; -- plant_item_route

  ENTITY plant_item_weight_representation
    SUBTYPE OF (property_definition_representation);
    WHERE
      wr1: SELF.used_representation.name = 'item weight';
      wr2: SIZEOF(SELF.used_representation.items) >= 2;
      wr3: SIZEOF(QUERY ( it <* SELF.used_representation.items | ((it.name 
               IN ['weight value','mass value','maximum weight value',
               'minimum weight value','maximum mass value',
               'minimum mass value']) AND (NOT (SIZEOF(TYPEOF(it) * [
               'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'QUALIFIED_REPRESENTATION_ITEM']) 
               = 2))) )) = 0;
      wr4: SIZEOF(QUERY ( it <* SELF.used_representation.items | ((
               'PLANT_SPATIAL_CONFIGURATION.GEOMETRIC_REPRESENTATION_ITEM' 
               IN TYPEOF(it)) AND (it.name = 'centre of gravity')) )) = 1;
      wr5: (1 <= SIZEOF(QUERY ( it <* SELF.used_representation.items | (it
               .name IN ['weight value','mass value',
               'maximum weight value',
               'minimum weight value','maximum mass value',
               'minimum mass value']) ))) AND (SIZEOF(QUERY ( it <* SELF.
               used_representation.items | (it.name IN ['weight value',
               'mass value','maximum weight value','minimum weight value',
               'maximum mass value','minimum mass value']) )) <= 2);
      wr6: SIZEOF(QUERY ( it <* SELF\property_definition_representation.
               used_representation.items | ((it.name 
               IN ['maximum weight value','minimum weight value',
               'maximum mass value','minimum mass value']) AND (NOT (
               SIZEOF(QUERY ( tq <* QUERY ( qual <* 
               it\qualified_representation_item.qualifiers | (
               'PLANT_SPATIAL_CONFIGURATION.TYPE_QUALIFIER' 
               IN TYPEOF(qual)) )
                | (tq.name = 'operating') )) = 1))) )) = 0;
  END_ENTITY; -- plant_item_weight_representation

  ENTITY plant_line_definition
    SUBTYPE OF (product_definition_with_associated_documents);
    WHERE
      wr1: SIZEOF(QUERY ( pdr <* USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.'
               + 'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATED_PRODUCT_DEFINITION')
                | ('PLANT_SPATIAL_CONFIGURATION.PIPING_SYSTEM' IN TYPEOF(
               pdr.relating_product_definition)) )) = 1;
      wr2: SIZEOF(QUERY ( pdr <* USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.'
               + 'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATING_PRODUCT_DEFINITION')
                | (
               'PLANT_SPATIAL_CONFIGURATION.PLANT_LINE_SEGMENT_DEFINITION' 
               IN TYPEOF(pdr.related_product_definition)) )) >= 1;
      wr3: (NOT (SIZEOF(QUERY ( pd <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
               'DEFINITION')
                | (SIZEOF(USEDIN(pd,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION')) >= 1) )) =
                0)) OR (SIZEOF(QUERY ( pd <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
               'DEFINITION')
                | (NOT (SIZEOF(QUERY ( pdr <* USEDIN(pd,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (SIZEOF(
               QUERY ( rep <* USEDIN(pdr.used_representation.
               context_of_items,
               'PLANT_SPATIAL_CONFIGURATION.REPRESENTATION.' +
               'CONTEXT_OF_ITEMS')
                | (SIZEOF(QUERY ( prop_def_rep <* USEDIN(rep,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.USED_REPRESENTATION') | 
               ((SIZEOF(['PLANT_SPATIAL_CONFIGURATION.SITE',
               'PLANT_SPATIAL_CONFIGURATION.SITE_BUILDING'] * TYPEOF(
               prop_def_rep.definition)) = 1) OR (
               'PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(prop_def_rep.
               definition.definition.formation.of_product))) )) >= 1) )) >=
                1) )) >= 1)) )) = 0);
      wr4: SELF.frame_of_reference.name = 'functional definition';
  END_ENTITY; -- plant_line_definition

  ENTITY plant_line_segment_definition
    SUBTYPE OF (product_definition);
    WHERE
      wr1 : SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | ('PLANT_SPATIAL_CONFIGURATION.PLANT_LINE_DEFINITION' IN 
                TYPEOF(pdr.relating_product_definition)) )) >= 1;
      wr2 : SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | ('PLANT_SPATIAL_CONFIGURATION.SHAPE_DEFINITION' IN 
                TYPEOF(pd)) )) >= 1;
      wr3 : SELF.frame_of_reference\application_context_element.name = 
                'functional definition';
      wr4 : SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'line segment characteristics') )) = 1;
      wr5 : SIZEOF(QUERY ( lsc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'line segment characteristics') )
                 | (NOT (SIZEOF(lsc.used_representation.items) >= 2)) )) = 
                0;
      wr6 : SIZEOF(QUERY ( lsc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'line segment characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* lsc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'design pressure')) )) = 1))
                )) = 0;
      wr7 : SIZEOF(QUERY ( lsc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'line segment characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* lsc.used_representation.items
                 | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'design temperature')) )) = 1)) )) = 0;
      wr8 : SIZEOF(QUERY ( lsc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'line segment characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* lsc.used_representation.items
                 | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.LENGTH_MEASURE_WITH_UNIT']) = 
                2) AND (it.name = 'elevation')) )) <= 1)) )) = 0;
      wr9 : SIZEOF(QUERY ( lsc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'line segment characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* lsc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'corrosion allowance')) )) <=
                 1)) )) = 0;
      wr10: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') )) >= 1)) OR (SIZEOF(
                QUERY ( si <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') ) | (NOT (SIZEOF(
                QUERY ( pd <* USEDIN(si,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (NOT (SIZEOF(QUERY ( pds <* QUERY ( pdr <* USEDIN(pd,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (
                'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_SHAPE' IN 
                TYPEOF(pdr)) ) | (pds.used_representation.name = 
                'segment insulation characteristics') )) = 1)) )) = 0)) )) 
                = 0);
      wr11: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') )) >= 1)) OR (SIZEOF(
                QUERY ( si <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') ) | (NOT (SIZEOF(
                QUERY ( pd <* USEDIN(si,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION.DEFINITION')
                 | (NOT (SIZEOF(QUERY ( sic <* QUERY ( pds <* 
                QUERY ( pdr <* USEDIN(pd,'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (
                'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_SHAPE' IN 
                TYPEOF(pdr)) ) | (pds.used_representation.name = 
                'segment insulation characteristics') ) | (SIZEOF(sic.
                used_representation.items) >= 1) )) = 1)) )) = 0)) )) = 0);
      wr12: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') )) >= 1)) OR (SIZEOF(
                QUERY ( si <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') ) | (NOT (SIZEOF(
                QUERY ( pd <* USEDIN(si,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (NOT (SIZEOF(QUERY ( sic <* QUERY ( pds <* 
                QUERY ( pdr <* USEDIN(pd,'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (
                'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_SHAPE' IN 
                TYPEOF(pdr)) ) | (pds.used_representation.name = 
                'segment insulation characteristics') ) | ((1 <= SIZEOF(
                QUERY ( it <* sic.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.LENGTH_MEASURE_WITH_UNIT']) = 
                2) AND (it.name IN ['thickness','minimum thickness',
                'maximum thickness'])) ))) AND (SIZEOF(QUERY ( it <* sic.
                used_representation.items | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.LENGTH_MEASURE_WITH_UNIT']) = 
                2) AND (it.name IN ['thickness','minimum thickness',
                'maximum thickness'])) )) <= 2)) )) = 1)) )) = 0)) )) = 0);
      wr13: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') )) >= 1)) OR (SIZEOF(
                QUERY ( si <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') ) | (NOT (SIZEOF(
                QUERY ( pd <* USEDIN(si,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (NOT (SIZEOF(QUERY ( sic <* QUERY ( pds <* 
                QUERY ( pdr <* USEDIN(pd,'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (
                'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_SHAPE' IN 
                TYPEOF(pdr)) ) | (pds.used_representation.name = 
                'segment insulation characteristics') ) | (SIZEOF(
                QUERY ( it <* sic.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.LENGTH_MEASURE_WITH_UNIT']) = 
                2) AND (it.name = 'thickness')) )) <= 1) )) = 1)) )) 
                = 0)) )) = 0);
      wr14: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') )) >= 1)) OR (SIZEOF(
                QUERY ( si <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') ) | (NOT (SIZEOF(
                QUERY ( pd <* USEDIN(si,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (NOT (SIZEOF(QUERY ( sic <* QUERY ( pds <* 
                QUERY ( pdr <* USEDIN(pd,'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (
                'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_SHAPE' IN 
                TYPEOF(pdr)) ) | (pds.used_representation.name = 
                'segment insulation characteristics') ) | (SIZEOF(
                QUERY ( it <* sic.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.LENGTH_MEASURE_WITH_UNIT']) = 
                2) AND (it.name = 'minimum thickness')) )) <= 1) )) 
                = 1)) )) = 0)) )) = 0);
      wr15: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') )) >= 1)) OR (SIZEOF(
                QUERY ( si <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') ) | (NOT (SIZEOF(
                QUERY ( pd <* USEDIN(si,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (NOT (SIZEOF(QUERY ( sic <* QUERY ( pds <* 
                QUERY ( pdr <* USEDIN(pd,'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (
                'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_SHAPE' IN 
                TYPEOF(pdr)) ) | (pds.used_representation.name = 
                'segment insulation characteristics') ) | (SIZEOF(
                QUERY ( it <* sic.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.LENGTH_MEASURE_WITH_UNIT']) = 
                2) AND (it.name = 'maximum thickness')) )) <= 1) )) 
                = 1)) )) = 0)) )) = 0);
      wr16: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') )) >= 1)) OR (SIZEOF(
                QUERY ( si <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PRODUCT_DEFINITION_RELATIONSHIP.' +
                'RELATED_PRODUCT_DEFINITION')
                 | (pdr.name = 'segment insulation') ) | (NOT (SIZEOF(
                QUERY ( pd <* USEDIN(si,
                'PLANT_SPATIAL_CONFIGURATION.PROPERTY_DEFINITION.' +
                'DEFINITION')
                 | (NOT (SIZEOF(QUERY ( sic <* QUERY ( pds <* 
                QUERY ( pdr <* USEDIN(pd,'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (
                'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_SHAPE' IN 
                TYPEOF(pdr)) ) | (pds.used_representation.name = 
                'segment insulation characteristics') ) | (SIZEOF(
                QUERY ( it <* sic.used_representation.items |
                (('PLANT_SPATIAL_CONFIGURATION.' +
                'DESCRIPTIVE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'boundaries')) )) <= 1) )) = 
                1)) )) = 0)) )) = 0);
  END_ENTITY; -- plant_line_segment_definition

  ENTITY plant_line_segment_termination
    SUBTYPE OF (shape_aspect);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PLANT_LINE_SEGMENT_DEFINITION' IN 
               TYPEOF(SELF.of_shape.definition);
      wr2: SIZEOF(QUERY ( sar <* (USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'SHAPE_ASPECT_RELATIONSHIP.RELATING_SHAPE_ASPECT') + USEDIN(
               SELF,'PLANT_SPATIAL_CONFIGURATION.' + 
               'SHAPE_ASPECT_RELATIONSHIP.RELATED_SHAPE_ASPECT')) | (NOT (
               SIZEOF(TYPEOF(sar) * [
               'PLANT_SPATIAL_CONFIGURATION.LINE_BRANCH_CONNECTION',
               'PLANT_SPATIAL_CONFIGURATION.LINE_PLANT_ITEM_CONNECTION',
               'PLANT_SPATIAL_CONFIGURATION.LINE_TERMINATION_CONNECTION']) 
               = 1)) )) = 0;
  END_ENTITY; -- plant_line_segment_termination

  ENTITY plant_spatial_configuration_action_request_assignment
    SUBTYPE OF (action_request_assignment);
      items : SET [1:?] OF plant_spatial_configuration_action_request_item;
  END_ENTITY; -- plant_spatial_configuration_action_request_assignment

  ENTITY plant_spatial_configuration_approval_assignment
    SUBTYPE OF (approval_assignment);
      items : SET [1:?] OF approval_item;
  END_ENTITY; -- plant_spatial_configuration_approval_assignment

  ENTITY plant_spatial_configuration_change_assignment
    SUBTYPE OF (action_assignment);
      items : SET [1:?] OF change_item;
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.CHANGE_ACTION' IN TYPEOF(SELF.
               assigned_action);
  END_ENTITY; -- plant_spatial_configuration_change_assignment

  ENTITY plant_spatial_configuration_date_and_time_assignment
    SUBTYPE OF (date_and_time_assignment);
      items : SET [1:?] OF plant_spatial_configuration_date_and_time_item;
  END_ENTITY; -- plant_spatial_configuration_date_and_time_assignment

  ENTITY plant_spatial_configuration_date_assignment
    SUBTYPE OF (date_assignment);
      items : SET [1:?] OF plant_spatial_configuration_dated_item;
  END_ENTITY; -- plant_spatial_configuration_date_assignment

  ENTITY plant_spatial_configuration_document_reference
    SUBTYPE OF (document_reference);
      items : SET [1:?] OF plant_spatial_configuration_document_item;
  END_ENTITY; -- plant_spatial_configuration_document_reference

  ENTITY plant_spatial_configuration_organization_assignment
    SUBTYPE OF (organization_assignment);
      items : SET [1:?] OF plant_spatial_configuration_organization_item;
    WHERE
      wr1: plant_spatial_configuration_organization_correlation(SELF);
  END_ENTITY; -- plant_spatial_configuration_organization_assignment

  ENTITY plant_spatial_configuration_person_and_organization_assignment
    SUBTYPE OF (person_and_organization_assignment);
      items : SET [1:?] OF
                  plant_spatial_configuration_person_and_organization_item;
    WHERE
      wr1: plant_spatial_configuration_person_and_organization_correlation(
               SELF);
  END_ENTITY; -- plant_spatial_configuration_person_and_organization_assignment

  ENTITY plant_spatial_configuration_person_assignment
    SUBTYPE OF (person_assignment);
      items : SET [1:?] OF plant_spatial_configuration_person_item;
    WHERE
      wr1: plant_spatial_configuration_person_correlation(SELF);
  END_ENTITY; -- plant_spatial_configuration_person_assignment

  ENTITY point
    SUPERTYPE OF (ONEOF (cartesian_point,point_on_curve,point_on_surface,
        point_replica,degenerate_pcurve))
    SUBTYPE OF (geometric_representation_item);
  END_ENTITY; -- point

  ENTITY point_on_curve
    SUBTYPE OF (point);
      basis_curve     : curve;
      point_parameter : parameter_value;
  END_ENTITY; -- point_on_curve

  ENTITY point_on_surface
    SUBTYPE OF (point);
      basis_surface     : surface;
      point_parameter_u : parameter_value;
      point_parameter_v : parameter_value;
  END_ENTITY; -- point_on_surface

  ENTITY point_replica
    SUBTYPE OF (point);
      parent_pt      : point;
      transformation : cartesian_transformation_operator;
    WHERE
      wr1: transformation.dim = parent_pt.dim;
      wr2: acyclic_point_replica(SELF,parent_pt);
  END_ENTITY; -- point_replica

  ENTITY poly_loop
    SUBTYPE OF (loop, geometric_representation_item);
      polygon : LIST [3:?] OF UNIQUE cartesian_point;
  END_ENTITY; -- poly_loop

  ENTITY polyline
    SUBTYPE OF (bounded_curve);
      points : LIST [2:?] OF cartesian_point;
  END_ENTITY; -- polyline

  ENTITY pre_defined_item;
      name : label;
  END_ENTITY; -- pre_defined_item

  ENTITY presentation_layer_assignment;
      name           : label;
      description    : text;
      assigned_items : SET [1:?] OF layered_item;
  END_ENTITY; -- presentation_layer_assignment

  ENTITY process_capability
    SUBTYPE OF (property_definition);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(SELF.definition\
               product_definition.formation.of_product);
      wr2: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PROPERTY_DEFINITION_REPRESENTATION.' 
               + 'DEFINITION') | ((pdr.used_representation.name = 
               'production capacity') AND (NOT (SIZEOF(QUERY ( it <* pdr.
               used_representation.items | (('PLANT_SPATIAL_CONFIGURATION.'
               + 'DESCRIPTIVE_REPRESENTATION_ITEM' 
               IN TYPEOF(it)) AND (it.name = 'production type')) )) 
               = 1))) )) = 0;
  END_ENTITY; -- process_capability

  ENTITY product;
      id                 : identifier;
      name               : label;
      description        : text;
      frame_of_reference : SET [1:?] OF product_context;
    UNIQUE
      ur1 : id;
  END_ENTITY; -- product

  ENTITY product_category;
      name        : label;
      description : OPTIONAL text;
  END_ENTITY; -- product_category

  ENTITY product_category_relationship;
      name         : label;
      description  : text;
      category     : product_category;
      sub_category : product_category;
    WHERE
      wr1: acyclic_product_category_relationship(SELF,[SELF.sub_category]);
  END_ENTITY; -- product_category_relationship

  ENTITY product_context
    SUBTYPE OF (application_context_element);
      discipline_type : label;
  END_ENTITY; -- product_context

  ENTITY product_definition;
      id                 : identifier;
      description        : text;
      formation          : product_definition_formation;
      frame_of_reference : product_definition_context;
  END_ENTITY; -- product_definition

  ENTITY product_definition_context
    SUBTYPE OF (application_context_element);
      life_cycle_stage : label;
  END_ENTITY; -- product_definition_context

  ENTITY product_definition_formation;
      id          : identifier;
      description : text;
      of_product  : product;
    UNIQUE
      ur1 : id, of_product;
  END_ENTITY; -- product_definition_formation

  ENTITY product_definition_formation_relationship;
      id                                    : identifier;
      name                                  : label;
      description                           : text;
      relating_product_definition_formation : product_definition_formation;
      related_product_definition_formation  : product_definition_formation;
  END_ENTITY; -- product_definition_formation_relationship

  ENTITY product_definition_formation_with_specified_source
    SUBTYPE OF (product_definition_formation);
      make_or_buy : source;
  END_ENTITY; -- product_definition_formation_with_specified_source

  ENTITY product_definition_relationship;
      id                          : identifier;
      name                        : label;
      description                 : text;
      relating_product_definition : product_definition;
      related_product_definition  : product_definition;
  END_ENTITY; -- product_definition_relationship

  ENTITY product_definition_shape
    SUBTYPE OF (property_definition);
    UNIQUE
      ur1 : definition;
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.CHARACTERIZED_PRODUCT_DEFINITION' 
               IN TYPEOF(SELF\property_definition.definition);
  END_ENTITY; -- product_definition_shape

  ENTITY product_definition_substitute;
      description           : text;
      context_relationship  : product_definition_relationship;
      substitute_definition : product_definition;
    WHERE
      wr1: context_relationship.related_product_definition :<>: 
               substitute_definition;
  END_ENTITY; -- product_definition_substitute

  ENTITY product_definition_usage
    SUPERTYPE OF (ONEOF (make_from_usage_option,assembly_component_usage))
    SUBTYPE OF (product_definition_relationship);
    UNIQUE
      ur1 : id, relating_product_definition, related_product_definition;
    WHERE
      wr1: acyclic_product_definition_relationship(SELF,[SELF\
               product_definition_relationship.related_product_definition],
               'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_USAGE.' + 
               'RELATED_PRODUCT_DEFINITION');
  END_ENTITY; -- product_definition_usage

  ENTITY product_definition_with_associated_documents
    SUBTYPE OF (product_definition);
      documentation_ids : SET [1:?] OF document;
  END_ENTITY; -- product_definition_with_associated_documents

  ENTITY product_material_composition_relationship
    SUBTYPE OF (product_definition_relationship);
      class                : label;
      constituent_amount   : SET [1:?] OF measure_with_unit;
      composition_basis    : label;
      determination_method : text;
  END_ENTITY; -- product_material_composition_relationship

  ENTITY product_related_product_category
    SUBTYPE OF (product_category);
      products : SET [1:?] OF product;
  END_ENTITY; -- product_related_product_category

  ENTITY property_definition;
      name        : label;
      description : text;
      definition  : characterized_definition;
  END_ENTITY; -- property_definition

  ENTITY property_definition_relationship;
      name                         : label;
      description                  : text;
      relating_property_definition : property_definition;
      related_property_definition  : property_definition;
  END_ENTITY; -- property_definition_relationship

  ENTITY property_definition_representation;
      definition          : property_definition;
      used_representation : representation;
  END_ENTITY; -- property_definition_representation

  ENTITY purchase_assignment
    SUBTYPE OF (action_assignment);
      items : SET [1:?] OF purchase_item;
  END_ENTITY; -- purchase_assignment

  ENTITY qualified_representation_item
    SUBTYPE OF (representation_item);
      qualifiers : SET [1:?] OF value_qualifier;
    WHERE
      wr1: SIZEOF(QUERY ( temp <* qualifiers | (
               'PLANT_SPATIAL_CONFIGURATION.PRECISION_QUALIFIER' IN TYPEOF(
               temp)) )) < 2;
  END_ENTITY; -- qualified_representation_item

  ENTITY quasi_uniform_curve
    SUBTYPE OF (b_spline_curve);
  END_ENTITY; -- quasi_uniform_curve

  ENTITY quasi_uniform_surface
    SUBTYPE OF (b_spline_surface);
  END_ENTITY; -- quasi_uniform_surface

  ENTITY ratio_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.RATIO_UNIT' IN TYPEOF(SELF\
               measure_with_unit.unit_component);
  END_ENTITY; -- ratio_measure_with_unit

  ENTITY ratio_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 0) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- ratio_unit

  ENTITY rational_b_spline_curve
    SUBTYPE OF (b_spline_curve);
      weights_data : LIST [2:?] OF REAL;
    DERIVE
      weights : ARRAY [0:upper_index_on_control_points] OF REAL := 
                   list_to_array(weights_data,0,
                   upper_index_on_control_points);
    WHERE
      wr1: SIZEOF(weights_data) = SIZEOF(SELF\b_spline_curve.
               control_points_list);
      wr2: curve_weights_positive(SELF);
  END_ENTITY; -- rational_b_spline_curve

  ENTITY rational_b_spline_surface
    SUBTYPE OF (b_spline_surface);
      weights_data : LIST [2:?] OF LIST [2:?] OF REAL;
    DERIVE
      weights : ARRAY [0:u_upper] OF ARRAY [0:v_upper] OF REAL := 
                   make_array_of_array(weights_data,0,u_upper,0,v_upper);
    WHERE
      wr1: (SIZEOF(weights_data) = SIZEOF(SELF\b_spline_surface.
               control_points_list)) AND (SIZEOF(weights_data[1]) = SIZEOF(
               SELF\b_spline_surface.control_points_list[1]));
      wr2: surface_weights_positive(SELF);
  END_ENTITY; -- rational_b_spline_surface

  ENTITY rectangular_composite_surface
    SUBTYPE OF (bounded_surface);
      segments : LIST [1:?] OF LIST [1:?] OF surface_patch;
    DERIVE
      n_u : INTEGER := SIZEOF(segments);
      n_v : INTEGER := SIZEOF(segments[1]);
    WHERE
      wr1: [] = QUERY ( s <* segments | (n_v <> SIZEOF(s)) );
      wr2: constraints_rectangular_composite_surface(SELF);
  END_ENTITY; -- rectangular_composite_surface

  ENTITY rectangular_trimmed_surface
    SUBTYPE OF (bounded_surface);
      basis_surface : surface;
      u1            : parameter_value;
      u2            : parameter_value;
      v1            : parameter_value;
      v2            : parameter_value;
      usense        : BOOLEAN;
      vsense        : BOOLEAN;
    WHERE
      wr1: u1 <> u2;
      wr2: v1 <> v2;
      wr3: (('PLANT_SPATIAL_CONFIGURATION.ELEMENTARY_SURFACE' IN TYPEOF(
               basis_surface)) AND (NOT (
               'PLANT_SPATIAL_CONFIGURATION.PLANE' 
               IN TYPEOF(basis_surface))))
               OR ('PLANT_SPATIAL_CONFIGURATION.SURFACE_OF_REVOLUTION' IN 
               TYPEOF(basis_surface)) OR (usense = (u2 > u1));
      wr4: ('PLANT_SPATIAL_CONFIGURATION.SPHERICAL_SURFACE' IN TYPEOF(
               basis_surface)) OR (
               'PLANT_SPATIAL_CONFIGURATION.TOROIDAL_SURFACE' IN TYPEOF(
               basis_surface)) OR (vsense = (v2 > v1));
  END_ENTITY; -- rectangular_trimmed_surface

  ENTITY reducer_fitting_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.GROUP_ASSIGNMENT.' +
               'ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.GROUP_ASSIGNMENT.' +
               'ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'reducer') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- reducer_fitting_classification

  ENTITY reference_geometry
    SUBTYPE OF (derived_shape_aspect);
    WHERE
      wr1: SIZEOF(QUERY ( pd <* USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.' 
               + 'PROPERTY_DEFINITION.DEFINITION') 
               | (NOT (SIZEOF(USEDIN(pd,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION')) >= 1)) )) 
               = 0;
  END_ENTITY; -- reference_geometry

  ENTITY reparametrised_composite_curve_segment
    SUBTYPE OF (composite_curve_segment);
      param_length : parameter_value;
    WHERE
      wr1: param_length > 0;
  END_ENTITY; -- reparametrised_composite_curve_segment

  ENTITY representation;
      name             : label;
      items            : SET [1:?] OF representation_item;
      context_of_items : representation_context;
  END_ENTITY; -- representation

  ENTITY representation_context;
      context_identifier : identifier;
      context_type       : text;
    INVERSE
      representations_in_context : SET [1:?] OF representation FOR 
                                      context_of_items;
  END_ENTITY; -- representation_context

  ENTITY representation_item;
      name : label;
    WHERE
      wr1: SIZEOF(using_representations(SELF)) > 0;
  END_ENTITY; -- representation_item

  ENTITY representation_map;
      mapping_origin        : representation_item;
      mapped_representation : representation;
    INVERSE
      map_usage : SET [1:?] OF mapped_item FOR mapping_source;
    WHERE
      wr1: item_in_context(SELF.mapping_origin,SELF.mapped_representation.
               context_of_items);
  END_ENTITY; -- representation_map

  ENTITY required_material_property
    SUBTYPE OF (material_property);
    WHERE
      wr1: (SIZEOF(TYPEOF(SELF\property_definition.definition) * [
               'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTOR',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'EXTERNALLY_DEFINED_PLANT_ITEM']) 
               = 1) OR (('PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION' 
               IN TYPEOF(SELF.definition)) AND (SIZEOF(QUERY ( pc <* 
               SELF\property_definition.
               definition\product_definition.formation.of_product.
               frame_of_reference | 
               (pc.discipline_type = 'process plant') )) = 1));
      wr2: SIZEOF(QUERY ( ra <* QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PROPERTY_DEFINITION_RELATIONSHIP.' +
               'RELATED_PROPERTY_DEFINITION')
                | (pdr.name = 'requirement allocation') ) | (
               'PLANT_SPATIAL_CONFIGURATION.MATERIAL_PROPERTY' IN TYPEOF(ra
               .relating_property_definition)) )) >= 1;
  END_ENTITY; -- required_material_property

  ENTITY reserved_space
    SUBTYPE OF (shape_aspect);
    WHERE
      wr1: SELF\shape_aspect.of_shape\property_definition.
               definition\product_definition.
               frame_of_reference\application_context_element.name =
               'physical occurrence';
  END_ENTITY; -- reserved_space

  ENTITY revolved_area_solid
    SUBTYPE OF (swept_area_solid);
      axis  : axis1_placement;
      angle : plane_angle_measure;
    DERIVE
      axis_line : line := line(axis.location,vector(axis.z,1));
  END_ENTITY; -- revolved_area_solid

  ENTITY revolved_face_solid
    SUBTYPE OF (swept_face_solid);
      axis  : axis1_placement;
      angle : plane_angle_measure;
    DERIVE
      axis_line : line := line(axis.location,vector(axis.z,1));
  END_ENTITY; -- revolved_face_solid

  ENTITY right_circular_cone
    SUBTYPE OF (geometric_representation_item);
      position   : axis1_placement;
      height     : positive_length_measure;
      radius     : length_measure;
      semi_angle : plane_angle_measure;
    WHERE
      wr1: radius >= 0;
  END_ENTITY; -- right_circular_cone

  ENTITY right_circular_cylinder
    SUBTYPE OF (geometric_representation_item);
      position : axis1_placement;
      height   : positive_length_measure;
      radius   : positive_length_measure;
  END_ENTITY; -- right_circular_cylinder

  ENTITY seam_curve
    SUBTYPE OF (surface_curve);
    WHERE
      wr1: SIZEOF(SELF\surface_curve.associated_geometry) = 2;
      wr2: associated_surface(SELF\surface_curve.associated_geometry[1]) =
                associated_surface(SELF\surface_curve.
                associated_geometry[2]);
      wr3: 'PLANT_SPATIAL_CONFIGURATION.PCURVE' IN TYPEOF(SELF\
               surface_curve.associated_geometry[1]);
      wr4: 'PLANT_SPATIAL_CONFIGURATION.PCURVE' IN TYPEOF(SELF\
               surface_curve.associated_geometry[2]);
  END_ENTITY; -- seam_curve

  ENTITY shape_aspect;
      name                 : label;
      description          : text;
      of_shape             : product_definition_shape;
      product_definitional : LOGICAL;
  END_ENTITY; -- shape_aspect

  ENTITY shape_aspect_deriving_relationship
    SUBTYPE OF (shape_aspect_relationship);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.DERIVED_SHAPE_ASPECT' IN TYPEOF(
               SELF\shape_aspect_relationship.relating_shape_aspect);
  END_ENTITY; -- shape_aspect_deriving_relationship

  ENTITY shape_aspect_relationship;
      name                  : label;
      description           : text;
      relating_shape_aspect : shape_aspect;
      related_shape_aspect  : shape_aspect;
  END_ENTITY; -- shape_aspect_relationship

  ENTITY shape_definition_representation
    SUBTYPE OF (property_definition_representation);
    WHERE
      wr1: ('PLANT_SPATIAL_CONFIGURATION.SHAPE_DEFINITION' IN TYPEOF(SELF.
               definition.definition)) OR (
               'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_SHAPE' IN 
               TYPEOF(SELF.definition));
      wr2: 'PLANT_SPATIAL_CONFIGURATION.SHAPE_REPRESENTATION' IN TYPEOF(
               SELF.used_representation);
  END_ENTITY; -- shape_definition_representation

  ENTITY shape_dimension_representation
    SUBTYPE OF (shape_representation);
    WHERE
      wr1: SIZEOF(QUERY ( temp <* SELF.items | (NOT (
               'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' IN
                TYPEOF(temp))) )) = 0;
      wr2: SIZEOF(SELF.items) <= 2;
      wr3: SIZEOF(QUERY ( pos_mri <* QUERY ( real_mri <* SELF.items | (
               'REAL' IN TYPEOF(real_mri\measure_with_unit.
                value_component)) )
                | (NOT (pos_mri\measure_with_unit.value_component > 0)) )) 
               = 0;
  END_ENTITY; -- shape_dimension_representation

  ENTITY shape_representation
    SUBTYPE OF (representation);
  END_ENTITY; -- shape_representation

  ENTITY shell_based_wireframe_model
    SUBTYPE OF (geometric_representation_item);
      sbwm_boundary : SET [1:?] OF shell;
    WHERE
      wr1: constraints_geometry_shell_based_wireframe_model(SELF);
  END_ENTITY; -- shell_based_wireframe_model

  ENTITY si_unit
    SUBTYPE OF (named_unit);
      prefix : OPTIONAL si_prefix;
      name   : si_unit_name;
    DERIVE
      SELF\named_unit.dimensions : dimensional_exponents := 
                                      dimensions_for_si_unit(SELF.name);
  END_ENTITY; -- si_unit

  ENTITY site
    SUBTYPE OF (characterized_object, property_definition);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(SELF\
               property_definition.definition\product_definition.formation.
               of_product);
  END_ENTITY; -- site

  ENTITY site_building
    SUBTYPE OF (property_definition);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.SITE' IN TYPEOF(SELF.definition);
      wr2: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | ((pdr.
               used_representation.name = 'building number') AND (SIZEOF(
               QUERY ( it <* pdr.used_representation.items |
               ('PLANT_SPATIAL_CONFIGURATION.' +
               'DESCRIPTIVE_REPRESENTATION_ITEM' 
               IN TYPEOF(it)) )) = 1)) )) = 1;
      wr3: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (SIZEOF(
               QUERY ( it <* pdr.used_representation.items | ((SIZEOF([
               'PLANT_SPATIAL_CONFIGURATION.AXIS_PLACEMENT_2D',
               'PLANT_SPATIAL_CONFIGURATION.AXIS_PLACEMENT_3D'] 
               * TYPEOF(it)) 
               = 1) AND (it.name = 'building orientation') AND (it.location
               .name = 'building location')) )) = 1) )) <= 1;
  END_ENTITY; -- site_building

  ENTITY site_feature
    SUBTYPE OF (property_definition);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.SITE' IN TYPEOF(SELF.definition);
      wr2: SIZEOF(USEDIN(SELF,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION')) = 3;
      wr3: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (SIZEOF(
               QUERY ( it <* pdr.used_representation.items |
               (('PLANT_SPATIAL_CONFIGURATION.' +
               'DESCRIPTIVE_REPRESENTATION_ITEM'
               IN TYPEOF(it)) AND (it.
               name = 'site feature type')) )) = 1) )) = 1;
      wr4: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (SIZEOF(
               QUERY ( it <* pdr.used_representation.items | ((SIZEOF([
               'PLANT_SPATIAL_CONFIGURATION.AXIS_PLACEMENT_2D',
               'PLANT_SPATIAL_CONFIGURATION.AXIS_PLACEMENT_3D'] 
               * TYPEOF(it)) 
               = 1) AND (it.name = 'feature orientation') AND (it.location.
               name = 'feature location')) )) = 1) )) = 1;
      wr5: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (SIZEOF(
               QUERY ( it <* pdr.used_representation.items |
               (('PLANT_SPATIAL_CONFIGURATION.' +
               'DESCRIPTIVE_REPRESENTATION_ITEM'
               IN TYPEOF(pdr.used_representation)) AND (it.name = 
               'origin type') AND (it.description IN ['man made',
               'natural'])) )) = 1) )) = 1;
  END_ENTITY; -- site_feature

  ENTITY site_representation
    SUBTYPE OF (shape_representation);
    WHERE
      wr1: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'PROPERTY_DEFINITION_REPRESENTATION.USED_REPRESENTATION') | 
               (NOT ('PLANT_SPATIAL_CONFIGURATION.SITE' IN TYPEOF(pdr.
               definition.definition))) )) = 0;
      wr2: SIZEOF(QUERY ( item <* SELF.items | (NOT (SIZEOF([
               'PLANT_SPATIAL_CONFIGURATION.CONNECTED_FACE_SET',
               'PLANT_SPATIAL_CONFIGURATION.GEOMETRIC_CURVE_SET'] * TYPEOF(
               item)) = 1)) )) = 1;
      wr3: SIZEOF(QUERY ( cfs <* QUERY ( item <* SELF.items | (
               'PLANT_SPATIAL_CONFIGURATION.CONNECTED_FACE_SET' IN TYPEOF(
               item)) ) | (NOT (SIZEOF(QUERY ( fcs <* cfs\
               connected_face_set.cfs_faces | (NOT (SIZEOF(QUERY ( bnds <* 
               fcs.bounds | (NOT ('PLANT_SPATIAL_CONFIGURATION.POLY_LOOP' 
               IN TYPEOF(bnds.bound))) )) = 0)) )) = 0)) )) = 0;
      wr4: SIZEOF(QUERY ( cfs <* QUERY ( item <* SELF.items | (
               'PLANT_SPATIAL_CONFIGURATION.CONNECTED_FACE_SET' IN TYPEOF(
               item)) ) | (NOT (SIZEOF(QUERY ( fcs <* cfs\
               connected_face_set.cfs_faces | (NOT (SIZEOF(QUERY ( bnds <* 
               fcs.bounds | (NOT (SIZEOF(bnds.bound\poly_loop.polygon) 
               <= 4)) )) = 0)) )) = 0)) )) = 0;
      wr5: SIZEOF(QUERY ( gcs <* QUERY ( item <* SELF.items | (
               'PLANT_SPATIAL_CONFIGURATION.GEOMETRIC_CURVE_SET' IN TYPEOF(
               item)) ) | (NOT (SIZEOF(QUERY ( el <* gcs\geometric_set.
               elements | (NOT (SIZEOF([
               'PLANT_SPATIAL_CONFIGURATION.CARTESIAN_POINT',
               'PLANT_SPATIAL_CONFIGURATION.POLYLINE'] * TYPEOF(el)) 
               = 1)) )) = 0)) )) = 0;
      wr6: SIZEOF(QUERY ( gcs <* QUERY ( item <* SELF.items | (
               'PLANT_SPATIAL_CONFIGURATION.GEOMETRIC_CURVE_SET' IN TYPEOF(
               item)) ) | (NOT (SIZEOF(QUERY ( el <* gcs\geometric_set.
               elements | ('PLANT_SPATIAL_CONFIGURATION.CARTESIAN_POINT' IN
                TYPEOF(el)) )) >= 1)) )) = 0;
      wr7: SIZEOF(QUERY ( gcs <* QUERY ( item <* SELF.items | (
               'PLANT_SPATIAL_CONFIGURATION.GEOMETRIC_CURVE_SET' IN TYPEOF(
               item)) ) | (NOT (SIZEOF(QUERY ( pline <* QUERY ( el <* gcs\
               geometric_set.elements | (
               'PLANT_SPATIAL_CONFIGURATION.POLYLINE' IN TYPEOF(el)) ) | (
               NOT (SIZEOF(QUERY ( pline_pt <* pline\polyline.points | (
               NOT (pline_pt IN gcs\geometric_set.elements)) )) = 0)) )) = 
               0)) )) = 0;
  END_ENTITY; -- site_representation

  ENTITY solid_angle_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.SOLID_ANGLE_UNIT' IN TYPEOF(SELF\
               measure_with_unit.unit_component);
  END_ENTITY; -- solid_angle_measure_with_unit

  ENTITY solid_angle_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 0) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- solid_angle_unit

  ENTITY solid_model
    SUPERTYPE OF (ONEOF (csg_solid,manifold_solid_brep,swept_face_solid,
        swept_area_solid))
    SUBTYPE OF (geometric_representation_item);
  END_ENTITY; -- solid_model

  ENTITY spacer_fitting_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.GROUP_ASSIGNMENT.' +
               'ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.GROUP_ASSIGNMENT.' +
               'ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'spacer') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- spacer_fitting_classification

  ENTITY specialty_item_classification
    SUBTYPE OF (group);
  END_ENTITY; -- specialty_item_classification

  ENTITY sphere
    SUBTYPE OF (geometric_representation_item);
      radius : positive_length_measure;
      centre : point;
  END_ENTITY; -- sphere

  ENTITY spherical_surface
    SUBTYPE OF (elementary_surface);
      radius : positive_length_measure;
  END_ENTITY; -- spherical_surface

  ENTITY stream_design_case
    SUBTYPE OF (property_definition, characterized_object);
    WHERE
      wr1 : SIZEOF(QUERY ( pd <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION.DEFINITION') | (
                'PLANT_SPATIAL_CONFIGURATION.STREAM_PHASE' 
                IN TYPEOF(pd)) )) >= 1;
      wr2 : SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream flow characteristics') )) = 1;
      wr3 : SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT (SIZEOF(sfc.used_representation.items) >= 2)) )) = 
                0;
      wr4 : SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT ((1 <= SIZEOF(QUERY ( it <* sfc.used_representation
                .items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name IN ['flow rate',
                'minimum flow rate','maximum flow rate'])) ))) AND (SIZEOF(
                QUERY ( it <* sfc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name IN ['flow rate',
                'minimum flow rate','maximum flow rate'])) )) <= 2))) )) = 
                0;
      wr5 : SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* sfc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'flow rate')) )) <= 1)) )) = 
                0;
      wr6 : SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* sfc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.
                name = 'minimum flow rate')) )) <= 1)) )) = 0;
      wr7 : SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* sfc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.
                name = 'maximum flow rate')) )) <= 1)) )) = 0;
      wr8 : SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT ((1 <= SIZEOF(QUERY ( it <* sfc.used_representation
                .items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name IN ['pressure',
                'minimum pressure','maximum pressure'])) ))) AND (SIZEOF(
                QUERY ( it <* sfc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name IN ['pressure',
                'minimum pressure','maximum pressure'])) )) <= 2))) )) = 0;
      wr9 : SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* sfc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.
                name = 'pressure')) )) <= 1)) )) = 0;
      wr10: SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* sfc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.
                name = 'minimum pressure')) )) <= 1)) )) = 0;
      wr11: SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* sfc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'maximum pressure')) )) 
                <= 1)) )) = 0;
      wr12: SIZEOF(QUERY ( sfc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 'stream flow characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* sfc.used_representation.items
                 | (('PLANT_SPATIAL_CONFIGURATION.' +
                'DESCRIPTIVE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'stream data reference')) )) 
                <= 1)) )) = 0;
      wr13: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( pdr <* 
                USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') )) = 1)) )) = 0);
      wr14: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (NOT (SIZEOF(soc.
                used_representation.items) >= 3)) )) = 0)) )) = 0);
      wr15: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | ((1 <= SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name IN ['temperature','minimum temperature',
                'maximum temperature'])) ))) AND (SIZEOF(QUERY ( it <* soc.
                used_representation.items | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name IN ['temperature','minimum temperature',
                'maximum temperature'])) )) <= 2)) )) = 1)) )) = 0);
      wr16: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'temperature')) )) <= 1) )) = 1)) )) = 0);
      wr17: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'minimum temperature')) )) <= 1) )) = 1)) )) 
                = 0);
      wr18: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'maximum temperature')) )) <= 1) )) = 1)) )) 
                = 0);
      wr19: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | ((1 <= SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name IN ['pressure',
                'minimum pressure','maximum pressure'])) ))) AND (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name IN ['pressure',
                'minimum pressure','maximum pressure'])) )) <= 2)) )) 
                = 1)) )) = 0);
      wr20: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' + 
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'pressure')) )) <= 1) )) 
                = 1)) )) = 0);
      wr21: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'minimum pressure')) )) 
                <= 1) )) = 1)) )) = 0);
      wr22: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'maximum pressure')) )) 
                <= 1) )) = 1)) )) = 0);
      wr23: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | ((1 <= SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.TIME_MEASURE_WITH_UNIT']) = 2) 
                AND (it.name IN ['duration','minimum duration',
                'maximum duration'])) ))) AND (SIZEOF(QUERY ( it <* soc.
                used_representation.items | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.TIME_MEASURE_WITH_UNIT']) 
                = 2) AND (it.name IN ['duration','minimum duration',
                'maximum duration'])) )) <= 2)) )) = 1)) )) = 0);
      wr24: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.TIME_MEASURE_WITH_UNIT']) 
                = 2) AND (it.name = 'duration')) )) <= 1) )) = 1)) )) = 0);
      wr25: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.TIME_MEASURE_WITH_UNIT']) 
                = 2) AND (it.name = 'minimum duration')) )) <= 1) )) 
                = 1)) )) = 0);
      wr26: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (SIZEOF(QUERY ( soc <* 
                QUERY ( pdr <* USEDIN(sc.related_property_definition,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.name = 
                'service operating characteristics') ) | (SIZEOF(
                QUERY ( it <* soc.used_representation.items | ((SIZEOF(
                TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.TIME_MEASURE_WITH_UNIT']) 
                = 2) AND (it.name = 'maximum duration')) )) <= 1) )) 
                = 1)) )) = 0);
      wr27: (NOT (SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') )) >= 1)) OR (SIZEOF(
                QUERY ( sc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' +
                'PROPERTY_DEFINITION_RELATIONSHIP.' +
                'RELATING_PROPERTY_DEFINITION')
                 | (pdr.related_property_definition.name = 
                'service characteristics') ) | (NOT (
                'PLANT_SPATIAL_CONFIGURATION.PLANT_ITEM_CONNECTOR' IN 
                TYPEOF(sc.related_property_definition.definition))) )) 
                = 0);
  END_ENTITY; -- stream_design_case

  ENTITY stream_phase
    SUBTYPE OF (property_definition);
    WHERE
      wr1 : 'PLANT_SPATIAL_CONFIGURATION.STREAM_DESIGN_CASE' IN TYPEOF(
                SELF.definition);
      wr2 : SIZEOF(QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )) = 1;
      wr3 : SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(spc.used_representation.items) >= 5)) )) = 
                0;
      wr4 : SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.RATIO_MEASURE_WITH_UNIT']) 
                = 2) AND (it.name = 'constituent mole fraction')) )) 
                = 1)) )) = 0;
      wr5 : SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | (('PLANT_SPATIAL_CONFIGURATION.' +
                'DESCRIPTIVE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'constituents')) )) = 1)) )) 
                = 0;
      wr6 : SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'phase density')) )) 
                = 1)) )) = 0;
      wr7 : SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.RATIO_MEASURE_WITH_UNIT']) 
                = 2) AND (it.name = 'phase fraction')) )) = 1)) )) = 0;
      wr8 : SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT ((1 <= SIZEOF(QUERY ( it <* spc.used_representation
                .items | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name IN ['temperature','minimum temperature',
                'maximum temperature'])) ))) AND (SIZEOF(QUERY ( it <* spc.
                used_representation.items | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name IN ['temperature','minimum temperature',
                'maximum temperature'])) )) <= 2))) )) = 0;
      wr9 : SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'temperature')) )) <= 1)) )) = 0;
      wr10: SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'minimum temperature')) )) <= 1)) )) = 0;
      wr11: SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((SIZEOF(TYPEOF(it) * [
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM',
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'THERMODYNAMIC_TEMPERATURE_MEASURE_WITH_UNIT']) = 2) AND (
                it.name = 'maximum temperature')) )) <= 1)) )) = 0;
      wr12: SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'specific gravity')) )) 
                <= 1)) )) = 0;
      wr13: SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'surface tension')) )) 
                <= 1)) )) = 0;
      wr14: SIZEOF(QUERY ( spc <* QUERY ( pdr <* USEDIN(SELF,
                'PLANT_SPATIAL_CONFIGURATION.' + 
                'PROPERTY_DEFINITION_REPRESENTATION.DEFINITION') | (pdr.
                used_representation.
                name = 'stream phase characteristics') )
                 | (NOT (SIZEOF(QUERY ( it <* spc.used_representation.items
                 | ((
                'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' 
                IN TYPEOF(it)) AND (it.name = 'viscosity')) )) <= 1)) )) = 
                0;
  END_ENTITY; -- stream_phase

  ENTITY structural_load_connector_classification
    SUBTYPE OF (group);
  END_ENTITY; -- structural_load_connector_classification

  ENTITY structural_system
    SUBTYPE OF (product_definition);
    WHERE
      wr1: SIZEOF(QUERY ( pdr <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'PRODUCT_DEFINITION_RELATIONSHIP.' +
               'RELATED_PRODUCT_DEFINITION')
                | (('PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(pdr.
               relating_product_definition.formation.of_product)) AND (pdr.
               relating_product_definition.frame_of_reference.name = 
               'functional occurrence')) )) = 1;
  END_ENTITY; -- structural_system

  ENTITY support_constraint_representation
    SUBTYPE OF (representation);
    WHERE
      wr1: SIZEOF(SELF.items) >= 3;
      wr2: SIZEOF(QUERY ( it <* SELF.items | ((
               'PLANT_SPATIAL_CONFIGURATION.MEASURE_REPRESENTATION_ITEM' IN
                TYPEOF(it)) AND (it.name IN ['negative x','positive x',
               'negative y','positive y','negative z','positive z',
               'negative x rotation','positive x rotation',
               'negative y rotation','positive y rotation',
               'negative z rotation','positive z rotation'])) )) = 1;
      wr3: SIZEOF(QUERY ( it <* SELF.items | (
               'PLANT_SPATIAL_CONFIGURATION.RATIO_MEASURE_WITH_UNIT' IN 
               TYPEOF(it)) )) = 1;
      wr4: SIZEOF(QUERY ( it <* SELF.items |
               ('PLANT_SPATIAL_CONFIGURATION.' +
               'DESCRIPTIVE_REPRESENTATION_ITEM' 
               IN TYPEOF(it)) )) = 1;
  END_ENTITY; -- support_constraint_representation

  ENTITY surface
    SUPERTYPE OF (ONEOF (elementary_surface,swept_surface,bounded_surface,
        offset_surface,surface_replica))
    SUBTYPE OF (geometric_representation_item);
  END_ENTITY; -- surface

  ENTITY surface_curve
    SUPERTYPE OF (ONEOF (intersection_curve,seam_curve) ANDOR 
        bounded_surface_curve)
    SUBTYPE OF (curve);
      curve_3d              : curve;
      associated_geometry   : LIST [1:2] OF pcurve_or_surface;
      master_representation : preferred_surface_curve_representation;
    DERIVE
      basis_surface : SET [1:2] OF surface := get_basis_surface(SELF);
    WHERE
      wr1: curve_3d.dim = 3;
      wr2: ('PLANT_SPATIAL_CONFIGURATION.PCURVE' IN TYPEOF(
               associated_geometry[1])) OR (master_representation <> 
               pcurve_s1);
      wr3: ('PLANT_SPATIAL_CONFIGURATION.PCURVE' IN TYPEOF(
               associated_geometry[2])) OR (master_representation <> 
               pcurve_s2);
      wr4: NOT ('PLANT_SPATIAL_CONFIGURATION.PCURVE' IN TYPEOF(curve_3d));
  END_ENTITY; -- surface_curve

  ENTITY surface_of_linear_extrusion
    SUBTYPE OF (swept_surface);
      extrusion_axis : vector;
  END_ENTITY; -- surface_of_linear_extrusion

  ENTITY surface_of_revolution
    SUBTYPE OF (swept_surface);
      axis_position : axis1_placement;
    DERIVE
      axis_line : line := line(axis_position.location,vector(axis_position
                     .z,1));
  END_ENTITY; -- surface_of_revolution

  ENTITY surface_patch;
      parent_surface : bounded_surface;
      u_transition   : transition_code;
      v_transition   : transition_code;
      u_sense        : BOOLEAN;
      v_sense        : BOOLEAN;
    INVERSE
      using_surfaces : BAG [1:?] OF rectangular_composite_surface FOR 
                          segments;
    WHERE
      wr1: NOT ('PLANT_SPATIAL_CONFIGURATION.CURVE_BOUNDED_SURFACE' IN 
               TYPEOF(parent_surface));
  END_ENTITY; -- surface_patch

  ENTITY surface_replica
    SUBTYPE OF (surface);
      parent_surface : surface;
      transformation : cartesian_transformation_operator_3d;
    WHERE
      wr1: acyclic_surface_replica(SELF,parent_surface);
  END_ENTITY; -- surface_replica

  ENTITY swage_fitting_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.GROUP_ASSIGNMENT.' +
               'ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.GROUP_ASSIGNMENT.' +
               'ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'swage') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- swage_fitting_classification

  ENTITY swept_area_solid
    SUPERTYPE OF (ONEOF (revolved_area_solid,extruded_area_solid))
    SUBTYPE OF (solid_model);
      swept_area : curve_bounded_surface;
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PLANE' IN TYPEOF(swept_area.
               basis_surface);
  END_ENTITY; -- swept_area_solid

  ENTITY swept_face_solid
    SUPERTYPE OF (ONEOF (extruded_face_solid,revolved_face_solid))
    SUBTYPE OF (solid_model);
      swept_face : face_surface;
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.PLANE' IN TYPEOF(swept_face.
               face_geometry);
  END_ENTITY; -- swept_face_solid

  ENTITY swept_surface
    SUPERTYPE OF (ONEOF (surface_of_linear_extrusion,
      surface_of_revolution))
    SUBTYPE OF (surface);
      swept_curve : curve;
  END_ENTITY; -- swept_surface

  ENTITY system_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.' +
               'GROUP_ASSIGNMENT.ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT'
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (SIZEOF(TYPEOF(it) * [
               'PLANT_SPATIAL_CONFIGURATION.DUCTING_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.ELECTRICAL_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.' +
               'INSTRUMENTATION_AND_CONTROL_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.PIPING_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.STRUCTURAL_SYSTEM']) = 1)) )) =
                0)) )) = 0;
  END_ENTITY; -- system_classification

  ENTITY system_space
    SUBTYPE OF (product_definition_shape);
    WHERE
      wr1: SIZEOF(TYPEOF(SELF.definition) * [
               'PLANT_SPATIAL_CONFIGURATION.ELECTRICAL_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.DUCTING_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.' + 
               'INSTRUMENTATION_AND_CONTROL_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.PIPING_SYSTEM',
               'PLANT_SPATIAL_CONFIGURATION.STRUCTURAL_SYSTEM']) = 1;
  END_ENTITY; -- system_space

  ENTITY thermodynamic_temperature_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.THERMODYNAMIC_TEMPERATURE_UNIT' IN
                TYPEOF(SELF\measure_with_unit.unit_component);
  END_ENTITY; -- thermodynamic_temperature_measure_with_unit

  ENTITY thermodynamic_temperature_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 0) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 1) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- thermodynamic_temperature_unit

  ENTITY time_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.TIME_UNIT' IN TYPEOF(SELF\
               measure_with_unit.unit_component);
  END_ENTITY; -- time_measure_with_unit

  ENTITY time_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 0) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 1) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- time_unit

  ENTITY topological_representation_item
    SUPERTYPE OF (ONEOF (vertex,edge,face_bound,face,connected_face_set,
        loop ANDOR path))
    SUBTYPE OF (representation_item);
  END_ENTITY; -- topological_representation_item

  ENTITY toroidal_surface
    SUBTYPE OF (elementary_surface);
      major_radius : positive_length_measure;
      minor_radius : positive_length_measure;
  END_ENTITY; -- toroidal_surface

  ENTITY torus
    SUBTYPE OF (geometric_representation_item);
      position     : axis1_placement;
      major_radius : positive_length_measure;
      minor_radius : positive_length_measure;
    WHERE
      wr1: major_radius > minor_radius;
  END_ENTITY; -- torus

  ENTITY trimmed_curve
    SUBTYPE OF (bounded_curve);
      basis_curve           : curve;
      trim_1                : SET [1:2] OF trimming_select;
      trim_2                : SET [1:2] OF trimming_select;
      sense_agreement       : BOOLEAN;
      master_representation : trimming_preference;
    WHERE
      wr1: (HIINDEX(trim_1) = 1) XOR (TYPEOF(trim_1[1]) <> TYPEOF(trim_1[2]));
      wr2: (HIINDEX(trim_2) = 1) XOR (TYPEOF(trim_2[1]) <> TYPEOF(trim_2[2]));
  END_ENTITY; -- trimmed_curve

  ENTITY truncated_pyramid
    SUBTYPE OF (boolean_result);
  END_ENTITY; -- truncated_pyramid

  ENTITY type_qualifier;
      name : label;
  END_ENTITY; -- type_qualifier

  ENTITY uniform_curve
    SUBTYPE OF (b_spline_curve);
  END_ENTITY; -- uniform_curve

  ENTITY uniform_surface
    SUBTYPE OF (b_spline_surface);
  END_ENTITY; -- uniform_surface

  ENTITY valve_classification
    SUBTYPE OF (group);
    WHERE
      wr1: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.GROUP_ASSIGNMENT.' +
               'ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( it <* ca.items | (
               NOT (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it))) )) = 0)) )) = 0;
      wr2: SIZEOF(QUERY ( ca <* QUERY ( ga <* USEDIN(SELF,
               'PLANT_SPATIAL_CONFIGURATION.GROUP_ASSIGNMENT.' +
               'ASSIGNED_GROUP')
                | ('PLANT_SPATIAL_CONFIGURATION.CLASSIFICATION_ASSIGNMENT' 
               IN TYPEOF(ga)) ) | (NOT (SIZEOF(QUERY ( pcd <* 
               QUERY ( it <* ca.items | (
               'PLANT_SPATIAL_CONFIGURATION.PIPING_COMPONENT_DEFINITION' IN
                TYPEOF(it)) ) | (NOT (SIZEOF(QUERY ( prpc <* USEDIN(pcd.
               formation.of_product,'PLANT_SPATIAL_CONFIGURATION.' + 
               'PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | 
               category_in_tree(prpc,'valve') )) = 1)) )) = 0)) )) = 0;
  END_ENTITY; -- valve_classification

  ENTITY vector
    SUBTYPE OF (geometric_representation_item);
      orientation : direction;
      magnitude   : length_measure;
    WHERE
      wr1: magnitude >= 0;
  END_ENTITY; -- vector

  ENTITY versioned_action_request;
      id          : identifier;
      version     : label;
      purpose     : text;
      description : text;
  END_ENTITY; -- versioned_action_request

  ENTITY vertex
    SUBTYPE OF (topological_representation_item);
  END_ENTITY; -- vertex

  ENTITY volume_measure_with_unit
    SUBTYPE OF (measure_with_unit);
    WHERE
      wr1: 'PLANT_SPATIAL_CONFIGURATION.VOLUME_UNIT' IN TYPEOF(SELF\
               measure_with_unit.unit_component);
  END_ENTITY; -- volume_measure_with_unit

  ENTITY volume_unit
    SUBTYPE OF (named_unit);
    WHERE
      wr1: (SELF\named_unit.dimensions.length_exponent = 3) AND (SELF\
               named_unit.dimensions.mass_exponent = 0) AND (SELF\
               named_unit.dimensions.time_exponent = 0) AND (SELF\
               named_unit.dimensions.electric_current_exponent = 0) AND (
               SELF\named_unit.dimensions.
               thermodynamic_temperature_exponent = 0) AND (SELF\named_unit
               .dimensions.amount_of_substance_exponent = 0) AND (SELF\
               named_unit.dimensions.luminous_intensity_exponent = 0);
  END_ENTITY; -- volume_unit

  RULE application_context_requires_ap_definition FOR (application_context, 
               application_protocol_definition);

  WHERE
    wr1: SIZEOF(QUERY ( ac <* application_context | (NOT (SIZEOF(
             QUERY ( apd <* application_protocol_definition | ((ac :=: apd.
             application) AND (apd.
             application_interpreted_model_schema_name = 
             'plant_spatial_configuration')) )) = 1)) )) = 0;

  END_RULE; -- application_context_requires_ap_definition

  RULE approval_requires_approval_date_time FOR (approval_date_time, 
             approval);

  WHERE
    wr1: SIZEOF(QUERY ( app <* approval | (NOT (SIZEOF(QUERY ( adt <* 
             approval_date_time | (app :=: adt.dated_approval) )) = 1)) )) 
             = 0;

  END_RULE; -- approval_requires_approval_date_time

  RULE approval_requires_approval_person_organization FOR (
             approval_person_organization, approval);

  WHERE
    wr1: SIZEOF(QUERY ( app <* approval | (NOT (SIZEOF(QUERY ( apo <* 
             approval_person_organization | (app :=: apo.
             authorized_approval) )) = 1)) )) = 0;

  END_RULE; -- approval_requires_approval_person_organization

  RULE change_action_requires_date FOR (change_action, 
             plant_spatial_configuration_date_assignment);

  WHERE
    wr1: SIZEOF(QUERY ( ca <* change_action | (NOT (SIZEOF(
             QUERY ( pscda <* plant_spatial_configuration_date_assignment
              | (ca IN pscda.items) )) = 1)) )) = 0;

  END_RULE; -- change_action_requires_date

  RULE change_item_requires_creation_date FOR (
             plant_spatial_configuration_change_assignment, 
             plant_spatial_configuration_date_assignment);

  WHERE
    wr1: SIZEOF(QUERY ( pscca <* 
             plant_spatial_configuration_change_assignment | (NOT (SIZEOF(
             QUERY ( ch_it <* pscca.items | (NOT (SIZEOF(QUERY ( pscda <* 
             plant_spatial_configuration_date_assignment | ((NOT (ch_it IN 
             pscda.items)) OR (pscda.role.name = 'creation date')) )) 
             = 1)) )) = 0)) )) = 0;

  END_RULE; -- change_item_requires_creation_date

  RULE change_item_requires_id FOR (
             plant_spatial_configuration_change_assignment, 
             change_item_id_assignment);

  WHERE
    wr1: SIZEOF(QUERY ( pscca <* 
             plant_spatial_configuration_change_assignment | (NOT (SIZEOF(
             QUERY ( ch_it <* pscca.items | (NOT (SIZEOF(QUERY ( ciia <* 
             change_item_id_assignment | (ch_it IN ciia.items) )) = 1)) )) 
             = 0)) )) = 0;

  END_RULE; -- change_item_requires_id

  RULE change_life_cycle_stage_usage_requires_approval FOR (
             versioned_action_request, 
             plant_spatial_configuration_approval_assignment);

  WHERE
    wr1: SIZEOF(QUERY ( vareq <* versioned_action_request | (NOT (SIZEOF(
             QUERY ( pscaa <* 
             plant_spatial_configuration_approval_assignment | (vareq IN 
             pscaa.items) )) = 1)) )) = 0;

  END_RULE; -- change_life_cycle_stage_usage_requires_approval

  RULE change_life_cycle_stage_usage_requires_stage FOR (
             versioned_action_request, action_request_status);

  WHERE
    wr1: SIZEOF(QUERY ( vareq <* versioned_action_request | (NOT (SIZEOF(
             QUERY ( ars <* action_request_status | (vareq :=: ars.
             assigned_request) )) = 1)) )) = 0;

  END_RULE; -- change_life_cycle_stage_usage_requires_stage

  RULE compatible_dimension FOR (cartesian_point, direction, 
             representation_context, geometric_representation_context);

  WHERE
    wr1: SIZEOF(QUERY ( x <* cartesian_point | (SIZEOF(QUERY ( y <* 
             geometric_representation_context | (item_in_context(x,y) AND (
             HIINDEX(x.coordinates) <> y.coordinate_space_dimension)) )) > 
             0) )) = 0;
    wr2: SIZEOF(QUERY ( x <* direction | (SIZEOF(QUERY ( y <* 
             geometric_representation_context | (item_in_context(x,y) AND (
             HIINDEX(x.direction_ratios) <> y.
             coordinate_space_dimension)) )) > 0) )) = 0;

  END_RULE; -- compatible_dimension

  RULE dependent_instantiable_application_context FOR (
             application_context);

  WHERE
    wr1: SIZEOF(QUERY ( ac <* application_context | (NOT (SIZEOF(USEDIN(ac,
             '')) >= 1)) )) = 0;

  END_RULE; -- dependent_instantiable_application_context

  RULE dependent_instantiable_product_context FOR (product_context);

  WHERE
    wr1: SIZEOF(QUERY ( pc <* product_context | (NOT (SIZEOF(USEDIN(pc,'')) 
             >= 1)) )) = 0;

  END_RULE; -- dependent_instantiable_product_context

  RULE dependent_instantiable_product_definition_context FOR (
             product_definition_context);

  WHERE
    wr1: SIZEOF(QUERY ( pdc <* product_definition_context | (NOT (SIZEOF(
             USEDIN(pdc,'')) >= 1)) )) = 0;

  END_RULE; -- dependent_instantiable_product_definition_context

  RULE product_context_discipline_type_constraint FOR (product_context);

  WHERE
    wr1: SIZEOF(QUERY ( pc <* product_context | (NOT (pc.discipline_type = 
             'process plant')) )) = 0;

  END_RULE; -- product_context_discipline_type_constraint

  RULE product_definition_context_name_constraint FOR (
             product_definition_context);

  WHERE
    wr1: SIZEOF(QUERY ( pdc <* product_definition_context | (NOT (pdc.name 
             IN ['functional definition','physical definition',
             'functional occurrence','physical occurrence',
             'catalogue definition','fabrication assembly'])) )) = 0;

  END_RULE; -- product_definition_context_name_constraint

  RULE product_definition_usage_constraint FOR (product_definition);

  WHERE
    wr1: SIZEOF(QUERY ( pd <* product_definition | ((pd.frame_of_reference
             .name = 'physical occurrence') AND (NOT (SIZEOF(
             QUERY ( pdr <* USEDIN(pd,
             'PLANT_SPATIAL_CONFIGURATION.' +
             'PRODUCT_DEFINITION_RELATIONSHIP.' +
             'RELATED_PRODUCT_DEFINITION') | (SIZEOF(TYPEOF(pdr) * [
             'PLANT_SPATIAL_CONFIGURATION.PRODUCT_DEFINITION_USAGE',
             'PLANT_SPATIAL_CONFIGURATION.MAKE_FROM_USAGE_OPTION',
             'PLANT_SPATIAL_CONFIGURATION.ASSEMBLY_COMPONENT_USAGE']) 
             = 1) )) <= 1))) )) = 0;
    wr2: SIZEOF(QUERY ( pd <* product_definition | ((pd.frame_of_reference
             .name = 'physical definition') AND (NOT (SIZEOF(
             QUERY ( pdr <* USEDIN(pd,
             'PLANT_SPATIAL_CONFIGURATION.' +
             'PRODUCT_DEFINITION_RELATIONSHIP.' 
             + 'RELATING_PRODUCT_DEFINITION') | (pdr.
             related_product_definition.frame_of_reference.name = 
             'physical occurrence') )) <= 1))) )) = 0;

  END_RULE; -- product_definition_usage_constraint

  RULE subtype_exclusive_characterized_object FOR (characterized_object);

  WHERE
    wr1: SIZEOF (QUERY (co <*characterized_object |
             NOT (SIZEOF (['PLANT_SPATIAL_CONFIGURATION.' +
             'PIPING_COMPONENT_CLASS',
             'PLANT_SPATIAL_CONFIGURATION.SITE',
             'PLANT_SPATIAL_CONFIGURATION.STREAM_DESIGN_CASE']
             * TYPEOF (co)) <= 1))) = 0;

  END_RULE; -- subtype_exclusive_characterized_object

  RULE subtype_exclusive_shape_representation FOR (shape_representation);

  WHERE
    wr1: SIZEOF (QUERY (sr <*shape_representation|
             NOT (SIZEOF (['PLANT_SPATIAL_CONFIGURATION.' +
             'ADVANCED_CSG_SHAPE_REPRESENTATION',
             'PLANT_SPATIAL_CONFIGURATION.HYBRID_SHAPE_REPRESENTATION',
             'PLANT_SPATIAL_CONFIGURATION.' +
             'PIPING_DESIGN_CSG_SHAPE_REPRESENTATION']
             * TYPEOF (sr)) <= 1))) = 0;

  END_RULE; -- subtype_exclusive_shape_representation

  RULE subtype_mandatory_externally_defined_item FOR (
             externally_defined_item);

  WHERE
    wr1: SIZEOF(QUERY ( edi <* externally_defined_item | (NOT (SIZEOF([
             'PLANT_SPATIAL_CONFIGURATION.CATALOGUE_CONNECTOR',
             'PLANT_SPATIAL_CONFIGURATION.' +
             'EXTERNALLY_DEFINED_CLASSIFICATION',
             'PLANT_SPATIAL_CONFIGURATION.' +
             'EXTERNALLY_DEFINED_PLANT_ITEM_DEFINITION'] 
             * TYPEOF(edi)) = 1)) )) = 0;

  END_RULE; -- subtype_mandatory_externally_defined_item

  RULE subtype_mandatory_pre_defined_item FOR (pre_defined_item);

  WHERE
    wr1: SIZEOF(QUERY ( pdi <* pre_defined_item | (NOT (
             'PLANT_SPATIAL_CONFIGURATION.KNOWN_SOURCE' 
             IN TYPEOF(pdi))) )) = 0;

  END_RULE; -- subtype_mandatory_pre_defined_item

  RULE versioned_action_request_requires_change_action FOR (change_action, 
             versioned_action_request);

  WHERE
    wr1: SIZEOF(QUERY ( vareq <* versioned_action_request | (NOT (SIZEOF(
             QUERY ( ca <* change_action | (vareq IN ca.directive.
             requests) )) = 1)) )) = 0;

  END_RULE; -- versioned_action_request_requires_change_action

  FUNCTION acyclic_curve_replica(
               rep: curve_replica;
               parent: curve
      ): BOOLEAN;
    IF NOT ('PLANT_SPATIAL_CONFIGURATION.CURVE_REPLICA' IN TYPEOF(parent))
         THEN
      RETURN(TRUE);
    END_IF;
    IF parent :=: rep THEN
      RETURN(FALSE);
    ELSE
      RETURN(acyclic_curve_replica(rep,parent\curve_replica.parent_curve));
    END_IF;

  END_FUNCTION; -- acyclic_curve_replica

  FUNCTION acyclic_mapped_representation(
               parent_set: SET OF representation;
               children_set: SET OF representation_item
      ): BOOLEAN;

    LOCAL
      i : INTEGER;
      x : SET OF representation_item;
      y : SET OF representation_item;
    END_LOCAL;
    x := QUERY ( z <* children_set | (
        'PLANT_SPATIAL_CONFIGURATION.MAPPED_ITEM' IN TYPEOF(z)) );
    IF SIZEOF(x) > 0 THEN
      REPEAT i := 1 TO HIINDEX(x) BY 1;
        IF x[i]\mapped_item.mapping_source.mapped_representation IN 
            parent_set THEN
          RETURN(FALSE);
        END_IF;
        IF NOT acyclic_mapped_representation(parent_set + x[i]\mapped_item
            .mapping_source.mapped_representation,x[i]\mapped_item.
            mapping_source.mapped_representation.items) THEN
          RETURN(FALSE);
        END_IF;
      END_REPEAT;
    END_IF;
    x := children_set - x;
    IF SIZEOF(x) > 0 THEN
      REPEAT i := 1 TO HIINDEX(x) BY 1;
        y := QUERY ( z <* bag_to_set(USEDIN(x[i],'')) | (
            'PLANT_SPATIAL_CONFIGURATION.REPRESENTATION_ITEM' 
            IN TYPEOF(z)) );
        IF NOT acyclic_mapped_representation(parent_set,y) THEN
          RETURN(FALSE);
        END_IF;
      END_REPEAT;
    END_IF;
    RETURN(TRUE);

  END_FUNCTION; -- acyclic_mapped_representation

  FUNCTION acyclic_point_replica(
               rep: point_replica;
               parent: point
      ): BOOLEAN;
    IF NOT ('PLANT_SPATIAL_CONFIGURATION.POINT_REPLICA' IN TYPEOF(parent))
         THEN
      RETURN(TRUE);
    END_IF;
    IF parent :=: rep THEN
      RETURN(FALSE);
    ELSE
      RETURN(acyclic_point_replica(rep,parent\point_replica.parent_pt));
    END_IF;

  END_FUNCTION; -- acyclic_point_replica

  FUNCTION acyclic_product_category_relationship(
               relation: product_category_relationship;
               children: SET OF product_category
      ): LOGICAL;

    LOCAL
      i              : INTEGER;
      x              : SET OF product_category_relationship;
      local_children : SET OF product_category;
    END_LOCAL;
    REPEAT i := 1 TO HIINDEX(children) BY 1;
      IF relation.category :=: children[i] THEN
        RETURN(FALSE);
      END_IF;
    END_REPEAT;
    x := bag_to_set(USEDIN(relation.category,
        'PLANT_SPATIAL_CONFIGURATION.' + 
        'PRODUCT_CATEGORY_RELATIONSHIP.SUB_CATEGORY'));
    local_children := children + relation.category;
    IF SIZEOF(x) > 0 THEN
      REPEAT i := 1 TO HIINDEX(x) BY 1;
        IF NOT acyclic_product_category_relationship(x[i],local_children)
             THEN
          RETURN(FALSE);
        END_IF;
      END_REPEAT;
    END_IF;
    RETURN(TRUE);

  END_FUNCTION; -- acyclic_product_category_relationship

  FUNCTION acyclic_product_definition_relationship(
               relation: product_definition_relationship;
               relatives: SET OF product_definition;
               specific_relation: STRING
      ): LOGICAL;

    LOCAL
      i               : INTEGER;
      x               : SET OF product_definition_relationship;
      local_relatives : SET OF product_definition;
    END_LOCAL;
    REPEAT i := 1 TO HIINDEX(relatives) BY 1;
      IF relation.relating_product_definition :=: relatives[i] THEN
        RETURN(FALSE);
      END_IF;
    END_REPEAT;
    x := bag_to_set(USEDIN(relation.relating_product_definition,
        specific_relation));
    local_relatives := relatives + relation.relating_product_definition;
    IF SIZEOF(x) > 0 THEN
      REPEAT i := 1 TO HIINDEX(x) BY 1;
        IF NOT acyclic_product_definition_relationship(x[i],
            local_relatives,specific_relation) THEN
          RETURN(FALSE);
        END_IF;
      END_REPEAT;
    END_IF;
    RETURN(TRUE);

  END_FUNCTION; -- acyclic_product_definition_relationship

  FUNCTION acyclic_set_replica(
               rep: geometric_set_replica;
               parent: geometric_set
      ): BOOLEAN;
    IF NOT ('PLANT_SPATIAL_CONFIGURATION.GEOMETRIC_SET_REPLICA' IN TYPEOF(
        parent)) THEN
      RETURN(TRUE);
    END_IF;
    IF parent :=: rep THEN
      RETURN(FALSE);
    ELSE
      RETURN(acyclic_set_replica(rep,parent\geometric_set_replica.
          parent_set));
    END_IF;

  END_FUNCTION; -- acyclic_set_replica

  FUNCTION acyclic_surface_replica(
               rep: surface_replica;
               parent: surface
      ): BOOLEAN;
    IF NOT ('PLANT_SPATIAL_CONFIGURATION.SURFACE_REPLICA' 
         IN TYPEOF(parent))
         THEN
      RETURN(TRUE);
    END_IF;
    IF parent :=: rep THEN
      RETURN(FALSE);
    ELSE
      RETURN(acyclic_surface_replica(rep,parent\surface_replica.
          parent_surface));
    END_IF;

  END_FUNCTION; -- acyclic_surface_replica

  FUNCTION associated_surface(
               arg: pcurve_or_surface
      ): surface;

    LOCAL
      surf : surface;
    END_LOCAL;
    IF 'PLANT_SPATIAL_CONFIGURATION.PCURVE' IN TYPEOF(arg) THEN
      surf := arg\pcurve.basis_surface;
    ELSE
      surf := arg;
    END_IF;
    RETURN(surf);

  END_FUNCTION; -- associated_surface

  FUNCTION bag_to_set(
               the_bag: BAG OF GENERIC:intype
      ): SET OF GENERIC:intype;

    LOCAL
      i       : INTEGER;
      the_set : SET OF GENERIC:intype := [];
    END_LOCAL;
    IF SIZEOF(the_bag) > 0 THEN
      REPEAT i := 1 TO HIINDEX(the_bag) BY 1;
        the_set := the_set + the_bag[i];
      END_REPEAT;
    END_IF;
    RETURN(the_set);

  END_FUNCTION; -- bag_to_set

  FUNCTION base_axis(
               dim: INTEGER;
               axis1, axis2, axis3: direction
      ): LIST [2:3] OF direction;

    LOCAL
      u      : LIST [2:3] OF direction;
      vec    : direction;
      factor : REAL;
    END_LOCAL;
    IF dim = 3 THEN
      u[3] := NVL(normalise(axis3),direction([0,0,1]));
      u[1] := first_proj_axis(u[3],axis1);
      u[2] := second_proj_axis(u[3],u[1],axis2);
    ELSE
      u[3] := ?;
      IF EXISTS(axis1) THEN
        u[1] := normalise(axis1);
        u[2] := orthogonal_complement(u[1]);
        IF EXISTS(axis2) THEN
          factor := dot_product(axis2,u[2]);
          IF factor < 0 THEN
            u[2].direction_ratios[1] := -u[2].direction_ratios[1];
            u[2].direction_ratios[2] := -u[2].direction_ratios[2];
          END_IF;
        END_IF;
      ELSE
        IF EXISTS(axis2) THEN
          u[2] := normalise(axis2);
          u[1] := orthogonal_complement(u[2]);
          u[1].direction_ratios[1] := -u[1].direction_ratios[1];
          u[1].direction_ratios[2] := -u[1].direction_ratios[2];
        ELSE
          u[1].direction_ratios[1] := 1;
          u[1].direction_ratios[2] := 0;
          u[2].direction_ratios[1] := 0;
          u[2].direction_ratios[2] := 1;
        END_IF;
      END_IF;
    END_IF;
    RETURN(u);

  END_FUNCTION; -- base_axis

  FUNCTION boolean_choose(
               b: BOOLEAN;
               choice1, choice2: GENERIC:item
      ): GENERIC:item;
    IF b THEN
      RETURN(choice1);
    ELSE
      RETURN(choice2);
    END_IF;

  END_FUNCTION; -- boolean_choose

  FUNCTION build_2axes(
               ref_direction: direction
      ): LIST [2:2] OF direction;

    LOCAL
      u : LIST [2:2] OF direction;
    END_LOCAL;
    u[1] := NVL(normalise(ref_direction),direction([1,0]));
    u[2] := orthogonal_complement(u[1]);
    RETURN(u);

  END_FUNCTION; -- build_2axes

  FUNCTION build_axes(
               axis, ref_direction: direction
      ): LIST [3:3] OF direction;

    LOCAL
      u : LIST [3:3] OF direction;
    END_LOCAL;
    u[3] := NVL(normalise(axis),direction([0,0,1]));
    u[1] := first_proj_axis(u[3],ref_direction);
    u[2] := normalise(cross_product(u[3],u[1]))\vector.orientation;
    RETURN(u);

  END_FUNCTION; -- build_axes

  FUNCTION build_transformed_set(
               tr: cartesian_transformation_operator;
               gset: geometric_set
      ): SET [0:?] OF geometric_set_select;

    LOCAL
      trcurve : curve;
      s       : SET [1:?] OF geometric_set_select := gset.elements;
      trpoint : point;
      trset   : SET [0:?] OF geometric_set_select := [];
      trsurf  : surface;
    END_LOCAL;
    REPEAT j := 1 TO SIZEOF(s) BY 1;
      IF 'PLANT_SPATIAL_CONFIGURATION.CURVE' IN TYPEOF(s[j]) THEN
        trset := trset + curve_replica(s[j],tr);
      ELSE
        IF 'PLANT_SPATIAL_CONFIGURATION.POINT' IN TYPEOF(s[j]) THEN
          trset := trset + point_replica(s[j],tr);
        ELSE
          IF 'PLANT_SPATIAL_CONFIGURATION.SURFACE' IN TYPEOF(s[j]) THEN
            trset := trset + surface_replica(s[j],tr || 
                cartesian_transformation_operator_3d(?));
          END_IF;
        END_IF;
      END_IF;
    END_REPEAT;
    RETURN(trset);

  END_FUNCTION; -- build_transformed_set

  FUNCTION category_in_tree(
               cat: product_category;
               val: STRING
      ): BOOLEAN;
    IF cat.name = val THEN
      RETURN(TRUE);
    ELSE
      RETURN(SIZEOF(QUERY ( pc <* USEDIN(cat,
          'PLANT_SPATIAL_CONFIGURATION.' + 
          'PRODUCT_CATEGORY_RELATIONSHIP.SUB_CATEGORY') | category_in_tree(
          pc,val) )) = 1);
    END_IF;
    RETURN(FALSE);

  END_FUNCTION; -- category_in_tree

  FUNCTION conditional_reverse(
               p: BOOLEAN;
               an_item: reversible_topology
      ): reversible_topology;
    IF p THEN
      RETURN(an_item);
    ELSE
      RETURN(topology_reversed(an_item));
    END_IF;

  END_FUNCTION; -- conditional_reverse

  FUNCTION constraints_composite_curve_on_surface(
               c: composite_curve_on_surface
      ): BOOLEAN;

    LOCAL
      n_segments : INTEGER := SIZEOF(c.segments);
    END_LOCAL;
    REPEAT k := 1 TO n_segments BY 1;
      IF (NOT ('PLANT_SPATIAL_CONFIGURATION.PCURVE' IN TYPEOF(c\
          composite_curve.segments[k].parent_curve))) AND (NOT (
          'PLANT_SPATIAL_CONFIGURATION.SURFACE_CURVE' IN TYPEOF(c\
          composite_curve.segments[k].parent_curve))) AND (NOT (
          'PLANT_SPATIAL_CONFIGURATION.COMPOSITE_CURVE_ON_SURFACE' IN 
          TYPEOF(c\composite_curve.segments[k].parent_curve))) THEN
        RETURN(FALSE);
      END_IF;
    END_REPEAT;
    RETURN(TRUE);

  END_FUNCTION; -- constraints_composite_curve_on_surface

  FUNCTION constraints_geometry_shell_based_wireframe_model(
               m: shell_based_wireframe_model
      ): BOOLEAN;

    LOCAL
      result : BOOLEAN := TRUE;
    END_LOCAL;
    REPEAT j := 1 TO SIZEOF(m.sbwm_boundary) BY 1;
      IF (NOT ('PLANT_SPATIAL_CONFIGURATION.WIRE_SHELL' IN TYPEOF(m.
          sbwm_boundary[j]))) AND (NOT (
          'PLANT_SPATIAL_CONFIGURATION.VERTEX_SHELL' IN TYPEOF(m.
          sbwm_boundary[j]))) THEN
        result := FALSE;
        RETURN(result);
      END_IF;
    END_REPEAT;
    RETURN(result);

  END_FUNCTION; -- constraints_geometry_shell_based_wireframe_model

  FUNCTION constraints_param_b_spline(
               degree, up_knots, up_cp: INTEGER;
               knot_mult: LIST OF INTEGER;
               knots: LIST OF parameter_value
      ): BOOLEAN;

    LOCAL
      k      : INTEGER;
      l      : INTEGER;
      sum    : INTEGER;
      result : BOOLEAN := TRUE;
    END_LOCAL;
    sum := knot_mult[1];
    REPEAT i := 2 TO up_knots BY 1;
      sum := sum + knot_mult[i];
    END_REPEAT;
    IF (degree < 1) OR (up_knots < 2) OR (up_cp < degree) OR (sum <> (
        degree + up_cp + 2)) THEN
      result := FALSE;
      RETURN(result);
    END_IF;
    k := knot_mult[1];
    IF (k < 1) OR (k > (degree + 1)) THEN
      result := FALSE;
      RETURN(result);
    END_IF;
    REPEAT i := 2 TO up_knots BY 1;
      IF (knot_mult[i] < 1) OR (knots[i] <= knots[i - 1]) THEN
        result := FALSE;
        RETURN(result);
      END_IF;
      k := knot_mult[i];
      IF (i < up_knots) AND (k > degree) THEN
        result := FALSE;
        RETURN(result);
      END_IF;
      IF (i = up_knots) AND (k > (degree + 1)) THEN
        result := FALSE;
        RETURN(result);
      END_IF;
    END_REPEAT;
    RETURN(result);

  END_FUNCTION; -- constraints_param_b_spline

  FUNCTION constraints_rectangular_composite_surface(
               s: rectangular_composite_surface
      ): BOOLEAN;
    REPEAT i := 1 TO s.n_u BY 1;
      REPEAT j := 1 TO s.n_v BY 1;
        IF NOT (('PLANT_SPATIAL_CONFIGURATION.B_SPLINE_SURFACE' IN TYPEOF(
            s.segments[i][j].parent_surface)) OR (
            'PLANT_SPATIAL_CONFIGURATION.RECTANGULAR_TRIMMED_SURFACE' IN 
            TYPEOF(s.segments[i][j].parent_surface))) THEN
          RETURN(FALSE);
        END_IF;
      END_REPEAT;
    END_REPEAT;
    REPEAT i := 1 TO s.n_u - 1 BY 1;
      REPEAT j := 1 TO s.n_v BY 1;
        IF s.segments[i][j].u_transition = discontinuous THEN
          RETURN(FALSE);
        END_IF;
      END_REPEAT;
    END_REPEAT;
    REPEAT i := 1 TO s.n_u BY 1;
      REPEAT j := 1 TO s.n_v - 1 BY 1;
        IF s.segments[i][j].v_transition = discontinuous THEN
          RETURN(FALSE);
        END_IF;
      END_REPEAT;
    END_REPEAT;
    RETURN(TRUE);

  END_FUNCTION; -- constraints_rectangular_composite_surface

  FUNCTION cross_product(
               arg1, arg2: direction
      ): vector;

    LOCAL
      v2     : LIST [3:3] OF REAL;
      v1     : LIST [3:3] OF REAL;
      mag    : REAL;
      res    : direction;
      result : vector;
    END_LOCAL;
    IF (NOT EXISTS(arg1)) OR (arg1.dim = 2) OR (NOT EXISTS(arg2)) OR (arg2
        .dim = 2) THEN
      RETURN(?);
    ELSE
      BEGIN
        v1 := normalise(arg1)\direction.direction_ratios;
        v2 := normalise(arg2)\direction.direction_ratios;
        res.direction_ratios[1] := (v1[2] * v2[3]) - (v1[3] * v2[2]);
        res.direction_ratios[2] := (v1[3] * v2[1]) - (v1[1] * v2[3]);
        res.direction_ratios[3] := (v1[1] * v2[2]) - (v1[2] * v2[1]);
        mag := 0;
        REPEAT i := 1 TO 3 BY 1;
          mag := mag + (res.direction_ratios[i] * res.direction_ratios[i]);
        END_REPEAT;
        IF mag > 0 THEN
          result.orientation := res;
          result.magnitude := SQRT(mag);
        ELSE
          result.orientation := arg1;
          result.magnitude := 0;
        END_IF;
        RETURN(result);
      END;
    END_IF;

  END_FUNCTION; -- cross_product

  FUNCTION curve_weights_positive(
               b: rational_b_spline_curve
      ): BOOLEAN;

    LOCAL
      result : BOOLEAN := TRUE;
    END_LOCAL;
    REPEAT i := 0 TO b.upper_index_on_control_points BY 1;
      IF b.weights[i] <= 0 THEN
        result := FALSE;
        RETURN(result);
      END_IF;
    END_REPEAT;
    RETURN(result);

  END_FUNCTION; -- curve_weights_positive

  FUNCTION derive_dimensional_exponents(
               x: unit
      ): dimensional_exponents;

    LOCAL
      i      : INTEGER;
      result : dimensional_exponents := dimensional_exponents(0,0,0,0,0,0,
                0);
    END_LOCAL;
    IF 'PLANT_SPATIAL_CONFIGURATION.DERIVED_UNIT' IN TYPEOF(x) THEN
      REPEAT i := LOINDEX(x.elements) TO HIINDEX(x.elements) BY 1;
        result.length_exponent := result.length_exponent + (x.elements[i].
            exponent * x.elements[i].unit.dimensions.length_exponent);
        result.mass_exponent := result.mass_exponent + (x.elements[i].
            exponent * x.elements[i].unit.dimensions.mass_exponent);
        result.time_exponent := result.time_exponent + (x.elements[i].
            exponent * x.elements[i].unit.dimensions.time_exponent);
        result.electric_current_exponent := result.
            electric_current_exponent + (x.elements[i].exponent * x.
            elements[i].unit.dimensions.electric_current_exponent);
        result.thermodynamic_temperature_exponent := result.
            thermodynamic_temperature_exponent + (x.elements[i].exponent * 
            x.elements[i].unit.dimensions.
            thermodynamic_temperature_exponent);
        result.amount_of_substance_exponent := result.
            amount_of_substance_exponent + (x.elements[i].exponent * x.
            elements[i].unit.dimensions.amount_of_substance_exponent);
        result.luminous_intensity_exponent := result.
            luminous_intensity_exponent + (x.elements[i].exponent * x.
            elements[i].unit.dimensions.luminous_intensity_exponent);
      END_REPEAT;
    ELSE
      result := x.dimensions;
    END_IF;
    RETURN(result);

  END_FUNCTION; -- derive_dimensional_exponents

  FUNCTION dimension_of(
               item: geometric_representation_item
      ): dimension_count;

    LOCAL
      x : SET OF representation;
      y : representation_context;
    END_LOCAL;
    x := using_representations(item);
    y := x[1].context_of_items;
    RETURN(y\geometric_representation_context.coordinate_space_dimension);

  END_FUNCTION; -- dimension_of

  FUNCTION dimensions_for_si_unit(
               n: si_unit_name
      ): dimensional_exponents;
    CASE n OF
      metre         :       RETURN(dimensional_exponents(1,0,0,0,0,0,0));
      gram          :       RETURN(dimensional_exponents(0,1,0,0,0,0,0));
      second        :       RETURN(dimensional_exponents(0,0,1,0,0,0,0));
      ampere        :       RETURN(dimensional_exponents(0,0,0,1,0,0,0));
      kelvin        :       RETURN(dimensional_exponents(0,0,0,0,1,0,0));
      mole          :       RETURN(dimensional_exponents(0,0,0,0,0,1,0));
      candela       :       RETURN(dimensional_exponents(0,0,0,0,0,0,1));
      radian        :       RETURN(dimensional_exponents(0,0,0,0,0,0,0));
      steradian     :       RETURN(dimensional_exponents(0,0,0,0,0,0,0));
      hertz         :       RETURN(dimensional_exponents(0,0,-1,0,0,0,0));
      newton        :       RETURN(dimensional_exponents(1,1,-2,0,0,0,0));
      pascal        :       RETURN(dimensional_exponents(-1,1,-2,0,0,0,0));
      joule         :       RETURN(dimensional_exponents(2,1,-2,0,0,0,0));
      watt          :       RETURN(dimensional_exponents(2,1,-3,0,0,0,0));
      coulomb       :       RETURN(dimensional_exponents(0,0,1,1,0,0,0));
      volt          :       RETURN(dimensional_exponents(2,1,-3,-1,0,0,0));
      farad         :       RETURN(dimensional_exponents(-2,-1,4,1,0,0,0));
      ohm           :       RETURN(dimensional_exponents(2,1,-3,-2,0,0,0));
      siemens       :       RETURN(dimensional_exponents(-2,-1,3,2,0,0,0));
      weber         :       RETURN(dimensional_exponents(2,1,-2,-1,0,0,0));
      tesla         :       RETURN(dimensional_exponents(0,1,-2,-1,0,0,0));
      henry         :       RETURN(dimensional_exponents(2,1,-2,-2,0,0,0));
      degree_celsius  :     RETURN(dimensional_exponents(0,0,0,0,1,0,0));
      lumen         :       RETURN(dimensional_exponents(0,0,0,0,0,0,1));
      lux           :       RETURN(dimensional_exponents(-2,0,0,0,0,0,1));
      becquerel     :       RETURN(dimensional_exponents(0,0,-1,0,0,0,0));
      gray          :       RETURN(dimensional_exponents(2,0,-2,0,0,0,0));
      sievert       :       RETURN(dimensional_exponents(2,0,-2,0,0,0,0));
      END_CASE;

  END_FUNCTION; -- dimensions_for_si_unit

  FUNCTION dot_product(
               arg1, arg2: direction
      ): REAL;

    LOCAL
      ndim   : INTEGER;
      scalar : REAL;
      vec1   : direction;
      vec2   : direction;
    END_LOCAL;
    IF (NOT EXISTS(arg1)) OR (NOT EXISTS(arg2)) THEN
      scalar := ?;
    ELSE
      IF arg1.dim <> arg2.dim THEN
        scalar := ?;
      ELSE
        BEGIN
          vec1 := normalise(arg1);
          vec2 := normalise(arg2);
          ndim := arg1.dim;
          scalar := 0;
          REPEAT i := 1 TO ndim BY 1;
            scalar := scalar + (vec1.direction_ratios[i] * vec2.
                direction_ratios[i]);
          END_REPEAT;
        END;
      END_IF;
    END_IF;
    RETURN(scalar);

  END_FUNCTION; -- dot_product

  FUNCTION edge_reversed(
               an_edge: edge
      ): edge;

    LOCAL
      the_reverse : edge;
    END_LOCAL;
    IF 'PLANT_SPATIAL_CONFIGURATION.ORIENTED_EDGE' IN TYPEOF(an_edge)
         THEN
      the_reverse := oriented_edge(an_edge\oriented_edge.edge_element,NOT 
          an_edge\oriented_edge.orientation);
    ELSE
      the_reverse := oriented_edge(an_edge,FALSE);
    END_IF;
    RETURN(the_reverse);

  END_FUNCTION; -- edge_reversed

  FUNCTION face_bound_reversed(
               a_face_bound: face_bound
      ): face_bound;

    LOCAL
      the_reverse : face_bound;
    END_LOCAL;
    IF 'PLANT_SPATIAL_CONFIGURATION.FACE_OUTER_BOUND' IN TYPEOF(
        a_face_bound) THEN
      the_reverse := face_bound(a_face_bound\face_bound.bound,NOT 
          a_face_bound\face_bound.orientation);
    ELSE
      the_reverse := face_bound(a_face_bound.bound,NOT a_face_bound.
          orientation);
    END_IF;
    RETURN(the_reverse);

  END_FUNCTION; -- face_bound_reversed

  FUNCTION face_reversed(
               a_face: face
      ): face;

    LOCAL
      the_reverse : face;
    END_LOCAL;
    IF 'PLANT_SPATIAL_CONFIGURATION.ORIENTED_FACE' IN TYPEOF(a_face) THEN
      the_reverse := oriented_face(a_face\oriented_face.face_element,NOT 
          a_face\oriented_face.orientation);
    ELSE
      the_reverse := oriented_face(a_face,FALSE);
    END_IF;
    RETURN(the_reverse);

  END_FUNCTION; -- face_reversed

  FUNCTION first_proj_axis(
               z_axis, arg: direction
      ): direction;

    LOCAL
      x_vec  : vector;
      v      : direction;
      z      : direction;
      x_axis : direction;
    END_LOCAL;
    IF (NOT EXISTS(z_axis)) OR (NOT EXISTS(arg)) OR (arg.dim <> 3) THEN
      x_axis := ?;
    ELSE
      z_axis := normalise(z_axis);
      IF NOT EXISTS(arg) THEN
        IF z_axis <> direction([1,0,0]) THEN
          v := direction([1,0,0]);
        ELSE
          v := direction([0,1,0]);
        END_IF;
      ELSE
        IF cross_product(arg,z).magnitude = 0 THEN
          RETURN(?);
        ELSE
          v := normalise(arg);
        END_IF;
      END_IF;
      x_vec := scalar_times_vector(dot_product(v,z),z_axis);
      x_axis := vector_difference(v,x_vec).orientation;
      x_axis := normalise(x_axis);
    END_IF;
    RETURN(x_axis);

  END_FUNCTION; -- first_proj_axis

  FUNCTION get_basis_surface(
               c: curve_on_surface
      ): SET [0:2] OF surface;

    LOCAL
      surfs : SET [0:2] OF surface;
      n     : INTEGER;
    END_LOCAL;
    surfs := [];
    IF 'PLANT_SPATIAL_CONFIGURATION.PCURVE' IN TYPEOF(c) THEN
      surfs := [c\pcurve.basis_surface];
    ELSE
      IF 'PLANT_SPATIAL_CONFIGURATION.SURFACE_CURVE' IN TYPEOF(c) THEN
        n := SIZEOF(c\surface_curve.associated_geometry);
        REPEAT i := 1 TO n BY 1;
          surfs := surfs + associated_surface(c\surface_curve.
              associated_geometry[i]);
        END_REPEAT;
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.COMPOSITE_CURVE_ON_SURFACE' IN TYPEOF(
        c) THEN
      n := SIZEOF(c\composite_curve_on_surface.segments);
      surfs := get_basis_surface(c\composite_curve_on_surface.segments[1].
          parent_curve);
      IF n > 1 THEN
        REPEAT i := 2 TO n BY 1;
          surfs := surfs * get_basis_surface(c\composite_curve_on_surface.
              segments[i].parent_curve);
        END_REPEAT;
      END_IF;
    END_IF;
    RETURN(surfs);

  END_FUNCTION; -- get_basis_surface

  FUNCTION item_in_context(
               item: representation_item;
               cntxt: representation_context
      ): BOOLEAN;

    LOCAL
      i : INTEGER;
      y : BAG OF representation_item;
    END_LOCAL;
    IF SIZEOF(USEDIN(item,
        'PLANT_SPATIAL_CONFIGURATION.REPRESENTATION.ITEMS') * cntxt.
        representations_in_context) > 0 THEN
      RETURN(TRUE);
    ELSE
      y := QUERY ( z <* USEDIN(item,'') | (
          'PLANT_SPATIAL_CONFIGURATION.' +
          'REPRESENTATION_ITEM' IN TYPEOF(z)) );
      IF SIZEOF(y) > 0 THEN
        REPEAT i := 1 TO HIINDEX(y) BY 1;
          IF item_in_context(y[i],cntxt) THEN
            RETURN(TRUE);
          END_IF;
        END_REPEAT;
      END_IF;
    END_IF;
    RETURN(FALSE);

  END_FUNCTION; -- item_in_context

  FUNCTION leap_year(
               year: year_number
      ): BOOLEAN;
    IF (((year MOD 4) = 0) AND ((year MOD 100) <> 0)) OR ((year MOD 400) =
         0) THEN
      RETURN(TRUE);
    ELSE
      RETURN(FALSE);
    END_IF;

  END_FUNCTION; -- leap_year

  FUNCTION list_face_loops(
               f: face
      ): LIST [0:?] OF loop;

    LOCAL
      loops : LIST [0:?] OF loop := [];
    END_LOCAL;
    REPEAT i := 1 TO SIZEOF(f.bounds) BY 1;
      loops := loops + f.bounds[i].bound;
    END_REPEAT;
    RETURN(loops);

  END_FUNCTION; -- list_face_loops

  FUNCTION list_of_topology_reversed(
               a_list: list_of_reversible_topology_item
      ): list_of_reversible_topology_item;

    LOCAL
      the_reverse : list_of_reversible_topology_item;
    END_LOCAL;
    the_reverse := [];
    REPEAT i := 1 TO SIZEOF(a_list) BY 1;
      the_reverse := topology_reversed(a_list[i]) + the_reverse;
    END_REPEAT;
    RETURN(the_reverse);

  END_FUNCTION; -- list_of_topology_reversed

  FUNCTION list_to_array(
               lis: LIST [0:?] OF GENERIC:t;
               low, u: INTEGER
      ): ARRAY [low:u] OF GENERIC:t;

    LOCAL
      n   : INTEGER;
      res : ARRAY [low:u] OF GENERIC:t;
    END_LOCAL;
    n := SIZEOF(lis);
    IF n <> ((u - low) + 1) THEN
      RETURN(?);
    ELSE
      REPEAT i := 1 TO n BY 1;
        res[(low + i) - 1] := lis[i];
      END_REPEAT;
      RETURN(res);
    END_IF;

  END_FUNCTION; -- list_to_array

  FUNCTION list_to_set(
               l: LIST [0:?] OF GENERIC:t
      ): SET OF GENERIC:t;

    LOCAL
      s : SET OF GENERIC:t := [];
    END_LOCAL;
    REPEAT i := 1 TO SIZEOF(l) BY 1;
      s := s + l[i];
    END_REPEAT;
    RETURN(s);

  END_FUNCTION; -- list_to_set

  FUNCTION make_array_of_array(
               lis: LIST [1:?] OF LIST [1:?] OF GENERIC:t;
               low1, u1, low2, u2: INTEGER
      ): ARRAY [low1:u1] OF ARRAY [low2:u2] OF GENERIC:t;

    LOCAL
      n2   : INTEGER;
      n1   : INTEGER;
      res  : ARRAY [low1:u1] OF ARRAY [low2:u2] OF GENERIC:t;
      resl : LIST [1:?] OF ARRAY [low2:u2] OF GENERIC:t;
    END_LOCAL;
    n1 := SIZEOF(lis);
    n2 := SIZEOF(lis[1]);
    IF (n1 <> ((u1 - low1) + 1)) AND (n2 <> ((u2 - low2) + 1)) THEN
      RETURN(?);
    END_IF;
    REPEAT i := 1 TO n1 BY 1;
      IF SIZEOF(lis[i]) <> n2 THEN
        RETURN(?);
      END_IF;
    END_REPEAT;
    REPEAT i := 1 TO n1 BY 1;
      resl[i] := list_to_array(lis[i],low2,u2);
    END_REPEAT;
    res := list_to_array(resl,low1,u1);
    RETURN(res);

  END_FUNCTION; -- make_array_of_array

  FUNCTION mixed_loop_type_set(
               l: SET [0:?] OF loop
      ): LOGICAL;

    LOCAL
      i              : INTEGER;
      poly_loop_type : LOGICAL;
    END_LOCAL;
    IF SIZEOF(l) <= 1 THEN
      RETURN(FALSE);
    END_IF;
    poly_loop_type := 'PLANT_SPATIAL_CONFIGURATION.POLY_LOOP' IN TYPEOF(l[
        1]);
    REPEAT i := 2 TO SIZEOF(l) BY 1;
      IF ('PLANT_SPATIAL_CONFIGURATION.POLY_LOOP' IN TYPEOF(l[i])) <> 
          poly_loop_type THEN
        RETURN(TRUE);
      END_IF;
    END_REPEAT;
    RETURN(FALSE);

  END_FUNCTION; -- mixed_loop_type_set

  FUNCTION normalise(
               arg: vector_or_direction
      ): vector_or_direction;

    LOCAL
      ndim   : INTEGER;
      v      : direction;
      vec    : vector;
      mag    : REAL;
      result : vector_or_direction;
    END_LOCAL;
    IF NOT EXISTS(arg) THEN
      result := ?;
    ELSE
      ndim := arg.dim;
      IF 'PLANT_SPATIAL_CONFIGURATION.VECTOR' IN TYPEOF(arg) THEN
        BEGIN
          vec := arg;
          v := arg\vector.orientation;
          IF arg\vector.magnitude = 0 THEN
            RETURN(?);
          ELSE
            vec.magnitude := 1;
          END_IF;
        END;
      ELSE
        v := arg;
      END_IF;
      mag := 0;
      REPEAT i := 1 TO ndim BY 1;
        mag := mag + (v.direction_ratios[i] * v.direction_ratios[i]);
      END_REPEAT;
      IF mag > 0 THEN
        mag := SQRT(mag);
        REPEAT i := 1 TO ndim BY 1;
          v.direction_ratios[i] := v.direction_ratios[i] / mag;
        END_REPEAT;
        IF 'PLANT_SPATIAL_CONFIGURATION.VECTOR' IN TYPEOF(arg) THEN
          vec.orientation := v;
          result := vec;
        ELSE
          result := v;
        END_IF;
      ELSE
        RETURN(?);
      END_IF;
    END_IF;
    RETURN(result);

  END_FUNCTION; -- normalise

  FUNCTION orthogonal_complement(
               vec: direction
      ): direction;

    LOCAL
      result : direction;
    END_LOCAL;
    IF (vec.dim <> 2) OR (NOT EXISTS(vec)) THEN
      RETURN(?);
    ELSE
      result.direction_ratios[1] := -vec.direction_ratios[2];
      result.direction_ratios[2] := vec.direction_ratios[1];
      RETURN(result);
    END_IF;

  END_FUNCTION; -- orthogonal_complement

  FUNCTION path_head_to_tail(
               a_path: path
      ): LOGICAL;

    LOCAL
      n : INTEGER;
      p : BOOLEAN := TRUE;
    END_LOCAL;
    n := SIZEOF(a_path.edge_list);
    REPEAT i := 2 TO n BY 1;
      p := p AND (a_path.edge_list[i - 1].edge_end :=: a_path.edge_list[i]
          .edge_start);
    END_REPEAT;
    RETURN(p);

  END_FUNCTION; -- path_head_to_tail

  FUNCTION path_reversed(
               a_path: path
      ): path;

    LOCAL
      the_reverse : path;
    END_LOCAL;
    IF 'PLANT_SPATIAL_CONFIGURATION.ORIENTED_PATH' IN TYPEOF(a_path) THEN
      the_reverse := oriented_path(a_path\oriented_path.path_element,NOT 
          a_path\oriented_path.orientation);
    ELSE
      the_reverse := oriented_path(a_path,FALSE);
    END_IF;
    RETURN(the_reverse);

  END_FUNCTION; -- path_reversed

  FUNCTION plant_spatial_configuration_organization_correlation(
               e: plant_spatial_configuration_organization_assignment
      ): BOOLEAN;

    LOCAL
      o_role : STRING;
    END_LOCAL;
    o_role := e\organization_assignment.role.name;
    CASE o_role OF
      'vendor'        :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* 
            e.items | (SIZEOF(['PLANT_SPATIAL_CONFIGURATION.PRODUCT',
            'PLANT_SPATIAL_CONFIGURATION.DOCUMENT'] * TYPEOF(x)) = 1) ))
             THEN
          RETURN(FALSE);
        END_IF;
      'owner'         :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* 
            e.items | (SIZEOF(['PLANT_SPATIAL_CONFIGURATION.SITE',
            'PLANT_SPATIAL_CONFIGURATION.DOCUMENT'] * TYPEOF(x)) = 1) ))
             THEN
          RETURN(FALSE);
        END_IF;
      'plant operator'  :         IF SIZEOF(e.items) <> SIZEOF(
            QUERY ( x <* e.items | ('PLANT_SPATIAL_CONFIGURATION.PLANT' IN 
            TYPEOF(x)) )) THEN
          RETURN(FALSE);
        END_IF;
      'plant owner'   :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* 
            e.items | ('PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(x)) ))
             THEN
          RETURN(FALSE);
        END_IF;
      'project owner' :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* 
            e.items | ('PLANT_SPATIAL_CONFIGURATION.DESIGN_PROJECT' IN 
            TYPEOF(x)) )) THEN
          RETURN(FALSE);
        END_IF;
      'assessor'      :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* 
            e.items | (('PLANT_SPATIAL_CONFIGURATION.' + 
            'PRODUCT_DEFINITION_RELATIONSHIP') IN TYPEOF(x)) )) THEN
          RETURN(FALSE);
        END_IF;
      OTHERWISE       :         RETURN(TRUE);
      END_CASE;
    RETURN(TRUE);

  END_FUNCTION; -- plant_spatial_configuration_organization_correlation

  FUNCTION plant_spatial_configuration_person_and_organization_correlation(
          e: plant_spatial_configuration_person_and_organization_assignment
      ): BOOLEAN;

    LOCAL
      po_role : STRING;
    END_LOCAL;
    po_role := e\person_and_organization_assignment.role.name;
    CASE po_role OF
      'owner'         :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* 
            e.items | (SIZEOF(['PLANT_SPATIAL_CONFIGURATION.SITE',
            'PLANT_SPATIAL_CONFIGURATION.' + 'CHANGE_ITEM'] * TYPEOF(x)) = 
            1) )) THEN
          RETURN(FALSE);
        END_IF;
      'plant owner'   :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* 
            e.items | ('PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(x)) ))
             THEN
          RETURN(FALSE);
        END_IF;
      'plant operator'  :         IF SIZEOF(e.items) <> SIZEOF(
            QUERY ( x <* e.items | ('PLANT_SPATIAL_CONFIGURATION.PLANT' IN 
            TYPEOF(x)) )) THEN
          RETURN(FALSE);
        END_IF;
      OTHERWISE       :         RETURN(TRUE);
      END_CASE;
    RETURN(TRUE);

  END_FUNCTION; -- plant_spatial_configuration_person_and_organization_correlation

  FUNCTION plant_spatial_configuration_person_correlation(
               e: plant_spatial_configuration_person_assignment
      ): BOOLEAN;

    LOCAL
      p_role : STRING;
    END_LOCAL;
    p_role := e\person_assignment.role.name;
    CASE p_role OF
      'vendor'     :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* e.
            items | ('PLANT_SPATIAL_CONFIGURATION.' +
             'DOCUMENT' IN TYPEOF(x)) ))
             THEN
          RETURN(FALSE);
        END_IF;
      'owner'      :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* e.
            items | (SIZEOF(['PLANT_SPATIAL_CONFIGURATION.SITE',
            'PLANT_SPATIAL_CONFIGURATION.DOCUMENT'] * TYPEOF(x)) = 1) ))
             THEN
          RETURN(FALSE);
        END_IF;
      'plant owner'  :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* e
            .items | ('PLANT_SPATIAL_CONFIGURATION.PLANT' IN TYPEOF(x)) ))
             THEN
          RETURN(FALSE);
        END_IF;
      'assessor'   :         IF SIZEOF(e.items) <> SIZEOF(QUERY ( x <* e.
            items | (('PLANT_SPATIAL_CONFIGURATION.' + 
            'PRODUCT_DEFINITION_RELATIONSHIP') IN TYPEOF(x)) )) THEN
          RETURN(FALSE);
        END_IF;
      OTHERWISE    :         RETURN(TRUE);
      END_CASE;
    RETURN(TRUE);

  END_FUNCTION; -- plant_spatial_configuration_person_correlation

  FUNCTION scalar_times_vector(
               scalar: REAL;
               vec: vector_or_direction
      ): vector;

    LOCAL
      v      : direction;
      mag    : REAL;
      result : vector;
    END_LOCAL;
    IF (NOT EXISTS(scalar)) OR (NOT EXISTS(vec)) THEN
      result := ?;
    ELSE
      IF 'PLANT_SPATIAL_CONFIGURATION.VECTOR' IN TYPEOF(vec) THEN
        v := vec\vector.orientation;
        mag := scalar * vec\vector.magnitude;
      ELSE
        v := vec;
        mag := scalar;
      END_IF;
      IF mag < 0 THEN
        REPEAT i := 1 TO SIZEOF(v.direction_ratios) BY 1;
          v.direction_ratios[i] := -v.direction_ratios[i];
        END_REPEAT;
        mag := -mag;
      END_IF;
      result.orientation := normalise(v);
      result.magnitude := mag;
    END_IF;
    RETURN(result);

  END_FUNCTION; -- scalar_times_vector

  FUNCTION second_proj_axis(
               z_axis, x_axis, arg: direction
      ): direction;

    LOCAL
      temp   : vector;
      v      : direction;
      y_axis : vector;
    END_LOCAL;
    IF NOT EXISTS(arg) THEN
      v := direction([0,1,0]);
    ELSE
      v := arg;
    END_IF;
    temp := scalar_times_vector(dot_product(v,z_axis),z_axis);
    y_axis := vector_difference(v,temp);
    temp := scalar_times_vector(dot_product(v,x_axis),x_axis);
    y_axis := vector_difference(y_axis,temp);
    y_axis := normalise(y_axis);
    RETURN(y_axis.orientation);

  END_FUNCTION; -- second_proj_axis

  FUNCTION set_of_topology_reversed(
               a_set: set_of_reversible_topology_item
      ): set_of_reversible_topology_item;

    LOCAL
      the_reverse : set_of_reversible_topology_item;
    END_LOCAL;
    the_reverse := [];
    REPEAT i := 1 TO SIZEOF(a_set) BY 1;
      the_reverse := the_reverse + topology_reversed(a_set[i]);
    END_REPEAT;
    RETURN(the_reverse);

  END_FUNCTION; -- set_of_topology_reversed

  FUNCTION shell_reversed(
               a_shell: shell
      ): shell;

    LOCAL
      the_reverse : shell;
    END_LOCAL;
    IF 'PLANT_SPATIAL_CONFIGURATION.ORIENTED_OPEN_SHELL' IN TYPEOF(a_shell)
         THEN
      the_reverse := oriented_open_shell(a_shell\oriented_open_shell.
          open_shell_element,NOT a_shell\oriented_open_shell.orientation);
    ELSE
      IF 'PLANT_SPATIAL_CONFIGURATION.OPEN_SHELL' IN TYPEOF(a_shell) THEN
        the_reverse := oriented_open_shell(a_shell,FALSE);
      ELSE
        IF 'PLANT_SPATIAL_CONFIGURATION.ORIENTED_CLOSED_SHELL' IN TYPEOF(
            a_shell) THEN
          the_reverse := oriented_closed_shell(a_shell\
              oriented_closed_shell.closed_shell_element,NOT a_shell\
              oriented_closed_shell.orientation);
        ELSE
          IF 'PLANT_SPATIAL_CONFIGURATION.CLOSED_SHELL' IN TYPEOF(a_shell)
               THEN
            the_reverse := oriented_closed_shell(a_shell,FALSE);
          ELSE
            the_reverse := ?;
          END_IF;
        END_IF;
      END_IF;
    END_IF;
    RETURN(the_reverse);

  END_FUNCTION; -- shell_reversed

  FUNCTION surface_weights_positive(
               b: rational_b_spline_surface
      ): BOOLEAN;

    LOCAL
      result : BOOLEAN := TRUE;
    END_LOCAL;
    REPEAT i := 0 TO b.u_upper BY 1;
      REPEAT j := 0 TO b.v_upper BY 1;
        IF b.weights[i][j] <= 0 THEN
          result := FALSE;
          RETURN(result);
        END_IF;
      END_REPEAT;
    END_REPEAT;
    RETURN(result);

  END_FUNCTION; -- surface_weights_positive

  FUNCTION topology_reversed(
               an_item: reversible_topology
      ): reversible_topology;
    IF 'PLANT_SPATIAL_CONFIGURATION.EDGE' IN TYPEOF(an_item) THEN
      RETURN(edge_reversed(an_item));
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.PATH' IN TYPEOF(an_item) THEN
      RETURN(path_reversed(an_item));
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.FACE_BOUND' IN TYPEOF(an_item) THEN
      RETURN(face_bound_reversed(an_item));
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.FACE' IN TYPEOF(an_item) THEN
      RETURN(face_reversed(an_item));
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.SHELL' IN TYPEOF(an_item) THEN
      RETURN(shell_reversed(an_item));
    END_IF;
    IF 'SET' IN TYPEOF(an_item) THEN
      RETURN(set_of_topology_reversed(an_item));
    END_IF;
    IF 'LIST' IN TYPEOF(an_item) THEN
      RETURN(list_of_topology_reversed(an_item));
    END_IF;
    RETURN(?);

  END_FUNCTION; -- topology_reversed

  FUNCTION using_representations(
               item: representation_item
      ): SET OF representation;

    LOCAL
      results            : SET OF representation;
      i                  : INTEGER;
      intermediate_items : SET OF representation_item;
      result_bag         : BAG OF representation;
    END_LOCAL;
    result_bag := USEDIN(item,
        'PLANT_SPATIAL_CONFIGURATION.REPRESENTATION.ITEMS');
    IF SIZEOF(result_bag) > 0 THEN
      REPEAT i := 1 TO HIINDEX(result_bag) BY 1;
        results := results + result_bag[i];
      END_REPEAT;
    END_IF;
    intermediate_items := QUERY ( z <* bag_to_set(USEDIN(item,'')) | (
        'PLANT_SPATIAL_CONFIGURATION.REPRESENTATION_ITEM' IN TYPEOF(z)) );
    IF SIZEOF(intermediate_items) > 0 THEN
      REPEAT i := 1 TO HIINDEX(intermediate_items) BY 1;
        results := results + using_representations(intermediate_items[i]);
      END_REPEAT;
    END_IF;
    RETURN(results);

  END_FUNCTION; -- using_representations

  FUNCTION valid_advanced_csg_tree(
               tree_element: boolean_operand
      ): BOOLEAN;
    IF SIZEOF(TYPEOF(tree_element) * ['PLANT_SPATIAL_CONFIGURATION.BLOCK',
        'PLANT_SPATIAL_CONFIGURATION.TORUS',
        'PLANT_SPATIAL_CONFIGURATION.RIGHT_CIRCULAR_CYLINDER',
        'PLANT_SPATIAL_CONFIGURATION.SPHERE',
        'PLANT_SPATIAL_CONFIGURATION.RIGHT_CIRCULAR_CONE',
        'PLANT_SPATIAL_CONFIGURATION.' + 
        'ADVANCED_FACE_WITH_THICKNESS_SHAPE_REPRESENTATION',
        'PLANT_SPATIAL_CONFIGURATION.EXTRUDED_AREA_SOLID',
        'PLANT_SPATIAL_CONFIGURATION.REVOLVED_AREA_SOLID',
        'PLANT_SPATIAL_CONFIGURATION.HALF_SPACE_SOLID']) = 1 THEN
      RETURN(TRUE);
    ELSE
      IF 'PLANT_SPATIAL_CONFIGURATION.BOOLEAN_RESULT' IN TYPEOF(
          tree_element) THEN
        IF NOT (tree_element\boolean_result.operator IN [boolean_operator.
            union,boolean_operator.difference]) THEN
          RETURN(FALSE);
        END_IF;
        IF 'PLANT_SPATIAL_CONFIGURATION.HALF_SPACE_SOLID' IN TYPEOF(
            tree_element\boolean_result.first_operand) THEN
          IF 'PLANT_SPATIAL_CONFIGURATION.ELEMENTARY_SURFACE' IN TYPEOF(
              tree_element\boolean_result.first_operand\half_space_solid.
              base_surface) THEN
            IF 'PLANT_SPATIAL_CONFIGURATION.HALF_SPACE_SOLID' IN TYPEOF(
                tree_element\boolean_result.second_operand) THEN
              IF 'PLANT_SPATIAL_CONFIGURATION.ELEMENTARY_SURFACE' IN 
                  TYPEOF(tree_element\boolean_result.second_operand\
                  half_space_solid.base_surface) THEN
                RETURN(TRUE);
              ELSE
                RETURN(FALSE);
              END_IF;
            ELSE
              RETURN(valid_advanced_csg_tree(tree_element\boolean_result.
                  second_operand));
            END_IF;
          ELSE
            RETURN(FALSE);
          END_IF;
        ELSE
          IF 'PLANT_SPATIAL_CONFIGURATION.HALF_SPACE_SOLID' IN TYPEOF(
              tree_element\boolean_result.second_operand) THEN
            IF 'PLANT_SPATIAL_CONFIGURATION.ELEMENTARY_SURFACE' IN TYPEOF(
                tree_element\boolean_result.second_operand\half_space_solid
                .base_surface) THEN
              RETURN(valid_advanced_csg_tree(tree_element\boolean_result.
                  first_operand));
            ELSE
              RETURN(FALSE);
            END_IF;
          ELSE
            RETURN(valid_advanced_csg_tree(tree_element\boolean_result.
                first_operand) AND valid_advanced_csg_tree(tree_element\
                boolean_result.second_operand));
          END_IF;
        END_IF;
      END_IF;
    END_IF;
    RETURN(FALSE);

  END_FUNCTION; -- valid_advanced_csg_tree

  FUNCTION valid_calendar_date(
               date: calendar_date
      ): LOGICAL;
    IF NOT ((1 <= date.day_component) AND (date.day_component <= 31))
         THEN
      RETURN(FALSE);
    END_IF;
    CASE date.month_component OF
      4        :         RETURN((1 <= date.day_component) AND (date.
            day_component <= 30));
      6        :         RETURN((1 <= date.day_component) AND (date.
            day_component <= 30));
      9        :         RETURN((1 <= date.day_component) AND (date.
            day_component <= 30));
      11       :         RETURN((1 <= date.day_component) AND (date.
            day_component <= 30));
      2        :         BEGIN
          IF leap_year(date.year_component) THEN
            RETURN((1 <= date.day_component) AND (date.day_component 
            <= 29));
          ELSE
            RETURN((1 <= date.day_component) AND (date.day_component 
            <= 28));
          END_IF;
        END;
      OTHERWISE  :         RETURN(TRUE);
      END_CASE;

  END_FUNCTION; -- valid_calendar_date

  FUNCTION valid_time(
               time: local_time
      ): BOOLEAN;
    IF EXISTS(time.second_component) THEN
      RETURN(EXISTS(time.minute_component));
    ELSE
      RETURN(TRUE);
    END_IF;

  END_FUNCTION; -- valid_time

  FUNCTION valid_units(
               m: measure_with_unit
      ): BOOLEAN;
    IF 'PLANT_SPATIAL_CONFIGURATION.LENGTH_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(1,0,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.MASS_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,1,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.TIME_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,1,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.ELECTRIC_CURRENT_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,0,1,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.THERMODYNAMIC_TEMPERATURE_MEASURE' IN 
        TYPEOF(m.value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,0,0,1,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.AMOUNT_OF_SUBSTANCE_MEASURE' IN 
        TYPEOF(m.value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,0,0,0,1,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.LUMINOUS_INTENSITY_MEASURE' IN TYPEOF(
        m.value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,0,0,0,0,1) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.PLANE_ANGLE_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.SOLID_ANGLE_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.AREA_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(2,0,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.VOLUME_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(3,0,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.RATIO_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.POSITIVE_LENGTH_MEASURE' IN TYPEOF(m.
        value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(1,0,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    IF 'PLANT_SPATIAL_CONFIGURATION.POSITIVE_PLANE_ANGLE_MEASURE' IN 
        TYPEOF(m.value_component) THEN
      IF derive_dimensional_exponents(m.unit_component) <> 
          dimensional_exponents(0,0,0,0,0,0,0) THEN
        RETURN(FALSE);
      END_IF;
    END_IF;
    RETURN(TRUE);

  END_FUNCTION; -- valid_units

  FUNCTION vector_difference(
               arg1, arg2: vector_or_direction
      ): vector;

    LOCAL
      ndim   : INTEGER;
      mag2   : REAL;
      mag1   : REAL;
      mag    : REAL;
      res    : direction;
      vec1   : direction;
      vec2   : direction;
      result : vector;
    END_LOCAL;
    IF (NOT EXISTS(arg1)) OR (NOT EXISTS(arg2)) OR (arg1.dim <> arg2.dim)
         THEN
      result := ?;
    ELSE
      BEGIN
        IF 'PLANT_SPATIAL_CONFIGURATION.VECTOR' IN TYPEOF(arg1) THEN
          mag1 := arg1\vector.magnitude;
          vec1 := arg1\vector.orientation;
        ELSE
          mag1 := 1;
          vec1 := arg1;
        END_IF;
        IF 'PLANT_SPATIAL_CONFIGURATION.VECTOR' IN TYPEOF(arg2) THEN
          mag2 := arg2\vector.magnitude;
          vec2 := arg2\vector.orientation;
        ELSE
          mag2 := 1;
          vec2 := arg2;
        END_IF;
        vec1 := normalise(vec1);
        vec2 := normalise(vec2);
        ndim := SIZEOF(vec1.direction_ratios);
        mag := 0;
        REPEAT i := 1 TO ndim BY 1;
          res.direction_ratios[i] := (mag1 * vec1.direction_ratios[i]) - (
              mag2 * vec2.direction_ratios[i]);
          mag := mag + (res.direction_ratios[i] * res.direction_ratios[i]);
        END_REPEAT;
        IF mag > 0 THEN
          result.magnitude := SQRT(mag);
          result.orientation := res;
        ELSE
          result.magnitude := 0;
          result.orientation := vec1;
        END_IF;
      END;
    END_IF;
    RETURN(result);

  END_FUNCTION; -- vector_difference

END_SCHEMA; -- plant_spatial_configuration
