SCHEMA machining_schema;

(* Version 5 date: 2002-02-06 
 * Author: ISO TC184/SC1/WG7 
 *) 
 
(* ************************************************************ *) 
(* CONSTANT from geometry_schema                   ISO 10303-42 *) 
(* ************************************************************ *) 
 
CONSTANT 
dummy_gri : geometric_representation_item :=  representation_item('')|| 
            geometric_representation_item(); 
END_CONSTANT; 
 
 
(* ************************************************************ *) 
(* Types from approval_schema                      ISO 10303-41 *) 
(* ************************************************************ *) 
 
ENTITY approval;  (* m0 *) 
status :                    approval_status; 
level  :                    label; 
END_ENTITY; 
 
ENTITY approval_status;  (* m0 *) 
name :                      label; 
END_ENTITY; 
 
(* ************************************************************ *) 
(* Types from date_time_schema                     ISO 10303-41 *) 
(* ************************************************************ *) 
 
ENTITY date_and_time;  (* m0 *) 
date_component :            date; 
time_component :            local_time; 
END_ENTITY; 
 
ENTITY date   (* m0 *) 
SUPERTYPE OF (ONEOF (calendar_date, ordinal_date, 
week_of_year_and_day_date)); 
year_component :            year_number; 
END_ENTITY; 
 
ENTITY calendar_date  (* m0 *) 

SUBTYPE OF (date); 
day_component   :           day_in_month_number; 
month_component :           month_in_year_number; 
WHERE 
  WR1: valid_calendar_date (SELF); 
END_ENTITY; 
 
TYPE day_in_month_number = INTEGER; 
WHERE 
  WR1: {1 <= SELF <= 31}; 
END_TYPE;  
 
TYPE month_in_year_number = INTEGER; 
WHERE 
  WR1: { 1 <= SELF <= 12 }; 
END_TYPE;  
 
ENTITY ordinal_date  (* m0 *) 
SUBTYPE OF (date); 
day_component : day_in_year_number; 
WHERE 
  WR1: (NOT leap_year(SELF.year_component) AND { 1 <= day_component <= 365 
}) 
       OR 
       (leap_year(SELF.year_component) AND { 1 <= day_component <= 366 }); 
END_ENTITY;  
 
TYPE day_in_year_number = INTEGER; 
WHERE 
  WR1: {1 <= SELF <= 366}; 
END_TYPE;  
 
ENTITY week_of_year_and_day_date  (* m0 *) 
SUBTYPE OF (date); 
week_component :            week_in_year_number; 
day_component  :            OPTIONAL day_in_week_number; 
END_ENTITY;  
 
TYPE week_in_year_number = INTEGER; 
WHERE 
  WR1: { 1 <= SELF <= 53 }; 
END_TYPE;  
 
TYPE day_in_week_number = INTEGER; 
WHERE 
  WR1: { 1 <= SELF <= 7 }; 
END_TYPE; -- day_in_week_number 
 
ENTITY local_time;  (* m0 *) 
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; 
 
TYPE hour_in_day = INTEGER; 
WHERE 
  WR1: { 0 <= SELF < 24 }; 
END_TYPE;

TYPE minute_in_hour = INTEGER; 
WHERE 
  WR1: { 0 <= SELF <= 59 }; 
END_TYPE; 
 
TYPE second_in_minute = REAL; 
WHERE 
  WR1: { 0 <= SELF <= 60 }; 
END_TYPE; 
 
ENTITY coordinated_universal_time_offset;  (* m0 *) 
hour_offset   :             INTEGER; 
minute_offset :             OPTIONAL INTEGER; 
sense         :             ahead_or_behind; 
WHERE 
  WR1: { 0 <= hour_offset <= 12 }; 
  WR2: { 0 <= minute_offset <= 59 }; 
  WR3: NOT ((hour_offset <> 0) AND (sense = exact)); 
END_ENTITY; 
 
TYPE ahead_or_behind = ENUMERATION OF(ahead, exact, behind); 
END_TYPE; 
 
TYPE year_number = INTEGER; 
END_TYPE; 
 
FUNCTION valid_calendar_date (date : calendar_date) : LOGICAL; 
  CASE date.month_component OF 
    1  : RETURN({ 1 <= date.day_component <= 31 }); 
    2  : BEGIN 
           IF (leap_year(date.year_component)) THEN 
             RETURN({ 1 <= date.day_component <= 29 }); 
           ELSE 
             RETURN({ 1 <= date.day_component <= 28 }); 
           END_IF; 
         END; 
    3  : RETURN({ 1 <= date.day_component <= 31 }); 
    4  : RETURN({ 1 <= date.day_component <= 30 }); 
    5  : RETURN({ 1 <= date.day_component <= 31 }); 
    6  : RETURN({ 1 <= date.day_component <= 30 }); 
    7  : RETURN({ 1 <= date.day_component <= 31 }); 
    8  : RETURN({ 1 <= date.day_component <= 31 }); 
    9  : RETURN({ 1 <= date.day_component <= 30 }); 
    10 : RETURN({ 1 <= date.day_component <= 31 }); 
    11 : RETURN({ 1 <= date.day_component <= 30 }); 
    12 : RETURN({ 1 <= date.day_component <= 31 }); 
  END_CASE; 
       RETURN (FALSE); 
END_FUNCTION; 
 
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; 
 
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; 
 
(* ************************************************************ *) 
(* Types from person_organization_schema           ISO 10303-41 *) 
(* ************************************************************ *) 
 
ENTITY person;   (* m0 *) 
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; 
WHERE 
  WR1: EXISTS(last_name) OR EXISTS(first_name); 
END_ENTITY; 
 
ENTITY address;  (* m0 *) 
internal_location       :   OPTIONAL label; 
street_number           :   OPTIONAL label; 
street                  :   OPTIONAL label; 
postal_box              :   OPTIONAL label; 
town                    :   OPTIONAL label; 
region                  :   OPTIONAL label; 
postal_code             :   OPTIONAL label; 
country                 :   OPTIONAL label; 
facsimile_number        :   OPTIONAL label; 
telephone_number        :   OPTIONAL label; 
electronic_mail_address :   OPTIONAL label; 
telex_number            :   OPTIONAL label; 
WHERE 
  WR1: EXISTS(internal_location)       OR 
       EXISTS(street_number)           OR 
       EXISTS(street)                  OR 
       EXISTS(postal_box)              OR 
       EXISTS(town)                    OR 
       EXISTS(region)                  OR 
       EXISTS(postal_code)             OR 
       EXISTS(country)                 OR 
       EXISTS(facsimile_number)        OR 
       EXISTS(telephone_number)        OR 
       EXISTS(electronic_mail_address) OR 
       EXISTS(telex_number); 
END_ENTITY; 
 
(* ************************************************************ *) 
(* Types from support_resource_schema              ISO 10303-41 *) 
(* ************************************************************ *) 
 
TYPE identifier = STRING; 
END_TYPE; 
 
TYPE label = STRING; 
END_TYPE; 
 
TYPE text = STRING;
END_TYPE; 
 
FUNCTION bag_to_set  
(the_bag : BAG OF GENERIC : intype) : SET OF GENERIC : intype; 
LOCAL 
    the_set: SET OF GENERIC : intype := []; 
END_LOCAL; 
IF SIZEOF (the_bag) > 0 THEN 
   REPEAT i := 1 to HIINDEX (the_bag); 
     the_set := the_set + the_bag [i]; 
   END_REPEAT; 
END_IF; 
RETURN (the_set); 
END_FUNCTION; 
 
 
(* ************************************************************ *) 
(* Types from measure_schema                       ISO 10303-41 *) 
(* ************************************************************ *) 
 
TYPE length_measure = REAL; 
END_TYPE; 
 
TYPE parameter_value = REAL; 
END_TYPE; 
 
TYPE plane_angle_measure = REAL; 
END_TYPE; 
 
TYPE positive_length_measure = length_measure; 
WHERE 
WR1: SELF > 0; 
END_TYPE; 
 
TYPE positive_ratio_measure = ratio_measure; 
WHERE 
WR1: SELF > 0; 
END_TYPE; 
 
TYPE ratio_measure = REAL; 
END_TYPE; 
 
TYPE time_measure = REAL; 
END_TYPE; 
 
 
(* ************************************************************** *) 
(* Types from product_property_representation_schema ISO 10303-41 *) 
(* ************************************************************** *) 
 
ENTITY shape_representation (* t1 *) 
SUBTYPE OF (representation); 
END_ENTITY; 
 
 
(* ************************************************************ *) 
(* Types from geometry_schema                      ISO 10303-42 *) 
(* ************************************************************ *) 
 
TYPE trimming_select = SELECT  
    (cartesian_point,
    parameter_value); 
END_TYPE; 
 
TYPE trimming_preference = ENUMERATION OF  
   (cartesian, parameter, unspecified); 
END_TYPE; 
 
TYPE transition_code = ENUMERATION OF  
        (discontinuous, 
        continuous, 
        cont_same_gradient, 
        cont_same_gradient_same_curvature); 
END_TYPE; 
 
ENTITY trimmed_curve    (* c0 *) 
        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: ('MACHINING_SCHEMA.PARAMETER_VALUE' IN TYPEOF(trim_1[1])) OR  
             ('MACHINING_SCHEMA.PARAMETER_VALUE' IN TYPEOF(trim_1[2])); 
        WR2: ('MACHINING_SCHEMA.PARAMETER_VALUE' IN TYPEOF(trim_2[1])) OR  
             ('MACHINING_SCHEMA.PARAMETER_VALUE' IN TYPEOF(trim_2[2])); 
        WR3: ('MACHINING_SCHEMA.PARAMETER' IN TYPEOF(SELF.master_representation));
END_ENTITY; 
 
ENTITY composite_curve  (* c0 *) 
        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;  
 
ENTITY composite_curve_segment;         (* c0 *) 
        transition    : transition_code;  
        same_sense    : BOOLEAN;  
        parent_curve  : curve;  
 INVERSE  
         using_curves  : BAG [1:?] OF composite_curve FOR segments;  
 WHERE  
        WR1 : ('MACHINING_SCHEMA.BOUNDED_CURVE' IN 
          TYPEOF(parent_curve));  
END_ENTITY; 
 
TYPE b_spline_curve_form = ENUMERATION OF (polyline_form, circular_arc, 
elliptic_arc, parabolic_arc, hyperbolic_arc, unspecified); 
END_TYPE;

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; 
 
TYPE dimension_count = INTEGER; 
WHERE 
WR1: SELF > 0; 
END_TYPE; 
 
TYPE knot_type = ENUMERATION OF (uniform_knots, quasi_uniform_knots, 
piecewise_bezier_knots, unspecified); 
END_TYPE; 
 
TYPE pcurve_or_surface = SELECT (pcurve, surface); 
END_TYPE; 
 
TYPE vector_or_direction = SELECT (vector, direction); 
END_TYPE; 
 
ENTITY axis1_placement (* s1 *) 
SUBTYPE OF (placement); 
axis     : OPTIONAL direction; 
DERIVE 
z : direction := NVL(normalise(axis), dummy_gri || 
                     direction([0.0,0.0,1.0])); 
WHERE 
WR1: SELF\geometric_representation_item.dim  = 3; 
END_ENTITY; 
 
ENTITY axis2_placement_3d (* m0 *) 
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.0); 
END_ENTITY; 
 
ENTITY bezier_curve (* c1 *) 
SUBTYPE OF (b_spline_curve); 
END_ENTITY; 
 
ENTITY bezier_surface (* s1 *) 
SUBTYPE OF (b_spline_surface); 
END_ENTITY; 
 
ENTITY bounded_curve (* c0 *) 
SUPERTYPE OF (ONEOF(polyline, b_spline_curve, trimmed_curve, 
                    bounded_pcurve, composite_curve)) 
SUBTYPE OF (curve); 
END_ENTITY; 
 
ENTITY bounded_pcurve (* s0 *) 
SUBTYPE OF (pcurve, bounded_curve);


END_SCHEMA;

