Files
pylib/pylib/data_step_std.py
2026-01-22 18:50:07 +01:00

1168 lines
30 KiB
Python
Executable File

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name,too-few-public-methods
"""STEP Standard structure.
:Date: 2020-01-03
.. module:: data_step_std
:platform: *nix, Windows
:synopsis: STEP Standard structure.
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
.. seealso::
STEP, ISO 10303-21, AP 232 (Application Protocol)
http://www.steptools.com/stds/step/ and
https://www.steptools.com/stds/stp_aim/html/schema.html
ISO 10303-21:2002. Industrial automation systems and integration --
Product data representation and exchange -- Part 21:
Implementation methods: Clear text encoding of the exchange
structure
ISO 10303-21:2016. Industrial automation systems and integration --
Product data representation and exchange -- Part 21:
Implementation methods: Clear text encoding of the exchange
structure
"""
# DATA section
# - Format: Instance name = Entity instance
# - Example: #4 = PRODUCT_DEFINITION_SHAPE('','',#5);
# - Instance name
# - unique name in the form "#1234"
# - must consist of a positive number
# - only valid locally within the STEP-file
# - Entity instance: name of the entity in capital letters followed
# by attribute values in defined order within parentheses
# - Attributes
# - Only explicit attributes get mapped (are listed)
# - Inverse, Derived and re-declared attributes are not listed
# since their values can be deduced from the other ones.
# - Unset attribute values are given as: $
# - Re-declared attributes as derived in a subtype are encoded: *
# - Enumeration (ENUM), boolean (BOOLEAN) and logical (LOGICAL)
# values are given in capital letters with a leading and
# trailing dot, e. g.: .TRUE.
# - String values are given as: ''
# - Integers (INTEGER) and real (REAL) values are used identical
# to typical programming languages
# - elements of aggregates (SET, BAG, LIST, ARRAY) are given in
# parentheses, separated by comma ",":
# STEP Standard TYPE LIST: first index is 1.
# STEP Standard TYPE ARRAY: first index is 0.
from enum import Enum
#
# EXPRESS simple data types
# TODO: BINARY, NUMBER
#
class GENERIC:
"""GENERIC
"""
class STRING(str):
"""EXPRESS Type STRING
This is the most often used simple type. EXPRESS strings can be
of any length and can contain any character (ISO 10646/Unicode).
"""
class INTEGER(int):
"""EXPRESS Type INTEGER
EXPRESS integers can have in principle any length, but most
implementations restricted them to a signed 32 bit value.
"""
class REAL(float):
"""EXPRESS Type REAL
Ideally an EXPRESS real value is unlimited in accuracy and size.
But in practice a real value is represented by a floating point
value of type double.
"""
def BOOLEAN(value):
"""EXPRESS Type BOOLEAN with values TRUE and FALSE
:param value: either ``.T.`` for a True value or ``.F.`` for a
False value
:type value: str
:raises: TypeError
"""
if value == ".T.":
return True
if value == ".F.":
return False
raise ValueError
def LOGICAL(value):
"""EXPRESS Type LOGICAL with values TRUE and FALSE and in addition
UNKNOWN
:param value: either ``.T.`` for a True value or ``.F.`` for a
False value
:type value: str
"""
# TODO: how does the UNKNOWN value look like?
if value == ".T.":
return True
if value == ".F.":
return False
return None
#
# EXPRESS aggregation data types
# BAG unordered -> ?
# TODO: find a data type for BAG?
# TODO: test if BAG have unset members?
#
class SET(set):
"""EXPRESS Type SET
SET are unordered. Contain a particular value more than once, is
not allowed. It is not possible to contain unset members.
:param value: value
:type value: str
:param dtype:
:type dtype:
:rtype: set
"""
# TODO: test for unset members?
class LIST(tuple):
"""EXPRESS Type LIST
LIST are ordered. It is not possible to contain unset members.
:param value: value
:type value: str
:param dtype:
:type dtype:
:rtype: tuple
"""
# TODO: test for unset members?
class ARRAY(tuple):
"""EXPRESS Type ARRAY
ARRAY are ordered. An ARRAY is the only aggregate that may
contain unset members.
:param value: value
:type value: str
:param dtype:
:type dtype:
:rtype: tuple
"""
#
# STEP functions
#
def dimension_of(item):
"""STEP Standard FUNCTION dimension_of
:param item:
:type item: GEOMETRIC_REPRESENTATION_ITEM
:returns: dim
:rtype: Union[int, None]
:var dim: dimension_count
dimension_count > 0
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_dimension_of.html
"""
# (* SCHEMA step_merged_ap_schema; *)
#
# -- DIFF IN AP214
# -- DIFF IN AP203e2
# -- DIFF IN AP238 STEP-NC
# -- DIFF IN AP224
# -- DIFF IN AP232
# FUNCTION dimension_of
# (item : geometric_representation_item ) : dimension_count;
# LOCAL
# x : SET OF representation;
# y : representation_context;
# dim : dimension_count;
# END_LOCAL;
# IF 'STEP_MERGED_AP_SCHEMA.CARTESIAN_POINT' IN TYPEOF(item) THEN
# dim := SIZEOF(item\cartesian_point.coordinates);
# RETURN (dim);
# END_IF;
# IF 'STEP_MERGED_AP_SCHEMA.DIRECTION' IN TYPEOF(item) THEN
# dim := SIZEOF(item\direction.direction_ratios);
# RETURN (dim);
# END_IF;
# IF 'STEP_MERGED_AP_SCHEMA.VECTOR' IN TYPEOF(item) THEN
# dim := SIZEOF(item\vector.orientation\direction.direction_ratios);
# RETURN (dim);
# END_IF;
# x := using_representations(item);
# IF SIZEOF(x) > 0 THEN
# y := x[1].context_of_items;
# dim := y\geometric_representation_context.coordinate_space_dimension;
# RETURN (dim);
# ELSE
# RETURN (?);
# END_IF;
# END_FUNCTION;
if isinstance(item, CARTESIAN_POINT):
dim = len(item.coordinates)
return dim
if isinstance(item, DIRECTION):
dim = len(item.direction_ratios)
return dim
if isinstance(item, VECTOR):
dim = len(item.orientation.direction_ratios)
return dim
# TODO: x, y
# x := using_representations(item);
# IF SIZEOF(x) > 0 THEN
# y := x[1].context_of_items;
# dim := y\geometric_representation_context.coordinate_space_dimension;
# RETURN (dim);
# ELSE
# RETURN (?);
# END_IF;
return None
def list_to_array(lis, low, u):
"""STEP Standard FUNCTION list_to_array
:param lis: STEP Standard TYPE LIST [0:?] OF GENERIC
:type lis: tuple[GENERIC, ...]
:param low:
:type low: INTEGER
:param u:
:type u: INTEGER
:returns: res
:rtype: Union[tuple, None]
:var n:
:vartype n: INTEGER
:var res: STEP Standard TYPE ARRAY [low:u] OF GENERIC
:vartype res: tuple[GENERIC, ...]
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_list_to_array.html
"""
# (* SCHEMA step_merged_ap_schema; *)
# -- DIFF IN AP214
# -- DIFF IN AP203e2
# -- DIFF IN AP238 STEP-NC
# -- DIFF IN AP224
# -- DIFF IN AP232
# FUNCTION list_to_array
# (lis : LIST [0:?] OF GENERIC : t;
# low : INTEGER;
# u : INTEGER ) : ARRAY [low:u] OF GENERIC : t;
# LOCAL
# n : INTEGER;
# res : ARRAY [low:u] OF GENERIC : t;
# END_LOCAL;
# n := SIZEOF(lis);
# IF n <> u - low + 1 THEN
# RETURN (?);
# ELSE
# res := [ lis[1]:0 ];
# REPEAT i := 2 TO n BY 1;
# res[(low + i - 1)] := lis[i];
# END_REPEAT;
# RETURN (res);
# END_IF;
# END_FUNCTION;
n = len(lis)
# length of new array and old list must be equal
if n != u - low + 1: # len(lis) != len(range(low, u+1))
return None
# TODO: new list?
#res = [i for i in lis]
res = lis
return res
def boolean_choose(b, choice1, choice2):
"""STEP Standard FUNCTION boolean_choose
:param b:
:type b: BOOLEAN
:param choice1:
:type choice1: GENERIC
:param choice2:
:type choice2: GENERIC
:returns: STEP STEP Standard TYPE GENERIC
:rtype: object
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_boolean_choose.html
"""
# (* SCHEMA step_merged_ap_schema; *)
#
# FUNCTION boolean_choose
# (b : BOOLEAN;
# choice1 : GENERIC : item;
# choice2 : GENERIC : item ) : GENERIC : item;
# IF b THEN
# RETURN (choice1);
# ELSE
# RETURN (choice2);
# END_IF;
# END_FUNCTION;
return choice1 if b else choice2
def path_head_to_tail(a_path):
"""STEP Standard FUNCTION path_head_to_tail
Check if the path is a connected curve set.
:param a_path:
:type a_path: PATH
:returns: p
:rtype: LOGICAL
:var p:
:vartype item: LOGICAL
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_path_head_to_tail.html
"""
# (* SCHEMA step_merged_ap_schema; *)
# -- DIFF IN AP214
# -- DIFF IN AP203e2
# -- DIFF IN AP238 STEP-NC
# -- DIFF IN AP224
# -- DIFF IN AP232
# FUNCTION path_head_to_tail
# (a_path : path ) : LOGICAL;
# LOCAL
# n : INTEGER;
# p : LOGICAL := TRUE;
# END_LOCAL;
# n := SIZEOF(a_path.edge_list);
# REPEAT i := 2 TO n BY 1;
# p := p AND (a_path.edge_list[(i - 1)].edge_end :=: a_path.edge_list[i].edge_start);
# END_REPEAT;
# RETURN (p);
# END_FUNCTION;
n = len(a_path.edge_list)
p = all([a_path.edge_list[i-1].edge_end == a_path.edge_list[i].edge_start for i in range(1, n)])
return p
# STEP Standard Type Enumeration
# Enumeration values are simple strings such as red, green, and blue
# for an rgb-enumeration. In the case that an enumeration type is
# declared extensible it can be extended in other schemas.
# Python note: Starting with 1 because 0 is False in a boolean sense
class PREFERRED_SURFACE_CURVE_REPRESENTATION(Enum):
"""STEP Standard TYPE b_spline_curve_form
:cvar CURVE_3D:
:cvar PCURVE_S1:
:cvar PCURVE_S2:
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_preferred_surface_curve_representation.html
"""
CURVE_3D = 1
PCURVE_S1 = 2
PCURVE_S2 = 3
class B_SPLINE_CURVE_FORM(Enum):
"""STEP Standard TYPE b_spline_curve_form
ENUMERATION OF (polyline_form, circular_arc, elliptic_arc,
parabolic_arc, hyperbolic_arc, unspecified).
:cvar POLYLINE_FORM:
:cvar CIRCULAR_ARC:
:cvar ELLIPTIC_ARC:
:cvar PARABOLIC_ARC:
:cvar HYPERBOLIC_ARC:
:cvar UNSPECIFIED:
.. seealso::
https://www.steptools.com/std/stp_aim/html/t_b_spline_curve_form.html
"""
POLYLINE_FORM = 1
CIRCULAR_ARC = 2
ELLIPTIC_ARC = 3
PARABOLIC_ARC = 4
HYPERBOLIC_ARC = 5
UNSPECIFIED = 6
class KNOT_TYPE(Enum):
"""STEP Standard TYPE knot_type
ENUMERATION OF (uniform_knots, quasi_uniform_knots,
piecewise_bezier_knots, unspecified).
:cvar UNIFORM_KNOTS:
:cvar QUASI_UNIFORM_KNOTS:
:cvar PIECEWISE_BEZIER_KNOTS:
:cvar UNSPECIFIED:
.. seealso::
https://www.steptools.com/std/stp_aim/html/t_knot_type.html
"""
UNIFORM_KNOTS = 1
QUASI_UNIFORM_KNOTS = 2
PIECEWISE_BEZIER_KNOTS = 3
UNSPECIFIED = 4
class REPRESENTATION_ITEM:
"""STEP Standard ENTITY representation_item
Explicit Attributes
:param name: label
:type name: STRING
Additional attributes
:ivar idn: for the instance the instance id and for the class the
total number of instances
:vartype idn: int <<additional>>
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_representation_item.html
"""
idn = 0 # equal to total numbers of instances
def __init__(self, name):
self.name = name
REPRESENTATION_ITEM.idn += 1
self.idn = REPRESENTATION_ITEM.idn # instance id
class GEOMETRIC_REPRESENTATION_ITEM(REPRESENTATION_ITEM):
"""STEP Standard ENTITY geometric_representation_item
Explicit Attributes
:param name: label
:type name: STRING
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_geometric_representation_item.html
"""
def __init__(self, name):
# TODO: or dim rather in a method (or property) so that it is
# conducted only on demand?
self.dim = dimension_of(self)
super().__init__(name)
class POINT(GEOMETRIC_REPRESENTATION_ITEM):
"""STEP Standard ENTITY point
Explicit Attributes
:param name: label
:type name: STRING
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_point.html
"""
class CARTESIAN_POINT(POINT):
"""STEP Standard ENTITY cartesian_point
Explicit Attributes
:param name: label
:type name: STRING
:param coordinates: list of length_measure
:type coordinates: tuple[float, ...]
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_cartesian_point.html
"""
def __init__(self, name, coordinates):
self.coordinates = coordinates
super().__init__(name)
def __str__(self):
return "#"+str(self.idn)+" = CARTESIAN_POINT('"+self.name+"', "+str(self.coordinates)+")"
class TOPOLOGICAL_REPRESENTATION_ITEM(REPRESENTATION_ITEM):
"""STEP Standard ENTITY topological_representation_item
Explicit Attributes
:param name: label
:type name: STRING
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_topological_representation_item.html
"""
class VERTEX(TOPOLOGICAL_REPRESENTATION_ITEM):
"""STEP Standard ENTITY vertex
Explicit Attributes
:param name: label
:type name: STRING
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_vertex.html
"""
class VERTEX_POINT(VERTEX):
"""STEP Standard ENTITY vertex_point
Explicit Attributes
:param name: label
:type name: STRING
:param vertex_geometry: point
:type vertex_geometry: POINT
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_vertex_point.html
"""
def __init__(self, name, vertex_geometry):
self.vertex_geometry = vertex_geometry
super().__init__(name)
def __str__(self):
return "#"+str(self.idn)+" = VERTEX_POINT('"+self.name+"', #"+str(self.vertex_geometry.idn)+")"
class DIRECTION(GEOMETRIC_REPRESENTATION_ITEM):
"""STEP Standard ENTITY direction
Explicit Attributes
:param name: label
:type name: STRING
:param direction_ratios: STEP Standard LIST OF REAL
:type direction_ratios: LIST[REAL, ...]
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_direction.html
"""
def __init__(self, name, direction_ratios):
self.direction_ratios = direction_ratios
super().__init__(name)
class VECTOR(GEOMETRIC_REPRESENTATION_ITEM):
"""STEP Standard ENTITY vector
Explicit Attributes
:param name: label
:type name: STRING
:param orientation:
:type orientation: DIRECTION
:param magnitude: length_measure
:type magnitude: REAL
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_vector.html
"""
def __init__(self, name, orientation, magnitude):
self.orientation = orientation
self.magnitude = magnitude
super().__init__(name)
class EDGE(TOPOLOGICAL_REPRESENTATION_ITEM):
"""STEP Standard ENTITY edge
Explicit Attributes
:param name: label
:type name: STRING
:param edge_start: start point
:type edge_start: VERTEX
:param edge_end: end point
:type edge_end: VERTEX
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_edge.html
"""
def __init__(self, name, edge_start, edge_end):
self.edge_start = edge_start
self.edge_end = edge_end
super().__init__(name)
class CURVE(GEOMETRIC_REPRESENTATION_ITEM):
"""STEP Standard ENTITY curve
Explicit Attributes
:param name: label
:type name: STRING
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_curve.html
"""
class LINE(CURVE):
"""STEP Standard ENTITY line
Explicit Attributes
:param name: label
:type name: STRING
:param pnt:
:type pnt: CARTESIAN_POINT
:param dir:
:type dir: VECTOR
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_line.html
"""
def __init__(self, name, pnt, dir):
self.pnt = pnt
self.dir = dir
super().__init__(name)
class SURFACE_CURVE(CURVE):
"""STEP Standard ENTITY surface_curve
Explicit Attributes
:param name: label
:type name: STRING
:param curve_3d:
:type curve_3d: CURVE
:param associated_geometry: STEP Standard TYPE LIST OF
pcurve_or_surface (SELECT) <<TODO>>
:type associated_geometry: LIST[Union[PCURVE, SURFACE], ...]
:param master_representation: <<TODO>>
:type master_representation: PREFERRED_SURFACE_CURVE_REPRESENTATION
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
:ivar basis_surface: <<TODO>>
:vartype basis_surface: SET[SURFACE, ...]
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_surface_curve.html
"""
# TODO: type associated_geometry master_representation basis_surface
def __init__(self, name, curve_3d, associated_geometry, master_representation):
self.curve_3d = curve_3d
self.associated_geometry = associated_geometry
self.master_representation = master_representation
super().__init__(name)
class SEAM_CURVE(SURFACE_CURVE):
"""STEP Standard ENTITY seam_curve
Explicit Attributes
:param name: label
:type name: STRING
:param curve_3d:
:type curve_3d: CURVE
:param associated_geometry: STEP Standard TYPE LIST OF
pcurve_or_surface (SELECT) <<TODO>>
:type associated_geometry: LIST[Union[PCURVE, SURFACE], ...]
:param master_representation: <<TODO>>
:type master_representation: PREFERRED_SURFACE_CURVE_REPRESENTATION
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
:ivar basis_surface: <<TODO>>
:vartype basis_surface: SET[SURFACE, ...]
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_seam_curve.html
"""
class EDGE_CURVE(EDGE):
"""STEP Standard ENTITY edge_curve
Explicit Attributes
:param name: label
:type name: STRING
:param edge_start: start point
:type edge_start: VERTEX
:param edge_end: end point
:type edge_end: VERTEX
:param edge_geometry: curve
:type edge_geometry: CURVE
:param same_sense: <<TODO>>
:type same_sense: BOOLEAN
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
Definition from ISO/CD 10303-42:1992: An edge curve is a special
subtype of edge which has its geometry fully defined. The
geometry is defined by associating the edge with a curve which
may be unbounded. As the topological and geometric directions may
be opposed, an indicator (same sense) is used to identify whether
the edge and curve directions agree or are opposed. The Boolean
value indicates whether the curve direction agrees with (TRUE) or
is in the opposite direction (FALSE) to the edge direction. Any
geometry associated with the vertices of the edge shall be
consistent with the edge geometry.
Informal propositions
1. The domain of the edge curve is formally defined to be the
domain of its edge geometry as trimmed by the vertices. This
domain does not include the vertices.
2. An edge curve has non-zero finite extent.
3. An edge curve is a manifold.
4. An edge curve is arcwise connected.
5. The edge start is not a part of the edge domain.
6. The edge end is not a part of the edge domain.
7. Vertex geometry shall be consistent with edge geometry.
Attribute definitions
EdgeGeometry
The curve which defines the shape and spatial location of the
edge. This curve may be unbounded and is implicitly trimmed
by the vertices of the edge; this defines the edge domain.
Multiple edges can reference the same curve.
SameSense
This logical flag indicates whether (TRUE), or not (FALSE)
the senses of the edge and the curve defining the edge
geometry are the same. The sense of an edge is from the edge
start vertex to the edge end vertex; the sense of a curve is
in the direction of increasing parameter.
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_edge_curve.html
https://iaiweb.lbl.gov/Resources/IFC_Releases/R2x3_final/ifctopologyresource/lexical/ifcedgecurve.htm
"""
def __init__(self, name, edge_start, edge_end, edge_geometry, same_sense):
self.edge_geometry = edge_geometry
self.same_sense = BOOLEAN(same_sense)
super().__init__(name, edge_start, edge_end)
class PLACEMENT(GEOMETRIC_REPRESENTATION_ITEM):
"""STEP Standard ENTITY placement
Explicit Attributes
:param name: label
:type name: STRING
:param location:
:type location: CARTESIAN_POINT
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_placement.html
"""
def __init__(self, name, location):
self.location = location
super().__init__(name)
class AXIS2_PLACEMENT_2D(PLACEMENT):
"""STEP Standard ENTITY axis2_placement_2d
Explicit Attributes
:param name: label
:type name: STRING
:param location:
:type location: CARTESIAN_POINT
:param ref_direction:
:type ref_direction: DIRECTION
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
:ivar p:
:vartype p: LIST[DIRECTION, ...]
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_axis2_placement_2d.html
"""
# TODO: type p
def __init__(self, name, location, ref_direction):
self.ref_direction = ref_direction
super().__init__(name, location)
class AXIS2_PLACEMENT_3D(PLACEMENT):
"""STEP Standard ENTITY axis2_placement_3d
Explicit Attributes
:param name: label
:type name: STRING
:param location:
:type location: CARTESIAN_POINT
:param axis:
:type axis: DIRECTION
:param ref_direction:
:type ref_direction: DIRECTION
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
:ivar p:
:vartype p: LIST[DIRECTION, ...]
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_axis2_placement_3d.html
"""
def __init__(self, name, location, axis, ref_direction):
self.axis = axis
self.ref_direction = ref_direction
super().__init__(name, location)
class CONIC(CURVE):
"""STEP Standard ENTITY conic
Explicit Attributes
:param name: label
:type name: STRING
:param position: axis2_placement
:type position: Union[AXIS2_PLACEMENT_2D, AXIS2_PLACEMENT_3D]
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_conic.html
"""
def __init__(self, name, position):
self.position = position
super().__init__(name)
class CIRCLE(CONIC):
"""STEP Standard ENTITY circle
Explicit Attributes
:param name: label
:type name: STRING
:param position: axis2_placement
:type position: Union[AXIS2_PLACEMENT_2D, AXIS2_PLACEMENT_3D]
:param radius: positive_length_measure
:type radius: REAL
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_circle.html
"""
def __init__(self, name, position, radius):
self.radius = radius
super().__init__(name, position)
class ELLIPSE(CONIC):
"""STEP Standard ENTITY ellipse
Explicit Attributes
:param name: label
:type name: STRING
:param position: STEP Standard TYPE axis2_placement (SELECT)
:type position: Union[AXIS2_PLACEMENT_2D, AXIS2_PLACEMENT_3D]
:param semi_axis_1: positive_length_measure
:type semi_axis_1: REAL
:param semi_axis_2: positive_length_measure
:type semi_axis_2: REAL
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_ellipse.html
"""
def __init__(self, name, position, semi_axis_1, semi_axis_2):
self.semi_axis_1 = semi_axis_1
self.semi_axis_2 = semi_axis_2
super().__init__(name, position)
class BOUNDED_CURVE(CURVE):
"""STEP Standard ENTITY bounded_curve
Explicit Attributes
:param name: label
:type name: STRING
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_bounded_curve.html
"""
class B_SPLINE_CURVE(BOUNDED_CURVE):
"""STEP Standard ENTITY b_spline_curve
Explicit Attributes
:param name: label
:type name: STRING
:param degree:
:type degree: INTEGER
:param control_points_list:
:type control_points_list: LIST[CARTESIAN_POINT, ...]
:param curve_form:
:type curve_form: B_SPLINE_CURVE_FORM
:param closed_curve:
:type closed_curve: LOGICAL
:param self_intersect:
:type self_intersect: LOGICAL
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
:ivar upper_index_on_control_points:
:vartype upper_index_on_control_points: INTEGER
:ivar control_points:
:vartype control_points: ARRAY[CARTESIAN_POINT, ...]
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_b_spline_curve.html
"""
# TODO: curve_form from str to B_SPLINE_CURVE_FORM, closed_curve,
# self_intersect
def __init__(self, name, degree, control_points_list, curve_form,
closed_curve, self_intersect):
self.degree = degree
self.control_points_list = control_points_list
self.curve_form = curve_form
self.closed_curve = LOGICAL(closed_curve)
self.self_intersect = LOGICAL(self_intersect)
self.upper_index_on_control_points = len(control_points_list) - 1
# TODO: necessary?
self.control_points = list_to_array(
control_points_list, 0, self.upper_index_on_control_points)
super().__init__(name)
class B_SPLINE_CURVE_WITH_KNOTS(B_SPLINE_CURVE):
"""STEP Standard ENTITY b_spline_curve_with_knots
Explicit Attributes
:param name: label
:type name: STRING
:param degree:
:type degree: INTEGER
:param control_points_list:
:type control_points_list: LIST[CARTESIAN_POINT, ...]
:param curve_form:
:type curve_form: B_SPLINE_CURVE_FORM
:param closed_curve:
:type closed_curve: LOGICAL
:param self_intersect:
:type self_intersect: LOGICAL
:param knot_multiplicities:
:type knot_multiplicities: LIST[INTEGER, ...]
:param knots: STEP Standard TYPE LIST OF parameter_value (REAL)
:type knots: LIST[REAL, ...]
:param knot_spec:
:type knot_spec: KNOT_TYPE
Derived Attributes
:ivar dim: dimension_count
:vartype dim: INTEGER
:ivar upper_index_on_control_points:
:vartype upper_index_on_control_points: INTEGER
:ivar control_points:
:vartype control_points: ARRAY[CARTESIAN_POINT, ...]
:ivar upper_index_on_knots:
:vartype upper_index_on_knots: INTEGER
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_b_spline_curve_with_knots.html
"""
# TODO: type of knot_spec from str to KNOT_TYPE
def __init__(self, name, degree, control_points_list, curve_form,
closed_curve, self_intersect, knot_multiplicities,
knots, knot_spec):
self.knot_multiplicities = knot_multiplicities
self.knots = knots
self.knot_spec = knot_spec
self.upper_index_on_knots = len(knots)
super().__init__(name, degree, control_points_list, curve_form,
closed_curve, self_intersect)
class ORIENTED_EDGE(EDGE):
"""STEP Standard ENTITY oriented_edge
Explicit Attributes
:param name: label
:type name: STRING
:param edge_start: [re-declared attribute from edge]
:type edge_start: VERTEX
:param edge_end: [re-declared attribute from edge]
:type edge_end: VERTEX
:param edge_element:
:type edge_element: EDGE
:param orientation:
:type orientation: BOOLEAN
Derived Attributes
:ivar edge_start: [re-declared attribute from edge]
:vartype edge_start: VERTEX
:ivar edge_end: [re-declared attribute from edge]
:vartype edge_end: VERTEX
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_oriented_edge.html
"""
def __init__(self, name, edge_start, edge_end, edge_element,
orientation):
# if edge_element not EDGE
if not isinstance(self, type(edge_element)):
# value of edge_start should be '*'
# value of edge_end should be '*'
self.edge_element = edge_element
self.orientation = BOOLEAN(orientation)
self.edge_start = boolean_choose(
self.orientation,
self.edge_element.edge_start, self.edge_element.edge_end)
self.edge_end = boolean_choose(
self.orientation,
self.edge_element.edge_end, self.edge_element.edge_start)
super().__init__(name, self.edge_start, self.edge_end)
else:
raise ValueError(edge_element + 'is not an EDGE')
class LOOP(TOPOLOGICAL_REPRESENTATION_ITEM):
"""STEP Standard ENTITY loop
Explicit Attributes
:param name: label
:type name: STRING
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_loop.html
"""
class PATH(TOPOLOGICAL_REPRESENTATION_ITEM):
"""STEP Standard ENTITY path
Explicit Attributes
:param name: label
:type name: STRING
:param edge_list:
:type edge_list: LIST[ORIENTED_EDGE, ...]
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_path.html
"""
def __init__(self, name, edge_list):
self.edge_list = edge_list
super().__init__(name)
if not path_head_to_tail(self):
raise ValueError(edge_list + 'is not a path')
class EDGE_LOOP(PATH, LOOP):
"""STEP Standard ENTITY edge_loop
Explicit Attributes
:param name: label
:type name: STRING
:param edge_list:
:type edge_list: LIST[ORIENTED_EDGE, ...]
.. seealso::
https://www.steptools.com/stds/stp_aim/html/t_edge_loop.html
"""
def __init__(self, name, edge_list):
self.edge_list = edge_list
super().__init__(name, edge_list)
self.ne = len(self.edge_list)
if self.edge_list[0].edge_start != self.edge_list[self.ne-1].edge_end:
raise ValueError(edge_list + 'is not a loop')