(*
   $Id$
   ISO TC184/SC4/WG3 N1997 - ISO/TS 10303-410 AP210 electronic assembly interconnect and packaging design - EXPRESS MIM
   Supersedes ISO TC184/SC4/WG3 N1639
*)


SCHEMA Ap210_electronic_assembly_interconnect_and_packaging_design_mim '{ 1 0 10303 410 1 1 4}';
USE FROM Ap210_device_functional_and_physical_characterization_mim;	-- ISO/TS 10303-1612
USE FROM Ap210_interconnect_technology_constraints_mim;	-- ISO/TS 10303-1622
USE FROM Ap210_assembly_technology_constraints_mim;	-- ISO/TS 10303-1610
USE FROM Ap210_assembly_functional_requirements_mim;	-- ISO/TS 10303-1605
USE FROM Ap210_assembly_physical_requirements_mim;	-- ISO/TS 10303-1608
USE FROM Ap210_interconnect_functional_requirements_mim;	-- ISO/TS 10303-1619
USE FROM Ap210_interconnect_physical_requirements_mim;	-- ISO/TS 10303-1620
USE FROM Ap210_assembly_physical_design_mim;	-- ISO/TS 10303-1606
USE FROM Ap210_interconnect_design_for_microwave_mim;	-- ISO/TS 10303-1618
USE FROM Ap210_production_rule_mim;	-- ISO/TS 10303-1630
USE FROM Ap210_functional_decomposition_mim;	-- ISO/TS 10303-1614
USE FROM Ap210_package_functional_and_physical_characterization_mim;	-- ISO/TS 10303-1624
USE FROM Ap210_laminate_assembly_design_mim;	-- ISO/TS 10303-1623
USE FROM Ap210_connection_zone_based_model_extraction_mim;	-- ISO/TS 10303-1611
USE FROM Ap210_functional_specification_mim;	-- ISO/TS 10303-1616
USE FROM Ap210_physical_unit_physical_characterization_mim;	-- ISO/TS 10303-1626
USE FROM Ap210_packaged_part_white_box_model_mim;	-- ISO/TS 10303-1625
USE FROM Ap210_printed_part_functional_and_physical_characterization_mim;	-- ISO/TS 10303-1627
USE FROM Ap210_assembly_functional_interface_requirements_mim;	-- ISO/TS 10303-1604
USE FROM Ap210_assembly_physical_interface_requirements_mim;	-- ISO/TS 10303-1607
USE FROM Ap210_assembly_requirement_allocation_mim;	-- ISO/TS 10303-1609
USE FROM Ap210_interconnect_requirement_allocation_mim;	-- ISO/TS 10303-1621
USE FROM Ap210_functional_requirement_allocation_mim;	-- ISO/TS 10303-1615
USE FROM Ap210_datum_difference_based_model_definition_mim;	-- ISO/TS 10303-1759

USE FROM Drawing_definition_mim; -- ISO/TS 10303-1309
USE FROM Dimension_and_tolerance_callouts_mim; -- ISO/TS 10303-1362 
USE FROM Text_representation_mim; -- ISO/TS 10303-1750

USE FROM presentation_appearance_schema
   (pre_defined_surface_side_style); -- ISO 10303-46

USE FROM application_context_schema
	(application_context,
	 application_protocol_definition);

USE FROM geometry_schema(offset_curve_2d);

SUBTYPE_CONSTRAINT aeaiapd_component_terminal_subtypes FOR physical_component_terminal;         
  (ONEOF(assembly_module_macro_component_join_terminal,
        interconnect_module_macro_component_join_terminal));
END_SUBTYPE_CONSTRAINT;

SUBTYPE_CONSTRAINT model_parameter_subtypes FOR model_parameter;         
	(ONEOF(analytical_model_parameter,
               category_model_parameter));
END_SUBTYPE_CONSTRAINT;               

SUBTYPE_CONSTRAINT part_terminal_subtypes FOR shape_aspect; 
ONEOF (minimally_defined_bare_die_terminal, -- *pca*
 assembly_module_terminal, -- *pca*
 cable_terminal, -- *pca*
 interconnect_module_terminal, -- *PCB*
 packaged_part_terminal); -- *pca*
END_SUBTYPE_CONSTRAINT;

SUBTYPE_CONSTRAINT physical_unit_subtypes FOR physical_unit;         
 (ONEOF (bare_die, 
          package, 
          packaged_part, 
          assembly_definition, 
          interconnect_definition));
END_SUBTYPE_CONSTRAINT;

SUBTYPE_CONSTRAINT aeaiapd_shape_definition_3d_intersection_subtypes FOR shape_definition_3d_intersection;         
  (ONEOF (edge_segment_cross_section,
              pre_defined_parallel_datum_axis_symbol_3d_2d_relationship,
              pre_defined_perpendicular_datum_axis_symbol_3d_2d_relationship,
              pre_defined_perpendicular_datum_plane_symbol_3d_2d_relationship));
END_SUBTYPE_CONSTRAINT;        

TYPE ap210_managed_design_object = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON managed_design_object WITH 
     (action,
      alternate_product_relationship,
      applied_approval_assignment,
      applied_date_and_time_assignment,
      applied_document_reference,
      applied_group_assignment,
      approval,
      approval_status,
      certification,
      characterized_object,
      composite_curve_segment,
      configuration_effectivity,
      configuration_item,
      contract,
      curve_style,
      curve_style_font,
      curve_style_font_and_scaling,
      curve_style_parameters_representation,
      date,
      design_composition_path,
      dimension_related_tolerance_zone_element,
      dimensional_characteristic_representation,
      dimensional_size,
      document,
      document_usage_constraint,
      externally_defined_item,
--      fill_area_style_colour,
      fill_area_style_hatching,
      fill_area_style_tiles,
      func,
      geometric_tolerance,
      geometric_tolerance_relationship,
      group,
      layer_connection_point,
      material_designation,
      measure_with_unit,
      organization,
      operational_requirement_occurrence_relationship,
      requirement_view_definition_relationship,
      person,
      person_and_organization,
      plus_minus_tolerance,
      pre_defined_item,
      presentation_style_assignment,
      product,
      product_concept,
      product_definition,
      product_definition_formation,
      product_definition_formation_relationship,
      product_definition_relationship,
      property_definition,
      property_definition_relationship,
      property_definition_representation,
      reference_composition_path,
      representation,
      representation_context,
      representation_item,
      representation_relationship,
      runout_zone_orientation,
      security_classification,
      shape_aspect,
      shape_aspect_relationship,
      tolerance_value,
      tolerance_zone_form,
      versioned_action_request,
      action_directive,
	analog_port_variable,
	applied_external_identification_assignment,
	applied_organization_assignment,
	applied_person_and_organization_assignment,
	auxiliary_characteristic_dimension_representation,
	assembly_component,
	assembly_component_usage,
	assembly_component_usage_substitute,
	assembly_joint,
	assembly_group_component_definition_placement_link,
	assembly_bond_definition,
	analytical_representation,
	analytical_model_port_assignment,
	analytical_model_port,
	analytical_model_make_from_relationship,
	analytical_model_definition,
	applied_identification_assignment,
	bus_element_link,
	bus_structural_definition,
	calendar_date,
	complex_clause,
	component_2d_location,
	component_3d_location,
	component_definition,
	component_feature,
	component_feature_relationship,
	component_functional_terminal,
	component_functional_unit,
	component_terminal,
	composite_signal_property_relationship,
	connection_zone_map_identification,
	connection_zone_interface_plane_relationship,
	conductive_interconnect_element_terminal_link,
	connector_based_interconnect_definition,
	range_characteristic,
	date_and_time,
	datum,
	datum_difference_functional_unit_usage_view_terminal_assignment,
	descriptive_representation_item,
	device_terminal_map,
	dimensional_location,
	direct_stratum_component_join_implementation,
	direction,
	effectivity,
	evaluated_characteristic,
	externally_defined_curve_font,
	externally_defined_hatch_style,
    draughting_pre_defined_text_font,
    externally_defined_text_font,
    text_font,
	externally_defined_tile_style,
	fabrication_joint,
	frozen_assignment,
	functional_specification,
	functional_unit_terminal_definition,
	functional_terminal_group,
	general_property_relationship,
	geometric_representation_context,
	geometric_representation_item,
	geometric_tolerance_group,
	group_product_definition,
	group_shape_aspect,
	item_defined_transformation,
	interface_mounted_join,
	join_shape_aspect,
	layout_junction,
	linear_array_component_definition_link,
	make_from_connectivity_relationship,
	make_from_feature_relationship,
	make_from_usage_option,
	mapped_item,
	measure_qualification,
	model_parameter,
	network_node_definition,
	packaged_connector_terminal_relationship,
	parameter_assignment_override,
	parameter_assignment,
	part_connected_terminals_definition,
	passage_technology,
	physical_connectivity_definition,
	physical_connectivity_element,
	physical_network,
	physical_node_requirement_to_implementing_component_allocation,
	plated_inter_stratum_feature,
	product_category,
	product_category_relationship,
	product_definition_with_associated_documents,
	product_specific_parameter_value_assignment,
	promissory_usage_occurrence,
	projected_zone_definition,
	printed_connector_template_terminal_relationship,
	printed_part_template_connected_terminals_definition,
	printed_part_template_material,
	printed_part_template_material_link,
	representation_relationship_with_transformation,
	requirement_assignment,
	predefined_requirement_view_definition,
	rule_action,
	runout_zone_orientation_reference_direction,
	scalar_terminal_definition_link,
	sequential_laminate_passage_based_fabrication_joint,
	shape_dimension_representation,
	shape_representation,
	shape_representation_relationship,
	signal,
	simple_clause,
	solid_curve_font,
	specified_higher_usage_occurrence,
    stratum_feature_conductive_join,
    dielectric_crossover_area,
    stratum_feature_based_derived_pattern,
	stratum_surface,
	stratum_technology,
	stratum_technology_occurrence_link,
	styled_item,
	tolerance_zone_definition,
	usage_view_connection_zone_terminal_shape_relationship,
	vector);
END_TYPE;

TYPE ap210_presented_item_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON presented_item_select WITH 
    (action,
    action_method,
    action_relationship,
    product_concept,
    product_concept_feature,
    product_concept_feature_category,
    product_definition,
    product_definition_formation,
    product_definition_relationship);
END_TYPE;


RULE application_protocol_definition_required FOR
    (application_context);
WHERE
  WR1:  SIZEOF( QUERY( ac <* application_context |
              (SIZEOF (QUERY (apd <*
USEDIN(ac,'APPLICATION_CONTEXT_SCHEMA.APPLICATION_PROTOCOL_DEFINITION.APPLICATION')
|
                apd.application_interpreted_model_schema_name =
'electronic_assembly_interconnect_and_packaging_design'
                )) > 0)
              )) > 0;
END_RULE;

RULE cartesian_coordinate_system_constraint FOR
     (global_unit_assigned_context,
      geometric_representation_context);
LOCAL
   guac_inst : SET OF global_unit_assigned_context :=
               QUERY ( guac <* global_unit_assigned_context |
             ('GEOMETRY_SCHEMA.' +
              'GEOMETRIC_REPRESENTATION_CONTEXT' IN TYPEOF (guac)));
END_LOCAL;
WHERE
   WR1: SIZEOF (QUERY (guac <* guac_inst |
        NOT (SIZEOF (guac.units) <= 3))) = 0;
   WR2: SIZEOF (QUERY (guac <* guac_inst | (NOT (
        (SIZEOF (QUERY (u <* guac.units |
        ('MEASURE_SCHEMA.LENGTH_UNIT'
        IN TYPEOF (u)))) = 1)
        AND
        (SIZEOF (QUERY (u <* guac.units |
     ('MEASURE_SCHEMA.' +
         'PLANE_ANGLE_UNIT'
        IN TYPEOF (u)))) = 1)
        AND
        (SIZEOF (QUERY (u <* guac.units |
    ('MEASURE_SCHEMA.' +
         'SOLID_ANGLE_UNIT'
        IN TYPEOF (u)) )) <= 1)
        )))) = 0;
   WR3: SIZEOF( QUERY( grc <* guac_inst |
        NOT( (grc.coordinate_space_dimension = 2) OR
        (grc.coordinate_space_dimension = 3)))) = 0;
   WR4: SIZEOF (QUERY (guac <* guac_inst |
        NOT (SIZEOF (QUERY (u <* guac.units |NOT(
    NOT((
     'MEASURE_SCHEMA.' +
     'PLANE_ANGLE_UNIT' IN TYPEOF(u)) AND
    ('MEASURE_SCHEMA.' +
     'CONVERSION_BASED_UNIT' IN TYPEOF(u)) AND
     (u\conversion_based_unit.name = 'degree'))
   OR
       ((abs(u\conversion_based_unit.
           conversion_factor\measure_with_unit.value_component -
               0.0174532925) <= 0.001) AND
        ('MEASURE_SCHEMA.' +
         'PLANE_ANGLE_MEASURE_WITH_UNIT'
        IN TYPEOF(u\conversion_based_unit.conversion_factor)))
   ))) = 0)
   )) = 0;
END_RULE;

RULE not_instantiable_pre_defined_surface_side_style FOR
    (pre_defined_surface_side_style);
WHERE
 WR1: SIZEOF (pre_defined_surface_side_style) = 0;
END_RULE;

RULE shape_representation_requires_origin FOR (shape_representation);
WHERE
  WR1: 
(* 
pseudocode
co:FOREACH (sr <* shape_representation |c1);
c1:EXACTLYONE(it <* sr\representation.items |c2) 
   or ATLEASTONE(it <* sr\representation.items |c3)
   or EXACTLYNONE(it <* sr\representation.items |c4);
c2:((it.name = 'origin') or (it.name = 'orientation')) and 
   (AXIS2_PLACEMENT_2D in TYPEOF(it)  OR
    AXIS2_PLACEMENT_3D in TYPEOF(it));
c3:STYLED_ITEM in TYPEOF(it);
c4:((it.name = 'origin') or (it.name = 'orientation')) and
   ((sr.name = 'zone shape') or 
   (sr.context_of_items.context_type = 'connection zone colour'));
*)
SIZEOF(QUERY ( sr <* shape_representation |  NOT(
(SIZEOF(QUERY ( it <* sr\representation.items | (
((it\representation_item.name = 'origin') or (it\representation_item.name = 'orientation')) and 
   (('GEOMETRY_SCHEMA.' +
    'AXIS2_PLACEMENT_2D' in TYPEOF(it))  OR
   ('GEOMETRY_SCHEMA.' +
    'AXIS2_PLACEMENT_2D' in TYPEOF(it)))
))) = 1
) 
OR
(SIZEOF(QUERY ( it <* sr\representation.items | (
   ('PRESENTATION_APPEARANCE_SCHEMA.' +
    'STYLED_ITEM' in TYPEOF(it))
))) >= 1
)
OR
(SIZEOF(QUERY ( it <* sr\representation.items | (
((it\representation_item.name = 'origin') or (it\representation_item.name = 'orientation')) and
   ((sr\representation.name = 'zone shape') or 
   (sr.context_of_items\representation_context.context_type = 'connection zone colour'))
))) = 0
)
))) = 0;
END_RULE;

FUNCTION valid_2d_wireframe_edge_curve
  (crv   : curve; schma : STRING) : BOOLEAN;

  -- recursively check for valid basic curve types
  IF SIZEOF ([schma + '.LINE',
              schma + '.B_SPLINE_CURVE',
              schma + '.CIRCLE',
              schma + '.HYPERBOLA',
              schma + '.ELLIPSE',
              schma + '.PARABOLA',
              schma + '.POLYLINE'] * TYPEOF (crv)) = 1
      THEN RETURN (TRUE);
  ELSE
    -- recursively check for valid basic curves for curve_replicas
    IF (schma + '.CURVE_REPLICA') IN TYPEOF (crv)
      THEN RETURN (valid_2d_wireframe_edge_curve
                         (crv\curve_replica.parent_curve, schma));
    -- recursively check for valid basis curves for offset_curves
    ELSE
      IF (schma + '.OFFSET_CURVE_2D') IN TYPEOF (crv)
        THEN RETURN (valid_2d_wireframe_edge_curve
                         (crv\offset_curve_2d.basis_curve, schma));
      END_IF;
    END_IF;
  END_IF;
  RETURN (FALSE);
END_FUNCTION;

END_SCHEMA;


