(*
 * $Id$
 *
 * JSDAI(TM), a way to implement STEP, ISO 10303
 * Copyright (C) 1997-2008, LKSoftWare GmbH, Germany
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License
 * version 3 as published by the Free Software Foundation (AGPL v3).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * JSDAI is a registered trademark of LKSoftWare GmbH, Germany
 * This software is also available under commercial licenses.
 * See also http://www.jsdai.net/
 *)

(*
   Derived from ISO TC184/SC4/WG12 N2876 - ISO/TS 10303-1051 Geometric tolerance - EXPRESS ARM
   by LKSoftWare GmbH for implementation purpose within IDA-STEP(TM)
*)

(* Based on ARM *) 


SCHEMA Geometric_tolerance_xim;

USE FROM Derived_shape_element_xim;    -- ISO/TS 10303-1130

USE FROM Elemental_geometric_shape_xim;    -- ISO/TS 10303-1004

USE FROM Measure_representation_xim;    -- ISO/TS 10303-1118

USE FROM Shape_property_assignment_xim;    -- ISO/TS 10303-1032

USE FROM Value_with_unit_xim;    -- ISO/TS 10303-1054

USE FROM shape_tolerance_schema(
	geometric_tolerance,
	geometric_tolerance_with_datum_reference,
	geometric_tolerance_relationship,
	projected_zone_definition,
	tolerance_zone,
	tolerance_zone_definition);
	
USE FROM shape_aspect_definition_schema(
	datum,
	datum_reference,
	datum_target,
	limit_condition);

USE FROM aic_geometric_tolerances(
	angularity_tolerance,
  circular_runout_tolerance,
  coaxiality_tolerance,
  common_datum,
  concentricity_tolerance,
  cylindricity_tolerance,
  flatness_tolerance,
  line_profile_tolerance,
  parallelism_tolerance,
  perpendicularity_tolerance,
  position_tolerance,
  roundness_tolerance,
  straightness_tolerance,
  surface_profile_tolerance,
  symmetry_tolerance,
  total_runout_tolerance);

USE FROM Geometric_tolerance_mim;
 
ENTITY Angularity_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (angularity_tolerance, Geometric_tolerance_armx);
  SELF\Geometric_tolerance_with_datum_reference.datum_system RENAMED reference_datum : SET[1:2] OF Datum_reference;
END_ENTITY;

ENTITY Circular_runout_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (circular_runout_tolerance, Geometric_tolerance_armx);
  angle : OPTIONAL REAL;
  SELF\Geometric_tolerance_with_datum_reference.datum_system RENAMED reference_datum : SET[1:2] OF Datum_reference;
END_ENTITY;

ENTITY Coaxiality_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (coaxiality_tolerance, Geometric_tolerance_armx);
  SELF\Geometric_tolerance_with_datum_reference.datum_system RENAMED reference_datum : SET[1:2] OF Datum_reference;
END_ENTITY;

ENTITY Common_datum_armx
  (* CONNOTATIONAL *) SUBTYPE OF (common_datum);
  made_up_by : SET[2:?] OF Single_datum;
DERIVE
  SELF\shape_aspect.of_shape : product_definition_shape := ?;
  SELF\shape_aspect.product_definitional : LOGICAL := ?;
  SELF\shape_aspect.description : text := ?;
  SELF\datum.identification : identifier := ?;
  SELF\shape_aspect.name : label := ?;
END_ENTITY;

ENTITY Concentricity_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (concentricity_tolerance, Geometric_tolerance_armx);
  SELF\Geometric_tolerance_with_datum_reference.datum_system RENAMED reference_datum : SET[1:2] OF Datum_reference;
END_ENTITY;

ENTITY Cylindricity_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (cylindricity_tolerance, Geometric_tolerance_armx);
END_ENTITY;

ENTITY Datum_defined_by_derived_shape
  (* CONNOTATIONAL *) SUBTYPE OF (Derived_geometry, Single_datum);
END_ENTITY;

ENTITY Datum_defined_by_feature
  (* CONNOTATIONAL *) SUBTYPE OF (Single_datum);
  defined_by : Shape_element;
END_ENTITY;

ENTITY Datum_defined_by_targets
   (* CONNOTATIONAL *) SUBTYPE OF (Single_datum);
  defined_by : SET[1:?] OF Datum_target;
  SELF\Shape_aspect.description RENAMED rule_description : STRING;
END_ENTITY;

ENTITY Flatness_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (flatness_tolerance, Geometric_tolerance_armx);
END_ENTITY;

ENTITY Geometric_tolerance_armx
  ABSTRACT SUPERTYPE OF (ONEOF (Angularity_tolerance_armx,
                                Circular_runout_tolerance_armx,
                                Coaxiality_tolerance_armx,
                                Concentricity_tolerance_armx,
                                Cylindricity_tolerance_armx,
                                Flatness_tolerance_armx,
                                Line_profile_tolerance_armx,
                                Parallelism_tolerance_armx,
                                Perpendicularity_tolerance_armx,
                                Position_tolerance_armx,
                                Roundness_tolerance_armx,
                                Straightness_tolerance_armx,
                                Surface_profile_tolerance_armx,
                                Symmetry_tolerance_armx,
                                Total_runout_tolerance_armx))
	(* CONNOTATIONAL *) SUBTYPE OF (geometric_tolerance);                                
  applied_to : Shape_element;
  segment_size : OPTIONAL Measure_with_unit;
  significant_digits : OPTIONAL INTEGER;
  value_determination : OPTIONAL STRING;
	modification : OPTIONAL limit_condition;
  SELF\geometric_tolerance.description RENAMED qualifying_note : OPTIONAL STRING;
  SELF\geometric_tolerance.magnitude RENAMED tolerance_value : length_measure_with_unit;
DERIVE
  SELF\geometric_tolerance.toleranced_shape_aspect : shape_aspect := ?;
WHERE
  WR1: (NOT (EXISTS(segment_size))) OR ('Geometric_tolerance_xim.LENGTH_MEASURE' IN TYPEOF(segment_size.value_component));
  WR2: (NOT (EXISTS(magnitude))) OR ('Geometric_tolerance_xim.LENGTH_MEASURE' IN TYPEOF(magnitude.value_component));
  WR3: (NOT (EXISTS(significant_digits))) OR (significant_digits > 0);
END_ENTITY;

ENTITY Line_profile_tolerance_armx
	(* CONNOTATIONAL *) SUBTYPE OF (line_profile_tolerance, Geometric_tolerance_armx);
  affected_plane : OPTIONAL axis2_placement;
  reference_datum : OPTIONAL SET[1:3] OF Datum_reference; (** Originally it is mandatory SET[1:3] **)
END_ENTITY;

ENTITY Parallelism_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (parallelism_tolerance, Geometric_tolerance_armx);
  affected_plane : OPTIONAL axis2_placement;
  SELF\Geometric_tolerance_with_datum_reference.datum_system RENAMED reference_datum : SET[1:2] OF Datum_reference;
END_ENTITY;

ENTITY Perpendicularity_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (perpendicularity_tolerance, Geometric_tolerance_armx);
  affected_plane : OPTIONAL axis2_placement;
  SELF\Geometric_tolerance_with_datum_reference.datum_system RENAMED reference_datum : SET[1:3] OF Datum_reference;
END_ENTITY;

ENTITY Placed_target
  ABSTRACT SUPERTYPE OF (ONEOF (Target_circle,
                                Target_point,
                                Target_rectangle,
                                Target_straight_line))
  (* CONNOTATIONAL *) SUBTYPE OF (placed_datum_target_feature);
  defined_in : geometric_representation_context;
  parameter_reference : axis2_placement;
DERIVE
  SELF\shape_aspect.of_shape : product_definition_shape := ?;
  SELF\shape_aspect.product_definitional : LOGICAL := ?;
  SELF\shape_aspect.description : text := ?;
  SELF\datum_target.target_id : identifier := ?;
  SELF\shape_aspect.name : label := ?;
END_ENTITY;

ENTITY Position_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (position_tolerance, Geometric_tolerance_armx);
  affected_plane : OPTIONAL axis2_placement;
  reference_datum : OPTIONAL SET[1:3] OF Datum_reference; (** Originally it is mandatory SET[1:3] **)
END_ENTITY;

ENTITY Roundness_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (roundness_tolerance, Geometric_tolerance_armx);
END_ENTITY;

ENTITY Single_datum
  (* CONNOTATIONAL *) SUBTYPE OF (datum);
  SELF\datum.identification RENAMED datum_name : STRING;
  modification : OPTIONAL limit_condition;
DERIVE
  SELF\shape_aspect.of_shape : product_definition_shape := ?;
  SELF\shape_aspect.description : text := ?;
  SELF\shape_aspect.product_definitional : LOGICAL := ?;
  SELF\shape_aspect.name : label := ?;
END_ENTITY;

ENTITY Straightness_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (straightness_tolerance, Geometric_tolerance_armx);
  affected_plane : OPTIONAL axis2_placement;
END_ENTITY;

ENTITY Surface_profile_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (surface_profile_tolerance, Geometric_tolerance_armx);
  reference_datum : OPTIONAL SET[1:3] OF Datum_reference; (** Originally it is mandatory SET[1:3] **)
END_ENTITY;

ENTITY Symmetry_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (symmetry_tolerance, Geometric_tolerance_armx);
  affected_plane : OPTIONAL axis2_placement;
  SELF\Geometric_tolerance_with_datum_reference.datum_system RENAMED reference_datum : SET[1:3] OF Datum_reference;
END_ENTITY;

-- SEDS
ENTITY Target_area
  SUBTYPE OF (Datum_target);
DERIVE
  SELF\shape_aspect.of_shape : product_definition_shape := ?;
  SELF\shape_aspect.description : text := ?;
  SELF\shape_aspect.product_definitional : LOGICAL := ?;
  SELF\datum_target.target_id : identifier := ?;
  SELF\shape_aspect.name : label := ?;
END_ENTITY;

ENTITY Target_circle
  (* CONNOTATIONAL *) SUBTYPE OF (Placed_target);
  diameter : measure_representation_item;
END_ENTITY;


ENTITY Target_point
  (* CONNOTATIONAL *) SUBTYPE OF (Placed_target);
END_ENTITY;

ENTITY Target_rectangle
  (* CONNOTATIONAL *) SUBTYPE OF (Placed_target);
  target_length : measure_representation_item;
  target_width : measure_representation_item;
END_ENTITY;

ENTITY Target_straight_line
   (* CONNOTATIONAL *) SUBTYPE OF (Placed_target);
END_ENTITY;

ENTITY Total_runout_tolerance_armx
  (* CONNOTATIONAL *) SUBTYPE OF (total_runout_tolerance, Geometric_tolerance_armx);
  angle : REAL;
  SELF\Geometric_tolerance_with_datum_reference.datum_system RENAMED reference_datum : SET[1:2] OF Datum_reference;
END_ENTITY;

END_SCHEMA;  -- Geometric_tolerance_xim

