(*
 * $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 layout template - EXPRESS ARM
   by LKSoftWare GmbH for implementation purpose within IDA-STEP(TM)
*)

SCHEMA Physical_layout_template_xim;

USE FROM Analytical_model_xim;	-- ISO/TS 10303-1603
USE FROM Feature_and_connection_zone_xim;	-- ISO/TS 10303-1671
   
REFERENCE FROM product_identification_xim(          -- ISO/TS 10303-1017 
        types_of_product 
); 

USE FROM Physical_layout_template_mim;

USE FROM application_context_schema(product_context);

  TYPE correlated_or_independent = SELECT
    (Property_value_representation,
     characteristic);
  END_TYPE;

  TYPE land_connection_zone_class = ENUMERATION OF
    (surface_point_class,
     edge_curve_class,
     edge_point_class,
     surface_area_class);
  END_TYPE;

  TYPE physical_unit_or_part_template = SELECT
    (Template_definition,
     Part_view_definition);
  END_TYPE;

  TYPE plp_material_item_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON
     material_item_select  WITH
   		(Template_definition);
  END_TYPE;

  ENTITY Connection_zone_in_layout_template
  	(* CONNOTATIONAL *) SUBTYPE OF (Connection_zone, Instanced_feature_armx);
  	SELF\Shape_element.containing_shape : Template_definition;
  	connection_zone_category            : OPTIONAL SET[1:?] OF land_connection_zone_class;
  END_ENTITY; 
  
	ENTITY Reference_part_template_for_analytical_model
		(* CONNOTATIONAL *) SUBTYPE OF (property_definition_representation);
		SELF\property_definition_representation.definition RENAMED template : Template_definition;
		analytical_representation																						: Analytical_model_definition_armx;
      DERIVE
        SELF\property_definition_representation.used_representation : representation := ?;
      UNIQUE
		UR1 : template;
	END_ENTITY;

  ENTITY Template
  	(* CONNOTATIONAL *) SUBTYPE OF (Product_armx);
    UNIQUE 
      UR1: SELF\product.id;
  	WHERE 
      WR1 : SIZEOF([ 'template model' ] * types_of_product(SELF))= 1 ;
  END_ENTITY;

  ENTITY Template_definition
    (* CONNOTATIONAL *) SUBTYPE OF (Item_shape, Product_view_definition, part_template_definition);
    	SELF\Product_view_definition.defined_version : Template_version;
    	physical_characteristic           : OPTIONAL SET[1:?] OF correlated_or_independent;
    DERIVE	
    	SELF\Item_shape.described_element : shapeable_item := SELF;      
    WHERE
      WR1 : SIZEOF(QUERY(prpc <* USEDIN(SELF\product_definition.formation.of_product,
 'PRODUCT_DEFINITION_SCHEMA.PRODUCT_RELATED_PRODUCT_CATEGORY.PRODUCTS') | (prpc.name = 'template model'))) > 0;
  END_ENTITY;
  
  ENTITY Template_version
  	(* CONNOTATIONAL *) SUBTYPE OF (product_definition_formation);
  		SELF\product_definition_formation.of_product : Template;
  END_ENTITY;

RULE template_version_constraint FOR 
(product_definition_formation);
WHERE
  WR1: SIZEOF ( QUERY ( pv <* Template_version | ( NOT ( 'PHYSICAL_LAYOUT_TEMPLATE_xim.' + 'TEMPLATE_VERSION' IN TYPEOF ( pv) ) ) AND ( 'PHYSICAL_LAYOUT_TEMPLATE_xim.' + 'TEMPLATE' IN TYPEOF ( pv.of_product) ) ) ) =0 ;
END_RULE; 

RULE template_definition_constraint FOR 
(Product_definition);
WHERE
  WR1: SIZEOF ( QUERY ( pvd <* Product_definition | ( NOT ( 'PHYSICAL_LAYOUT_TEMPLATE_xim.' + 'TEMPLATE_DEFINITION' IN TYPEOF (pvd) ) ) AND ( 'PHYSICAL_LAYOUT_TEMPLATE_xim.' + 'TEMPLATE_VERSION' IN TYPEOF ( pvd.formation) ) ) ) =0 ;
END_RULE; 


END_SCHEMA;

