(*
 * $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 N - ISO/CD-TS 10303-xxxx Physical unit shape with parameters - EXPRESS ARM
   by LKSoftWare GmbH for implementation purpose within IDA-STEP(TM)
*)

SCHEMA Physical_unit_shape_with_parameters_xim;

USE FROM Physical_unit_usage_view_xim;	-- ISO/TS 10303-1732

USE FROM Shape_parameters_xim;

USE FROM Physical_unit_shape_with_parameters_mim;

REFERENCE FROM support_resource_schema   -- ISO 10303-41
  (bag_to_set);

  TYPE mass_property_quality = ENUMERATION OF
    (high,
     medium,
     low,
     is_unknown);
  END_TYPE;

	TYPE puswp_requirement_assignment_item = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON requirement_assignment_item WITH 
	    (Physical_unit_keepout_shape_model,
		Physical_unit_shape_model);
	END_TYPE; 

  TYPE shape_approximation_level = ENUMERATION OF
    (coarse,
     detailed,
     is_unknown);
  END_TYPE;

  TYPE shape_extent = ENUMERATION OF
    (envelope,
     over_body,
     over_lands,
     over_breakout);
  END_TYPE;

  ENTITY Physical_unit_keepout_shape_model
    ABSTRACT (* CONNOTATIONAL *) SUBTYPE OF (shape_representation);
			constrained_design_object_category : keepout_product_design_object_category;    
      shape_characterized_definition     : Part_usage_view; --physical_unit;
      shape_material_condition           : material_condition;
      shape_purpose                      : OPTIONAL predefined_keepout_purpose;
      shape_environment                  : application_environment;
      shape_extent                       : shape_extent;			
      shape_approximation_level          : shape_approximation_level;
      centroid_location                  : OPTIONAL Cartesian_point;
    DERIVE
      principal_part_shape : SET [0:1] OF Shape_representation_relationship :=
        bag_to_set(QUERY( gmr <* USEDIN(SELF,
        'PRODUCT_PROPERTY_REPRESENTATION_SCHEMA.SHAPE_REPRESENTATION_RELATIONSHIP.REP_2') |
         (gmr\Representation_relationship.name = 'principal part shape')));      
    INVERSE
	  external_shape_purpose : SET [0:1] OF External_source_identification FOR items;      
	WHERE
	  WR1 : (EXISTS (shape_purpose)) XOR ((SIZEOF(external_shape_purpose)) = 1);
      WR2 : SIZEOF(principal_part_shape) < 2;
  END_ENTITY;

  ENTITY Physical_unit_shape_model
    ABSTRACT (* CONNOTATIONAL *) SUBTYPE OF (shape_representation);
      shape_characterized_definition    : Part_view_definition;
      shape_material_condition          : material_condition;      
      centroid_location					: OPTIONAL Cartesian_point;      
      shape_environment                 : application_environment;      
      shape_extent						: shape_extent;      
      shape_approximation_level			: shape_approximation_level;
      mass_property_quality				: mass_property_quality;
    DERIVE
      principal_part_shape : SET [0:1] OF Shape_representation_relationship :=
        bag_to_set(QUERY( gmr <* USEDIN(SELF,
        'PRODUCT_PROPERTY_REPRESENTATION_SCHEMA.SHAPE_REPRESENTATION_RELATIONSHIP.REP_2') |
         (gmr\Representation_relationship.name = 'principal part shape')));      
    WHERE
      WR1 : NOT ('PACKAGED_PART_BLACK_BOX_MODEL_XIM.PACKAGED_PART_ARMX' IN TYPEOF(shape_characterized_definition));
      WR2 : SIZEOF(USEDIN(SELF, 'SHAPE_PROPERTY_ASSIGNMENT_XIM.SHAPE_DESCRIPTION_ASSOCIATION.REPRESENTATION'))=0;            
      WR3 : SIZEOF(principal_part_shape) < 2;
  END_ENTITY;

  ENTITY Physical_unit_shape_representation_relationship
  	(* CONNOTATIONAL *) SUBTYPE OF (shape_representation_relationship);
      SELF\Shape_representation_relationship.rep_1 RENAMED principal_part_shape : Physical_unit_shape_model;
      SELF\Shape_representation_relationship.rep_2 RENAMED related_part_shape   : Physical_unit_shape_model;
    DERIVE
      SELF\Representation_relationship.name : label := 'physical unit shape representation relationship';
    UNIQUE
      UR1 : principal_part_shape,
 related_part_shape;
    WHERE
      WR1 : principal_part_shape :<>: related_part_shape;
      WR3 : principal_part_shape\shape_representation.context_of_items :=: related_part_shape\shape_representation.context_of_items;
      WR4 : principal_part_shape\Physical_unit_shape_model.shape_characterized_definition :=:
            related_part_shape\Physical_unit_shape_model.shape_characterized_definition;
  END_ENTITY;

END_SCHEMA;


