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

SCHEMA Shape_feature_xim;
USE FROM Contextual_shape_positioning_xim;
USE FROM Property_assignment_xim;
REFERENCE FROM support_resource_schema   -- ISO 10303-41
  (bag_to_set);

USE FROM Shape_feature_mim;

  TYPE sf_property_assignment_select = SELECT BASED_ON property_assignment_select WITH 
    (Shape_element, 
     characterized_object);
  END_TYPE; 

ENTITY Shape_feature_definition_armx -- see AP214 for mapping
(** Can't make it abstract, as it is used directly, need to add workarround on mappings ABSTRACT SUPERTYPE **)
  ABSTRACT SUPERTYPE
  SUBTYPE OF (shape_feature_definition);
    DERIVE
      feature_model : SET [1:?] OF shape_representation := get_geometric_model(of_shape); 
    INVERSE
      of_shape : Item_shape FOR definition;
    WHERE
      WR1: EXISTS(feature_model);
END_ENTITY;

ENTITY Shape_feature_occurrence  -- see AP214 for mapping
  ABSTRACT SUPERTYPE OF (ONEOF (Instanced_feature_armx, Placed_feature_armx))
  SUBTYPE OF (Shape_element);
END_ENTITY;

ENTITY Instanced_feature_armx  -- see AP214 for mapping
  SUBTYPE OF ( Shape_feature_occurrence, Shape_feature_definition_armx, instanced_feature);
END_ENTITY;

ENTITY Placed_feature_armx  -- see AP214 for mapping
  SUBTYPE OF ( Shape_feature_occurrence, placed_feature);
   definition : Shape_feature_definition_armx;
END_ENTITY;

 FUNCTION get_geometric_model(input : Item_shape) : SET OF Shape_representation;
 LOCAL
  sda : SET OF Shape_description_association := [];
  gm : SET OF Shape_representation := [];
 END_LOCAL;
 
  sda := bag_to_set(USEDIN(input,
	 	'SHAPE_PROPERTY_ASSIGNMENT_XIM.' + 
	 	'SHAPE_DESCRIPTION_ASSOCIATION.' + 'REPRESENTED_CHARACTERISTIC'));
 
 REPEAT i := 1 to SIZEOF(sda) BY 1;
  gm := gm + sda[i].representation;
 END_REPEAT;
 RETURN(gm);
END_FUNCTION;

END_SCHEMA;
