[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
committed by
wwmayer
parent
b5d0950211
commit
e887b8a843
@@ -23,7 +23,7 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
@@ -33,37 +33,47 @@ from SimpleDataTypes import *
|
||||
from TypeChecker import check_type
|
||||
import BaseType
|
||||
|
||||
|
||||
class BaseAggregate(object):
|
||||
""" A class that define common properties to ARRAY, LIST, SET and BAG.
|
||||
"""
|
||||
def __init__( self , bound1 , bound2 , base_type ):
|
||||
"""A class that define common properties to ARRAY, LIST, SET and BAG."""
|
||||
|
||||
def __init__(self, bound1, bound2, base_type):
|
||||
# check that bound1<bound2
|
||||
if (bound1!=None and bound2!=None):
|
||||
if bound1>bound2:
|
||||
if bound1 != None and bound2 != None:
|
||||
if bound1 > bound2:
|
||||
raise AssertionError("bound1 shall be less than or equal to bound2")
|
||||
self._bound1 = bound1
|
||||
self._bound2 = bound2
|
||||
self._base_type = base_type
|
||||
|
||||
def __getitem__(self, index):
|
||||
if index<self._bound1:
|
||||
raise IndexError("ARRAY index out of bound (lower bound is %i, passed %i)"%(self._bound1,index))
|
||||
elif(self._bound2!=None and index>self._bound2):
|
||||
raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound2,index))
|
||||
if index < self._bound1:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (lower bound is %i, passed %i)" % (self._bound1, index)
|
||||
)
|
||||
elif self._bound2 != None and index > self._bound2:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (upper bound is %i, passed %i)" % (self._bound2, index)
|
||||
)
|
||||
else:
|
||||
return list.__getitem__(self,index)
|
||||
|
||||
def __setitem__(self,index,value):
|
||||
if index<self._bound1:
|
||||
raise IndexError("ARRAY index out of bound (lower bound is %i, passed %i)"%(self._bound1,index))
|
||||
elif (self._bound2!=None and index>self._bound2):
|
||||
raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound2,index))
|
||||
elif not isinstance(value,self._base_type):
|
||||
raise TypeError("%s type expected, passed %s."%(self._base_type, type(value)))
|
||||
return list.__getitem__(self, index)
|
||||
|
||||
def __setitem__(self, index, value):
|
||||
if index < self._bound1:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (lower bound is %i, passed %i)" % (self._bound1, index)
|
||||
)
|
||||
elif self._bound2 != None and index > self._bound2:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (upper bound is %i, passed %i)" % (self._bound2, index)
|
||||
)
|
||||
elif not isinstance(value, self._base_type):
|
||||
raise TypeError("%s type expected, passed %s." % (self._base_type, type(value)))
|
||||
else:
|
||||
# first find the length of the list, and extend it if ever
|
||||
# the index is
|
||||
list.__setitem__(self,index,value)
|
||||
list.__setitem__(self, index, value)
|
||||
|
||||
|
||||
class ARRAY(BaseType.Type, BaseType.Aggregate):
|
||||
"""
|
||||
@@ -76,12 +86,12 @@ class ARRAY(BaseType.Type, BaseType.Aggregate):
|
||||
that an array value cannot contain duplicate elements.
|
||||
It may also specify that an array value
|
||||
need not contain an element at every index position.
|
||||
|
||||
|
||||
Given that m is the lower bound and n is the upper bound, there are exactly n-m+1 elements
|
||||
in the array. These elements are indexed by subscripts from m to n, inclusive (see 12.6.1).
|
||||
NOTE 1 { The bounds may be positive, negative or zero, but may not be indeterminate (?) (see
|
||||
14.2).
|
||||
|
||||
|
||||
Syntax:
|
||||
165 array_type = ARRAY bound_spec OF [ OPTIONAL ] [ UNIQUE ] base_type .
|
||||
176 bound_spec = '[' bound_1 ':' bound_2 ']' .
|
||||
@@ -119,16 +129,17 @@ class ARRAY(BaseType.Type, BaseType.Aggregate):
|
||||
a total of 40 elements of data type something in the attribute named sectors. Within each
|
||||
ARRAY[11:14], no duplicates may occur; however, the same something instance may occur in two
|
||||
different ARRAY[11:14] values within a single value for the attribute named sectors.
|
||||
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
@TODO
|
||||
"""
|
||||
def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False, OPTIONAL=False, scope = None):
|
||||
|
||||
def __init__(self, bound_1, bound_2, base_type, UNIQUE=False, OPTIONAL=False, scope=None):
|
||||
BaseType.Type.__init__(self, base_type, scope)
|
||||
if not type(bound_1)==int:
|
||||
if not type(bound_1) == int:
|
||||
raise TypeError("ARRAY lower bound must be an integer")
|
||||
if not type(bound_2)==int:
|
||||
if not type(bound_2) == int:
|
||||
raise TypeError("ARRAY upper bound must be an integer")
|
||||
if not (bound_1 <= bound_2):
|
||||
raise AssertionError("ARRAY lower bound must be less than or equal to upper bound")
|
||||
@@ -139,8 +150,8 @@ class ARRAY(BaseType.Type, BaseType.Aggregate):
|
||||
self._optional = OPTIONAL
|
||||
# preallocate list elements
|
||||
list_size = bound_2 - bound_1 + 1
|
||||
self._container = list_size*[None]
|
||||
|
||||
self._container = list_size * [None]
|
||||
|
||||
def bound_1(self):
|
||||
return self._bound_1
|
||||
|
||||
@@ -149,10 +160,10 @@ class ARRAY(BaseType.Type, BaseType.Aggregate):
|
||||
|
||||
def get_hiindex(self):
|
||||
return INTEGER(self._bound_2)
|
||||
|
||||
|
||||
def get_loindex(self):
|
||||
return INTEGER(self._bound_1)
|
||||
|
||||
|
||||
def get_hibound(self):
|
||||
return INTEGER(self._bound_2)
|
||||
|
||||
@@ -160,42 +171,54 @@ class ARRAY(BaseType.Type, BaseType.Aggregate):
|
||||
return INTEGER(self._bound_1)
|
||||
|
||||
def get_size(self):
|
||||
return INTEGER(self._bound_2 - self._bound_1 +1)
|
||||
|
||||
return INTEGER(self._bound_2 - self._bound_1 + 1)
|
||||
|
||||
def get_value_unique(self):
|
||||
''' Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise'''
|
||||
"""Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise"""
|
||||
if None in self._container:
|
||||
return Unknown
|
||||
if self.get_size()-len(set(self._container))>0: #some items are repeated
|
||||
if self.get_size() - len(set(self._container)) > 0: # some items are repeated
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def __getitem__(self, index):
|
||||
if index<self._bound_1:
|
||||
raise IndexError("ARRAY index out of bound (lower bound is %i, passed %i)"%(self._bound_1,index))
|
||||
elif(index>self._bound_2):
|
||||
raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound_2,index))
|
||||
if index < self._bound_1:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (lower bound is %i, passed %i)" % (self._bound_1, index)
|
||||
)
|
||||
elif index > self._bound_2:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (upper bound is %i, passed %i)" % (self._bound_2, index)
|
||||
)
|
||||
else:
|
||||
value = self._container[index-self._bound_1]
|
||||
if not self._optional and value==None:
|
||||
raise AssertionError("Not OPTIONAL prevent the value with index %i from being None (default). Please set the value first."%index)
|
||||
value = self._container[index - self._bound_1]
|
||||
if not self._optional and value == None:
|
||||
raise AssertionError(
|
||||
"Not OPTIONAL prevent the value with index %i from being None (default). Please set the value first."
|
||||
% index
|
||||
)
|
||||
return value
|
||||
|
||||
|
||||
def __setitem__(self, index, value):
|
||||
if index<self._bound_1:
|
||||
raise IndexError("ARRAY index out of bound (lower bound is %i, passed %i)"%(self._bound_1,index))
|
||||
elif(index>self._bound_2):
|
||||
raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound_2,index))
|
||||
if index < self._bound_1:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (lower bound is %i, passed %i)" % (self._bound_1, index)
|
||||
)
|
||||
elif index > self._bound_2:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (upper bound is %i, passed %i)" % (self._bound_2, index)
|
||||
)
|
||||
else:
|
||||
# first check the type of the value
|
||||
check_type(value,self.get_type())
|
||||
check_type(value, self.get_type())
|
||||
# then check if the value is already in the array
|
||||
if self._unique:
|
||||
if value in self._container:
|
||||
raise AssertionError("UNIQUE keyword prevents inserting this instance.")
|
||||
self._container[index-self._bound_1] = value
|
||||
self._container[index - self._bound_1] = value
|
||||
|
||||
|
||||
class LIST(BaseType.Type, BaseType.Aggregate):
|
||||
"""
|
||||
@@ -206,7 +229,7 @@ class LIST(BaseType.Type, BaseType.Aggregate):
|
||||
elements that can be held in the collection defined by a list data type.
|
||||
A list data type
|
||||
definition may optionally specify that a list value cannot contain duplicate elements.
|
||||
|
||||
|
||||
Syntax:
|
||||
237 list_type = LIST [ bound_spec ] OF [ UNIQUE ] base_type .
|
||||
176 bound_spec = '[' bound_1 ':' bound_2 ']' .
|
||||
@@ -228,24 +251,25 @@ class LIST(BaseType.Type, BaseType.Aggregate):
|
||||
EXAMPLE 28 { This example defines a list of arrays. The list can contain zero to ten arrays. Each
|
||||
array of ten integers shall be different from all other arrays in a particular list.
|
||||
complex_list : LIST[0:10] OF UNIQUE ARRAY[1:10] OF INTEGER;
|
||||
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
@TODO
|
||||
"""
|
||||
def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False, scope = None):
|
||||
|
||||
def __init__(self, bound_1, bound_2, base_type, UNIQUE=False, scope=None):
|
||||
BaseType.Type.__init__(self, base_type, scope)
|
||||
if not type(bound_1)==int:
|
||||
if not type(bound_1) == int:
|
||||
raise TypeError("LIST lower bound must be an integer")
|
||||
# bound_2 can be set to None
|
||||
self._unbounded = False
|
||||
if bound_2 == None:
|
||||
self._unbounded = True
|
||||
elif not type(bound_2)==int:
|
||||
elif not type(bound_2) == int:
|
||||
raise TypeError("LIST upper bound must be an integer")
|
||||
if not bound_1>=0:
|
||||
if not bound_1 >= 0:
|
||||
raise AssertionError("LIST lower bound must be greater of equal to 0")
|
||||
if (type(bound_2)==int and not (bound_1 <= bound_2)):
|
||||
if type(bound_2) == int and not (bound_1 <= bound_2):
|
||||
raise AssertionError("ARRAY lower bound must be less than or equal to upper bound")
|
||||
# set up class attributes
|
||||
self._bound_1 = bound_1
|
||||
@@ -254,7 +278,7 @@ class LIST(BaseType.Type, BaseType.Aggregate):
|
||||
# preallocate list elements if bounds are both integers
|
||||
if not self._unbounded:
|
||||
list_size = bound_2 - bound_1 + 1
|
||||
self._container = list_size*[None]
|
||||
self._container = list_size * [None]
|
||||
# for unbounded list, this will come after
|
||||
else:
|
||||
self._container = [None]
|
||||
@@ -264,15 +288,15 @@ class LIST(BaseType.Type, BaseType.Aggregate):
|
||||
|
||||
def bound_2(self):
|
||||
return self._bound_2
|
||||
|
||||
|
||||
def get_size(self):
|
||||
number_of_indeterminates = self._container.count(None)
|
||||
hiindex = len(self._container) - number_of_indeterminates
|
||||
return INTEGER(hiindex)
|
||||
|
||||
|
||||
def get_hiindex(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
"""When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value."""
|
||||
number_of_indeterminates = self._container.count(None)
|
||||
hiindex = len(self._container) - number_of_indeterminates
|
||||
return INTEGER(hiindex)
|
||||
@@ -282,24 +306,24 @@ class LIST(BaseType.Type, BaseType.Aggregate):
|
||||
|
||||
def get_hibound(self):
|
||||
hibound = self._bound_2
|
||||
if type(hibound)==int:
|
||||
if type(hibound) == int:
|
||||
return INTEGER(hibound)
|
||||
else:
|
||||
return hibound
|
||||
|
||||
|
||||
def get_lobound(self):
|
||||
lobound = self._bound_1
|
||||
if type(lobound)==int:
|
||||
if type(lobound) == int:
|
||||
return INTEGER(lobound)
|
||||
else:
|
||||
return lobound
|
||||
|
||||
def get_value_unique(self):
|
||||
''' Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise'''
|
||||
"""Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise"""
|
||||
if None in self._container:
|
||||
return Unknown
|
||||
if self.get_size()-len(set(self._container))>0: #some items are repeated
|
||||
if self.get_size() - len(set(self._container)) > 0: # some items are repeated
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@@ -307,66 +331,88 @@ class LIST(BaseType.Type, BaseType.Aggregate):
|
||||
def __getitem__(self, index):
|
||||
# case bounded
|
||||
if not self._unbounded:
|
||||
if index<self._bound_1:
|
||||
raise IndexError("ARRAY index out of bound (lower bound is %i, passed %i)"%(self._bound_1,index))
|
||||
elif(index>self._bound_2):
|
||||
raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound_2,index))
|
||||
if index < self._bound_1:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (lower bound is %i, passed %i)"
|
||||
% (self._bound_1, index)
|
||||
)
|
||||
elif index > self._bound_2:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (upper bound is %i, passed %i)"
|
||||
% (self._bound_2, index)
|
||||
)
|
||||
else:
|
||||
value = self._container[index-self._bound_1]
|
||||
value = self._container[index - self._bound_1]
|
||||
if value == None:
|
||||
raise AssertionError("Value with index %i not defined. Please set the value first."%index)
|
||||
raise AssertionError(
|
||||
"Value with index %i not defined. Please set the value first." % index
|
||||
)
|
||||
return value
|
||||
#case unbounded
|
||||
# case unbounded
|
||||
else:
|
||||
if index-self._bound_1>len(self._container):
|
||||
raise AssertionError("Value with index %i not defined. Please set the value first."%index)
|
||||
if index - self._bound_1 > len(self._container):
|
||||
raise AssertionError(
|
||||
"Value with index %i not defined. Please set the value first." % index
|
||||
)
|
||||
else:
|
||||
value = self._container[index-self._bound_1]
|
||||
value = self._container[index - self._bound_1]
|
||||
if value == None:
|
||||
raise AssertionError("Value with index %i not defined. Please set the value first."%index)
|
||||
raise AssertionError(
|
||||
"Value with index %i not defined. Please set the value first." % index
|
||||
)
|
||||
return value
|
||||
|
||||
|
||||
def __setitem__(self, index, value):
|
||||
# case bounded
|
||||
if not self._unbounded:
|
||||
if index<self._bound_1:
|
||||
raise IndexError("ARRAY index out of bound (lower bound is %i, passed %i)"%(self._bound_1,index))
|
||||
elif(index>self._bound_2):
|
||||
raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound_2,index))
|
||||
if index < self._bound_1:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (lower bound is %i, passed %i)"
|
||||
% (self._bound_1, index)
|
||||
)
|
||||
elif index > self._bound_2:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (upper bound is %i, passed %i)"
|
||||
% (self._bound_2, index)
|
||||
)
|
||||
else:
|
||||
# first check the type of the value
|
||||
check_type(value,self.get_type())
|
||||
check_type(value, self.get_type())
|
||||
# then check if the value is already in the array
|
||||
if self._unique:
|
||||
if value in self._container:
|
||||
raise AssertionError("UNIQUE keyword prevent inserting this instance.")
|
||||
self._container[index-self._bound_1] = value
|
||||
self._container[index - self._bound_1] = value
|
||||
# case unbounded
|
||||
else:
|
||||
if index<self._bound_1:
|
||||
raise IndexError("ARRAY index out of bound (lower bound is %i, passed %i)"%(self._bound_1,index))
|
||||
if index < self._bound_1:
|
||||
raise IndexError(
|
||||
"ARRAY index out of bound (lower bound is %i, passed %i)"
|
||||
% (self._bound_1, index)
|
||||
)
|
||||
# if the _container list is of good size, just do like the bounded case
|
||||
if (index-self._bound_1<len(self._container)):
|
||||
if index - self._bound_1 < len(self._container):
|
||||
# first check the type of the value
|
||||
check_type(value,self.get_type)
|
||||
check_type(value, self.get_type)
|
||||
# then check if the value is already in the array
|
||||
if self._unique:
|
||||
if value in self._container:
|
||||
raise AssertionError("UNIQUE keyword prevent inserting this instance.")
|
||||
self._container[index-self._bound_1] = value
|
||||
self._container[index - self._bound_1] = value
|
||||
# in the other case, we have to extend the base _container list
|
||||
else:
|
||||
delta_size = (index-self._bound_1) - len(self._container) + 1
|
||||
#create a list of None, and extend the list
|
||||
list_extension = delta_size*[None]
|
||||
delta_size = (index - self._bound_1) - len(self._container) + 1
|
||||
# create a list of None, and extend the list
|
||||
list_extension = delta_size * [None]
|
||||
self._container.extend(list_extension)
|
||||
# first check the type of the value
|
||||
check_type(value,self.get_type())
|
||||
check_type(value, self.get_type())
|
||||
# then check if the value is already in the array
|
||||
if self._unique:
|
||||
if value in self._container:
|
||||
raise AssertionError("UNIQUE keyword prevent inserting this instance.")
|
||||
self._container[index-self._bound_1] = value
|
||||
self._container[index - self._bound_1] = value
|
||||
|
||||
|
||||
class BAG(BaseType.Type, BaseType.Aggregate):
|
||||
"""
|
||||
@@ -375,14 +421,14 @@ class BAG(BaseType.Type, BaseType.Aggregate):
|
||||
A bag data type has as its domain unordered collections of like elements. The optional lower
|
||||
and upper bounds, which are integer-valued expressions, define the minimum and maximum
|
||||
number of elements that can be held in the collection defined by a bag data type.
|
||||
|
||||
|
||||
Syntax:
|
||||
170 bag_type = BAG [ bound_spec ] OF base_type .
|
||||
176 bound_spec = '[' bound_1 ':' bound_2 ']' .
|
||||
174 bound_1 = numeric_expression .
|
||||
175 bound_2 = numeric_expression .
|
||||
171 base_type = aggregation_types | simple_types | named_types .
|
||||
|
||||
|
||||
Rules and restrictions:
|
||||
a) The bound_1 expression shall evaluate to an integer value greater than or equal to
|
||||
zero. It gives the lower bound, which is the minimum number of elements that can be in a
|
||||
@@ -402,24 +448,25 @@ class BAG(BaseType.Type, BaseType.Aggregate):
|
||||
as in:
|
||||
a_bag_of_points : BAG [1:?] OF point;
|
||||
The value of the attribute named a_bag_of_points now must contain at least one point.
|
||||
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
@TODO
|
||||
"""
|
||||
def __init__( self , bound_1 , bound_2 , base_type , scope = None):
|
||||
|
||||
def __init__(self, bound_1, bound_2, base_type, scope=None):
|
||||
BaseType.Type.__init__(self, base_type, scope)
|
||||
if not type(bound_1)==int:
|
||||
if not type(bound_1) == int:
|
||||
raise TypeError("LIST lower bound must be an integer")
|
||||
# bound_2 can be set to None
|
||||
self._unbounded = False
|
||||
if bound_2 == None:
|
||||
self._unbounded = True
|
||||
elif not type(bound_2)==int:
|
||||
elif not type(bound_2) == int:
|
||||
raise TypeError("LIST upper bound must be an integer")
|
||||
if not bound_1>=0:
|
||||
if not bound_1 >= 0:
|
||||
raise AssertionError("LIST lower bound must be greater of equal to 0")
|
||||
if (type(bound_2)==int and not (bound_1 <= bound_2)):
|
||||
if type(bound_2) == int and not (bound_1 <= bound_2):
|
||||
raise AssertionError("ARRAY lower bound must be less than or equal to upper bound")
|
||||
# set up class attributes
|
||||
self._bound_1 = bound_1
|
||||
@@ -432,29 +479,29 @@ class BAG(BaseType.Type, BaseType.Aggregate):
|
||||
def bound_2(self):
|
||||
return self._bound_2
|
||||
|
||||
def add(self,value):
|
||||
'''
|
||||
def add(self, value):
|
||||
"""
|
||||
Adds a value to the bag
|
||||
'''
|
||||
"""
|
||||
if self._unbounded:
|
||||
check_type(value,self.get_type())
|
||||
check_type(value, self.get_type())
|
||||
self._container.append(value)
|
||||
else:
|
||||
# first ensure that the bag is not full
|
||||
if len(self._container) == self._bound_2 - self._bound_1 + 1:
|
||||
raise AssertionError('BAG is full. Impossible to add any more item')
|
||||
raise AssertionError("BAG is full. Impossible to add any more item")
|
||||
else:
|
||||
check_type(value,self.get_type())
|
||||
check_type(value, self.get_type())
|
||||
self._container.append(value)
|
||||
|
||||
def get_size(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
"""When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value."""
|
||||
return INTEGER(len(self._container))
|
||||
|
||||
|
||||
def get_hiindex(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
"""When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value."""
|
||||
return INTEGER(len(self._container))
|
||||
|
||||
def get_loindex(self):
|
||||
@@ -462,23 +509,24 @@ class BAG(BaseType.Type, BaseType.Aggregate):
|
||||
|
||||
def get_hibound(self):
|
||||
hibound = self._bound_2
|
||||
if type(hibound)==int:
|
||||
if type(hibound) == int:
|
||||
return INTEGER(hibound)
|
||||
else:
|
||||
return hibound
|
||||
|
||||
def get_lobound(self):
|
||||
lobound = self._bound_1
|
||||
if type(lobound)==int:
|
||||
if type(lobound) == int:
|
||||
return INTEGER(lobound)
|
||||
else:
|
||||
return lobound
|
||||
|
||||
def get_value_unique(self):
|
||||
''' Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise'''
|
||||
"""Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise"""
|
||||
if None in self._container:
|
||||
return Unknown
|
||||
if self.get_size()-len(set(self._container))>0: #some items are repeated
|
||||
if self.get_size() - len(set(self._container)) > 0: # some items are repeated
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@@ -520,24 +568,25 @@ class SET(BaseType.Type, BaseType.Aggregate):
|
||||
as in:
|
||||
a_set_of_points : SET [0:15] OF point;
|
||||
The value of the attribute named a_set_of_points now may contain no more than 15 points.
|
||||
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
The difference with the BAG class is that the base container for SET is a set object.
|
||||
"""
|
||||
def __init__( self , bound_1 , bound_2 , base_type , scope = None):
|
||||
|
||||
def __init__(self, bound_1, bound_2, base_type, scope=None):
|
||||
BaseType.Type.__init__(self, base_type, scope)
|
||||
if not type(bound_1)==int:
|
||||
if not type(bound_1) == int:
|
||||
raise TypeError("LIST lower bound must be an integer")
|
||||
# bound_2 can be set to None
|
||||
self._unbounded = False
|
||||
if bound_2 == None:
|
||||
self._unbounded = True
|
||||
elif not type(bound_2)==int:
|
||||
elif not type(bound_2) == int:
|
||||
raise TypeError("LIST upper bound must be an integer")
|
||||
if not bound_1>=0:
|
||||
if not bound_1 >= 0:
|
||||
raise AssertionError("LIST lower bound must be greater of equal to 0")
|
||||
if (type(bound_2)==int and not (bound_1 <= bound_2)):
|
||||
if type(bound_2) == int and not (bound_1 <= bound_2):
|
||||
raise AssertionError("ARRAY lower bound must be less than or equal to upper bound")
|
||||
# set up class attributes
|
||||
self._bound_1 = bound_1
|
||||
@@ -550,30 +599,30 @@ class SET(BaseType.Type, BaseType.Aggregate):
|
||||
def bound_2(self):
|
||||
return self._bound_2
|
||||
|
||||
def add(self,value):
|
||||
'''
|
||||
def add(self, value):
|
||||
"""
|
||||
Adds a value to the bag
|
||||
'''
|
||||
"""
|
||||
if self._unbounded:
|
||||
check_type(value,self.get_type())
|
||||
check_type(value, self.get_type())
|
||||
self._container.add(value)
|
||||
else:
|
||||
# first ensure that the bag is not full
|
||||
if len(self._container) == self._bound_2 - self._bound_1 + 1:
|
||||
if not value in self._container:
|
||||
raise AssertionError('SET is full. Impossible to add any more item')
|
||||
raise AssertionError("SET is full. Impossible to add any more item")
|
||||
else:
|
||||
check_type(value,self.get_type())
|
||||
check_type(value, self.get_type())
|
||||
self._container.add(value)
|
||||
|
||||
|
||||
def get_size(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
"""When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value."""
|
||||
return INTEGER(len(self._container))
|
||||
|
||||
|
||||
def get_hiindex(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
"""When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value."""
|
||||
return INTEGER(len(self._container))
|
||||
|
||||
def get_loindex(self):
|
||||
@@ -581,21 +630,21 @@ class SET(BaseType.Type, BaseType.Aggregate):
|
||||
|
||||
def get_hibound(self):
|
||||
hibound = self._bound_2
|
||||
if type(hibound)==int:
|
||||
if type(hibound) == int:
|
||||
return INTEGER(hibound)
|
||||
else:
|
||||
return hibound
|
||||
|
||||
def get_lobound(self):
|
||||
lobound = self._bound_1
|
||||
if type(lobound)==int:
|
||||
if type(lobound) == int:
|
||||
return INTEGER(lobound)
|
||||
else:
|
||||
return lobound
|
||||
|
||||
|
||||
def get_value_unique(self):
|
||||
''' Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise'''
|
||||
"""Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise"""
|
||||
if None in self._container:
|
||||
return Unknown
|
||||
else:
|
||||
|
||||
@@ -23,47 +23,54 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
class Type(object):
|
||||
'''
|
||||
"""
|
||||
A type can be defined from its name and scope
|
||||
Looking into the scope dict returns the python type class.
|
||||
This is the base class for aggregated data types or constructed data types
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self, typedef, scope):
|
||||
self._scope = scope
|
||||
self._typedef = typedef
|
||||
|
||||
|
||||
def get_scope(self):
|
||||
return self._scope
|
||||
|
||||
|
||||
def get_type(self):
|
||||
if type(self._typedef) == str:
|
||||
if self._scope == None:
|
||||
raise AssertionError('No scope defined for this type')
|
||||
raise AssertionError("No scope defined for this type")
|
||||
elif self._typedef in vars(self._scope):
|
||||
return vars(self._scope)[self._typedef]
|
||||
else:
|
||||
raise TypeError("Type '%s' is not defined in given scope"%self._typedef)
|
||||
raise TypeError("Type '%s' is not defined in given scope" % self._typedef)
|
||||
else:
|
||||
return self._typedef
|
||||
|
||||
|
||||
class Aggregate:
|
||||
'''
|
||||
"""
|
||||
This is an abstract class. ARRAY, LIST, SET and BAG inherit from this class
|
||||
'''
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
scp = sys.modules[__name__]
|
||||
|
||||
class line:
|
||||
pass
|
||||
new_type = Type('lie',scp)
|
||||
|
||||
new_type = Type("lie", scp)
|
||||
print(new_type.get_type())
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
@@ -32,6 +32,7 @@
|
||||
import sys
|
||||
import BaseType
|
||||
|
||||
|
||||
class EnumerationId(object):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
@@ -40,15 +41,17 @@ class EnumerationId(object):
|
||||
values of the enumeration data type. These names are designated by enumeration_ids and are
|
||||
referred to as enumeration items.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class ENUMERATION(object):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
===================
|
||||
An ENUMERATION data type has as its domain an ordered set of names. The names represent
|
||||
values of the enumeration data type.
|
||||
|
||||
|
||||
Python implementation:
|
||||
======================
|
||||
An enumeration is initialized from strings defining the types.
|
||||
@@ -57,21 +60,22 @@ class ENUMERATION(object):
|
||||
(ahead,
|
||||
behind);
|
||||
END_TYPE; -- ahead_or_behind
|
||||
|
||||
|
||||
is implemented in python with the line:
|
||||
>>> ahead_of_behind = ENUMERATION('ahead','behind', the_current_scope)
|
||||
>>> ahead_or_behind.ahead
|
||||
>>> ahead_of_behind.behind
|
||||
|
||||
|
||||
And, if and only if ahead and/or behind are not in scope (e.g. they are not entity names,
|
||||
and/or many enums define the same enumeration identifier):
|
||||
>>> ahead
|
||||
>>> behind
|
||||
"""
|
||||
def __init__(self,*kargs,**args):
|
||||
|
||||
def __init__(self, *kargs, **args):
|
||||
# first defining the scope
|
||||
if 'scope' in args:
|
||||
self._scope = args['scope']
|
||||
if "scope" in args:
|
||||
self._scope = args["scope"]
|
||||
else:
|
||||
self._scope = None
|
||||
# store passed enum identifiers
|
||||
@@ -82,14 +86,14 @@ class ENUMERATION(object):
|
||||
# we create an attribute ahead with which is a new
|
||||
# instance of EnumerationId
|
||||
for enum_id_name in self._enum_id_names:
|
||||
setattr(self,enum_id_name,EnumerationId())
|
||||
setattr(self, enum_id_name, EnumerationId())
|
||||
# we store this new attributes to the enum_ids list, which
|
||||
# will be accessed by the type checker with the get_enum_ids method
|
||||
self._enum_ids.append(self.__getattribute__(enum_id_name))
|
||||
#
|
||||
# Then we check if the enums names can be added to the current scope:
|
||||
# if the name is already in the scope, then another enums id or select
|
||||
# has the same name -> we do nothing, enums will be called
|
||||
# has the same name -> we do nothing, enums will be called
|
||||
# with ahead_of_behind.ahead or ahead_or_behind.behind.
|
||||
# otherwise, they can be called as only ahead or behind
|
||||
# Note: since ENUMERATIONS are defined *before* entities, if an entity
|
||||
@@ -101,24 +105,26 @@ class ENUMERATION(object):
|
||||
|
||||
def get_enum_ids(self):
|
||||
return self._enum_ids
|
||||
|
||||
|
||||
|
||||
class SELECT(object):
|
||||
""" A select data type has as its domain the union of the domains of the named data types in
|
||||
"""A select data type has as its domain the union of the domains of the named data types in
|
||||
its select list. The select data type is a generalization of each of the named data types in its
|
||||
select list.
|
||||
"""
|
||||
def __init__(self,*kargs,**args):
|
||||
|
||||
def __init__(self, *kargs, **args):
|
||||
# first defining the scope
|
||||
if 'scope' in args:
|
||||
self._scope = args['scope']
|
||||
if "scope" in args:
|
||||
self._scope = args["scope"]
|
||||
else:
|
||||
self._scope = None
|
||||
# create the types from the list of arguments
|
||||
self._base_types = []
|
||||
for types in list(kargs):
|
||||
new_type = BaseType.Type(types,self._scope)
|
||||
new_type = BaseType.Type(types, self._scope)
|
||||
self._base_types.append(new_type)
|
||||
|
||||
|
||||
def get_allowed_types(self):
|
||||
_auth_types = []
|
||||
for types in self._base_types:
|
||||
@@ -126,12 +132,12 @@ class SELECT(object):
|
||||
return _auth_types
|
||||
|
||||
def get_allowed_basic_types(self):
|
||||
''' if a select contains some subselect, goes down through the different
|
||||
sublayers until there is no more '''
|
||||
"""if a select contains some subselect, goes down through the different
|
||||
sublayers until there is no more"""
|
||||
b = []
|
||||
_auth_types = self.get_allowed_types()
|
||||
for _auth_type in _auth_types:
|
||||
if isinstance(_auth_type,SELECT) or isinstance(_auth_type,ENUMERATION):
|
||||
if isinstance(_auth_type, SELECT) or isinstance(_auth_type, ENUMERATION):
|
||||
h = _auth_type.get_allowed_types()
|
||||
b.extend(h)
|
||||
else:
|
||||
|
||||
@@ -23,33 +23,31 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
class Model(objet):
|
||||
""" The container for entity instances
|
||||
"""
|
||||
"""The container for entity instances"""
|
||||
|
||||
def __init_(self):
|
||||
print("Model initialized")
|
||||
self._instances = []
|
||||
|
||||
|
||||
def add_instance(self, entity_instance):
|
||||
self._instances.append(entity_instance)
|
||||
|
||||
|
||||
def remove_instance(self, entity_instance):
|
||||
self._instances.remove(entity_instance)
|
||||
|
||||
|
||||
def get_instances(self):
|
||||
return self._instances
|
||||
|
||||
|
||||
def export_to_p21file(self, filename):
|
||||
raise AssertionError("Not implemented")
|
||||
|
||||
|
||||
def export_to_p28file(self, filename):
|
||||
raise AssertionError("Not implemented")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,19 +36,21 @@ import time
|
||||
|
||||
INSTANCE_DEFINITION_RE = re.compile("#(\d+)[^\S\n]?=[^\S\n]?(.*?)\((.*)\)[^\S\n]?;[\\r]?$")
|
||||
|
||||
|
||||
def map_string_to_num(stri):
|
||||
""" Take a string, check whether it is an integer, a float or not
|
||||
"""
|
||||
if ('.' in stri) or ('E' in stri): #it's definitely a float
|
||||
"""Take a string, check whether it is an integer, a float or not"""
|
||||
if ("." in stri) or ("E" in stri): # it's definitely a float
|
||||
return REAL(stri)
|
||||
else:
|
||||
return INTEGER(stri)
|
||||
|
||||
|
||||
class Model:
|
||||
"""
|
||||
A model contains a list of instances
|
||||
"""
|
||||
def __init__(self,name):
|
||||
|
||||
def __init__(self, name):
|
||||
self._name = name
|
||||
# a dict of instances
|
||||
# each time an instance is added to the model, count is incremented
|
||||
@@ -56,21 +58,22 @@ class Model:
|
||||
self._number_of_instances = 0
|
||||
|
||||
def add_instance(self, instance):
|
||||
'''
|
||||
"""
|
||||
Adds an instance to the model
|
||||
'''
|
||||
"""
|
||||
self._number_of_instances += 1
|
||||
self._instances[self._number_of_instances-1] = instance
|
||||
self._instances[self._number_of_instances - 1] = instance
|
||||
|
||||
def print_instances(self):
|
||||
'''
|
||||
"""
|
||||
Dump instances to stdout
|
||||
'''
|
||||
"""
|
||||
for idx in range(self._number_of_instances):
|
||||
"=========="
|
||||
print("Instance #%i"%(idx+1))
|
||||
print("Instance #%i" % (idx + 1))
|
||||
print(self._instances[idx])
|
||||
|
||||
|
||||
class Part21EntityInstance:
|
||||
"""
|
||||
A class to represent a Part21 instance as defined in one Part21 file
|
||||
@@ -83,7 +86,8 @@ class Part21EntityInstance:
|
||||
entity : <class 'config_control_design.product_definition_shape'>
|
||||
entity_instance_attributes: ['$','$','#5']
|
||||
"""
|
||||
def __init__(self,entity_name,attributes):
|
||||
|
||||
def __init__(self, entity_name, attributes):
|
||||
self._entity
|
||||
self._attributes_definition = attributes
|
||||
print(self._entity_name)
|
||||
@@ -98,6 +102,7 @@ class Part21Parser:
|
||||
self._number_of_ancestors : stores the number of ancestors of entity id. This enables
|
||||
to define the order of instances creation.
|
||||
"""
|
||||
|
||||
def __init__(self, filename):
|
||||
self._filename = filename
|
||||
# the schema
|
||||
@@ -106,12 +111,12 @@ class Part21Parser:
|
||||
self._instances_definition = {}
|
||||
# this dict contains lists of 0 ancestors, 1 ancestor, etc.
|
||||
# initializes this dict
|
||||
#self._number_of_ancestors = {} # this kind of sorting don't work on non-trivial files
|
||||
#for i in range(2000):
|
||||
# self._number_of_ancestors = {} # this kind of sorting don't work on non-trivial files
|
||||
# for i in range(2000):
|
||||
# self._number_of_ancestors[i]=[]
|
||||
self.parse_file()
|
||||
# reduce number_of_ancestors dict
|
||||
#for item in self._number_of_ancestors.keys():
|
||||
# for item in self._number_of_ancestors.keys():
|
||||
# if len(self._number_of_ancestors[item])==0:
|
||||
# del self._number_of_ancestors[item]
|
||||
|
||||
@@ -124,7 +129,7 @@ class Part21Parser:
|
||||
|
||||
def parse_file(self):
|
||||
init_time = time.time()
|
||||
print("Parsing file %s..."%self._filename)
|
||||
print("Parsing file %s..." % self._filename)
|
||||
fp = open(self._filename)
|
||||
while True:
|
||||
line = fp.readline()
|
||||
@@ -132,31 +137,32 @@ class Part21Parser:
|
||||
break
|
||||
# there may be a multiline definition. In this case, we read lines until we found
|
||||
# a ;
|
||||
while (line.find(';') == -1): #it's a multiline
|
||||
line = line.replace("\n","").replace("\r","") + fp.readline()
|
||||
while line.find(";") == -1: # it's a multiline
|
||||
line = line.replace("\n", "").replace("\r", "") + fp.readline()
|
||||
# parse line
|
||||
match_instance_definition = INSTANCE_DEFINITION_RE.search(line) # id,name,attrs
|
||||
if match_instance_definition:
|
||||
instance_id, entity_name, entity_attrs = match_instance_definition.groups()
|
||||
instance_int_id = int(instance_id)
|
||||
# find number of ancestors
|
||||
#number_of_ancestors = entity_attrs.count('#')
|
||||
# number_of_ancestors = entity_attrs.count('#')
|
||||
# fill number of ancestors dict
|
||||
#self._number_of_ancestors[number_of_ancestors].append(instance_int_id) # this kind of sorting don't work on non-trivial files
|
||||
# self._number_of_ancestors[number_of_ancestors].append(instance_int_id) # this kind of sorting don't work on non-trivial files
|
||||
# parse attributes string
|
||||
entity_attrs_list, str_len = Utils.process_nested_parent_str(entity_attrs)
|
||||
# then finally append this instance to the disct instance
|
||||
self._instances_definition[instance_int_id] = (entity_name,entity_attrs_list)
|
||||
else: #does not match with entity instance definition, parse the header
|
||||
if line.startswith('FILE_SCHEMA'):
|
||||
#identify the schema name
|
||||
self._instances_definition[instance_int_id] = (entity_name, entity_attrs_list)
|
||||
else: # does not match with entity instance definition, parse the header
|
||||
if line.startswith("FILE_SCHEMA"):
|
||||
# identify the schema name
|
||||
self._schema_name = line.split("'")[1].split("'")[0].split(" ")[0].lower()
|
||||
fp.close()
|
||||
print('done in %fs.'%(time.time()-init_time))
|
||||
print('schema: - %s entities %i'%(self._schema_name,len(self._instances_definition)))
|
||||
print("done in %fs." % (time.time() - init_time))
|
||||
print("schema: - %s entities %i" % (self._schema_name, len(self._instances_definition)))
|
||||
|
||||
|
||||
class EntityInstancesFactory(object):
|
||||
'''
|
||||
"""
|
||||
This class creates entity instances from the str definition
|
||||
For instance, the definition:
|
||||
20: ('CARTESIAN_POINT', ["''", '(5.,125.,20.)'])
|
||||
@@ -166,44 +172,48 @@ class EntityInstancesFactory(object):
|
||||
p.[2] = REAL(125)
|
||||
p.[3] = REAL(20)
|
||||
new_instance = cartesian_point(STRING(''),p)
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self, schema_name, instance_definition):
|
||||
# First try to import the schema module
|
||||
pass
|
||||
|
||||
|
||||
class Part21Population(object):
|
||||
def __init__(self, part21_loader):
|
||||
""" Take a part21_loader a tries to create entities
|
||||
"""
|
||||
"""Take a part21_loader a tries to create entities"""
|
||||
self._part21_loader = part21_loader
|
||||
self._aggregate_scope = []
|
||||
self._aggr_scope = False
|
||||
self.create_entity_instances()
|
||||
|
||||
def create_entity_instances(self):
|
||||
""" Starts entity instances creation
|
||||
"""
|
||||
"""Starts entity instances creation"""
|
||||
for number_of_ancestor in list(self._part21_loader._number_of_ancestors):
|
||||
for entity_definition_id in self._part21_loader._number_of_ancestors[number_of_ancestor]:
|
||||
for entity_definition_id in self._part21_loader._number_of_ancestors[
|
||||
number_of_ancestor
|
||||
]:
|
||||
self.create_entity_instance(entity_definition_id)
|
||||
|
||||
def create_entity_instance(self, instance_id):
|
||||
instance_definition = self._part21_loader._instances_definition[instance_id]
|
||||
print("Instance definition to process",instance_definition)
|
||||
print("Instance definition to process", instance_definition)
|
||||
# first find class name
|
||||
class_name = instance_definition[0].lower()
|
||||
print("Class name:%s"%class_name)
|
||||
print("Class name:%s" % class_name)
|
||||
object_ = globals()[class_name]
|
||||
# then attributes
|
||||
#print object_.__doc__
|
||||
# print object_.__doc__
|
||||
instance_attributes = instance_definition[1]
|
||||
print("instance_attributes:",instance_attributes)
|
||||
print("instance_attributes:", instance_attributes)
|
||||
a = object_(*instance_attributes)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import time
|
||||
import sys
|
||||
from config_control_design import *
|
||||
|
||||
p21loader = Part21Parser("gasket1.p21")
|
||||
print("Creating instances")
|
||||
p21population = Part21Population(p21loader)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
@@ -31,9 +31,11 @@
|
||||
|
||||
__doc__ = "This module defines EXPRESS rules"
|
||||
|
||||
|
||||
class Rule(object):
|
||||
'''
|
||||
"""
|
||||
This class describes a RULE
|
||||
@TODO: to be implemented
|
||||
'''
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
@@ -23,22 +23,25 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
class BaseEntityClass(object):
|
||||
""" A class that allows advanced __repr__ features for entity instances
|
||||
"""
|
||||
"""A class that allows advanced __repr__ features for entity instances"""
|
||||
|
||||
def __repr__(self):
|
||||
""" Displays attribute with their values
|
||||
"""
|
||||
doc_string = "# %s class description:\n%s\n# Instance attributes:\n"%(self.__class__,self.__doc__)
|
||||
"""Displays attribute with their values"""
|
||||
doc_string = "# %s class description:\n%s\n# Instance attributes:\n" % (
|
||||
self.__class__,
|
||||
self.__doc__,
|
||||
)
|
||||
# write each argument with its value
|
||||
properties = dir(self)
|
||||
for elem in properties:
|
||||
if not elem.startswith("_"):
|
||||
doc_string += "\t%s:%s\n"%(elem,self.__getattribute__(elem))
|
||||
doc_string += "\t%s:%s\n" % (elem, self.__getattribute__(elem))
|
||||
return doc_string
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
@@ -33,6 +33,7 @@
|
||||
Docstrings are courtesy of ISO 10303-11:1994(E)
|
||||
"""
|
||||
|
||||
|
||||
class NUMBER:
|
||||
"""
|
||||
EXPRESS definition:
|
||||
@@ -45,14 +46,16 @@ class NUMBER:
|
||||
represent it, e.g. the size of the crowd at a football game would be an integer, whereas the area
|
||||
of the pitch would be a real.
|
||||
size : NUMBER ;
|
||||
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
class NUMBER is an abstract class, aimed at being specialized.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
class REAL(float,NUMBER):
|
||||
|
||||
|
||||
class REAL(float, NUMBER):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
===================
|
||||
@@ -73,17 +76,19 @@ class REAL(float,NUMBER):
|
||||
quired. This expression shall evaluate to a positive integer value.
|
||||
b) When no resolution specification is given the precision of the real number is uncon-
|
||||
strained.
|
||||
|
||||
|
||||
Note 9.2.6:
|
||||
integer and real are both specializations of number;
|
||||
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
REAL both inherits from float and NUMBER
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
class INTEGER(int,NUMBER):
|
||||
|
||||
class INTEGER(int, NUMBER):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
===================
|
||||
@@ -96,17 +101,19 @@ class INTEGER(int,NUMBER):
|
||||
ENTITY foo;
|
||||
nodes : INTEGER;
|
||||
END_ENTITY;
|
||||
|
||||
|
||||
Note 9.2.6: integer and real are both specializations of number;
|
||||
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
INTEGER both inherits from int and NUMBER
|
||||
|
||||
|
||||
@TODO: note 9.2.6 tells that integer is a specialization of real
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class STRING(str):
|
||||
"""
|
||||
The string data type has as its domain sequences of characters. The characters which are
|
||||
@@ -118,7 +125,7 @@ class STRING(str):
|
||||
A string data type may be defined as either fixed or varying width (number of characters). If
|
||||
it is not specfically defined as fixed width (by using the fixed reserved word in the dfinition)
|
||||
the string has varying width.
|
||||
|
||||
|
||||
The domain of a fixed width string data type is the set of all character sequences of exactly
|
||||
the width specified in the type definition.
|
||||
The domain of a varying width string data type is the set of all character sequences of width
|
||||
@@ -127,12 +134,14 @@ class STRING(str):
|
||||
the width of these sequences.
|
||||
Substrings and individual characters may be addressed using subscripts as described in 12.5.
|
||||
The case (upper or lower) of letters within a string is significant.
|
||||
|
||||
|
||||
Python mapping: INTEGER is mapped the 'str' type. An additional width_spec parameter can be passed
|
||||
to handle the FIXED length constraint
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class LOGICAL:
|
||||
"""
|
||||
The logical data type has as its domain the three literals true, false and unknown.
|
||||
@@ -142,20 +151,24 @@ class LOGICAL:
|
||||
true. The logical data type is compatible with the boolean data type, except that the value
|
||||
unknown cannot be assigned to a boolean variable.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
Unknown = LOGICAL()
|
||||
|
||||
#
|
||||
#The boolean data type has as its domain the two literals true and false. The boolean data
|
||||
#type is a specialization of the logical data type.
|
||||
#
|
||||
#Python mapping: BOOLEAN is mapped to 'bool' type
|
||||
# The boolean data type has as its domain the two literals true and false. The boolean data
|
||||
# type is a specialization of the logical data type.
|
||||
#
|
||||
# Python mapping: BOOLEAN is mapped to 'bool' type
|
||||
#
|
||||
# The bool data type can't however be subclassed in Python (see
|
||||
# See http://mail.python.org/pipermail/python-dev/2002-March/020822.html)
|
||||
# so it is just set to bool
|
||||
BOOLEAN = bool
|
||||
|
||||
|
||||
|
||||
class BINARY(str):
|
||||
"""
|
||||
The binary data type has as its domain sequences of bits, each bit being represented by 0 or 1.
|
||||
@@ -172,45 +185,49 @@ class BINARY(str):
|
||||
than or equal to the maximum width specified in the type definition. If no width is specified,
|
||||
the domain is the set of all bit sequences, with no constraint on the width of these sequences.
|
||||
Subbinaries and individual bits may be addressed using subscripts as described in 12.3.
|
||||
|
||||
|
||||
Python mapping: BINARY is mapped to the 'str' type. A check is performed to validate it is a binary
|
||||
string representing a number.
|
||||
"""
|
||||
|
||||
def __new__(self, value, width=-1, fixed=False):
|
||||
return str.__new__(self, value)
|
||||
|
||||
|
||||
def __init__(self, value, width=-1, fixed=False):
|
||||
""" By default, length is set to None"""
|
||||
"""By default, length is set to None"""
|
||||
self._specified_width = width
|
||||
self._fixed = fixed
|
||||
# Check implicit width
|
||||
if (width!=-1) and not fixed:
|
||||
raise ValueError("The 'width' parameter is passed but 'fixed' is still false. Please explicitly set 'fixed' to True to avoid implicit declaration")
|
||||
if (width != -1) and not fixed:
|
||||
raise ValueError(
|
||||
"The 'width' parameter is passed but 'fixed' is still false. Please explicitly set 'fixed' to True to avoid implicit declaration"
|
||||
)
|
||||
# First check the string length if 'fixed' is set to True
|
||||
if fixed:
|
||||
if len(value) != width:
|
||||
raise ValueError("The BINARY width %i is not consistent with the 'width' declaration(%i)"%(len(value),width))
|
||||
raise ValueError(
|
||||
"The BINARY width %i is not consistent with the 'width' declaration(%i)"
|
||||
% (len(value), width)
|
||||
)
|
||||
# Check that the value passed is actually a binary
|
||||
try:
|
||||
int(value,2)
|
||||
int(value, 2)
|
||||
except ValueError:
|
||||
raise ValueError("%s is not a binary"%value)
|
||||
raise ValueError("%s is not a binary" % value)
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
if __name__ == "__main__":
|
||||
print("Creating REAL from float value")
|
||||
a = REAL(1.5)
|
||||
print(a*2)
|
||||
print(a * 2)
|
||||
print("Creating REAL from string value")
|
||||
a = REAL("1.2")
|
||||
print(a*3)
|
||||
print(a * 3)
|
||||
print("Creating INTEGER from int value")
|
||||
b = INTEGER(2)
|
||||
c = INTEGER(3)
|
||||
print(b+c)
|
||||
print(b + c)
|
||||
print("Creating INTEGER from string value")
|
||||
e = INTEGER("5")
|
||||
f = INTEGER("8")
|
||||
print(e*f)
|
||||
|
||||
|
||||
print(e * f)
|
||||
|
||||
@@ -36,18 +36,16 @@ corresponding classes.
|
||||
In addition it writes out a graphviz file with the entity graph.
|
||||
"""
|
||||
|
||||
import Part21,sys
|
||||
import Part21, sys
|
||||
|
||||
|
||||
|
||||
__title__="Simple Part21 STEP reader"
|
||||
__title__ = "Simple Part21 STEP reader"
|
||||
__author__ = "Juergen Riegel"
|
||||
__version__ = "0.1 (Jan 2014)"
|
||||
|
||||
|
||||
|
||||
class SimpleParser:
|
||||
""" read the file
|
||||
"""read the file
|
||||
|
||||
Part21.Part21Parser Loads all instances definition of a Part21 file into memory.
|
||||
Two dicts are created:
|
||||
@@ -55,117 +53,133 @@ class SimpleParser:
|
||||
Part21.Part21Parser._number_of_ancestors : stores the number of ancestors of entity id. This enables
|
||||
to define the order of instances creation.
|
||||
"""
|
||||
|
||||
def __init__(self, filename):
|
||||
import time
|
||||
import sys
|
||||
|
||||
self._p21loader = Part21.Part21Parser(filename)
|
||||
#self._p21loader._number_of_ancestors = {} # not needed, save memory
|
||||
# self._p21loader._number_of_ancestors = {} # not needed, save memory
|
||||
self.schemaModule = None
|
||||
self.schemaClasses = None
|
||||
self.instanceMape = {}
|
||||
#for i in self._p21loader._instances_definition.keys():
|
||||
# for i in self._p21loader._instances_definition.keys():
|
||||
# print i,self._p21loader._instances_definition[i][0],self._p21loader._instances_definition[i][1]
|
||||
|
||||
def _writeGraphVizEdge(self,num,attrList,file):
|
||||
def _writeGraphVizEdge(self, num, attrList, file):
|
||||
for i in attrList:
|
||||
if isinstance(i,list):
|
||||
self._writeGraphVizEdge(num,i,file)
|
||||
elif isinstance(i,str):
|
||||
if not i == '' and i[0] == '#':
|
||||
if isinstance(i, list):
|
||||
self._writeGraphVizEdge(num, i, file)
|
||||
elif isinstance(i, str):
|
||||
if not i == "" and i[0] == "#":
|
||||
key = int(i[1:])
|
||||
file.write(' '+repr(num)+' -> '+repr(key)+'\n')
|
||||
file.write(" " + repr(num) + " -> " + repr(key) + "\n")
|
||||
|
||||
def writeGraphViz(self, fileName):
|
||||
print("Writing GraphViz file %s..." % fileName)
|
||||
gvFile = open(fileName, "w")
|
||||
|
||||
def writeGraphViz(self,fileName):
|
||||
print("Writing GraphViz file %s..."%fileName)
|
||||
gvFile = open(fileName,'w')
|
||||
|
||||
gvFile.write('digraph G {\n node [fontname=Verdana,fontsize=12]\n node [style=filled]\n node [fillcolor="#EEEEEE"]\n node [color="#EEEEEE"]\n edge [color="#31CEF0"]\n')
|
||||
gvFile.write(
|
||||
'digraph G {\n node [fontname=Verdana,fontsize=12]\n node [style=filled]\n node [fillcolor="#EEEEEE"]\n node [color="#EEEEEE"]\n edge [color="#31CEF0"]\n'
|
||||
)
|
||||
for i in list(self._p21loader._instances_definition):
|
||||
entityStr = '#'+repr(i)
|
||||
nameStr = self._p21loader._instances_definition[i][0].lower()
|
||||
sttrStr = repr(self._p21loader._instances_definition[i][1]).replace('"','').replace("'",'').replace(" ",'')
|
||||
if len (sttrStr) > 40:
|
||||
sttrStr = sttrStr[:39]+'....'
|
||||
gvFile.write(' '+repr(i)+' [label="'+entityStr+'\n'+nameStr+'\n'+sttrStr+'"]\n')
|
||||
self._writeGraphVizEdge( i,self._p21loader._instances_definition[i][1],gvFile)
|
||||
gvFile.write('}\n')
|
||||
entityStr = "#" + repr(i)
|
||||
nameStr = self._p21loader._instances_definition[i][0].lower()
|
||||
sttrStr = (
|
||||
repr(self._p21loader._instances_definition[i][1])
|
||||
.replace('"', "")
|
||||
.replace("'", "")
|
||||
.replace(" ", "")
|
||||
)
|
||||
if len(sttrStr) > 40:
|
||||
sttrStr = sttrStr[:39] + "...."
|
||||
gvFile.write(
|
||||
" " + repr(i) + ' [label="' + entityStr + "\n" + nameStr + "\n" + sttrStr + '"]\n'
|
||||
)
|
||||
self._writeGraphVizEdge(i, self._p21loader._instances_definition[i][1], gvFile)
|
||||
gvFile.write("}\n")
|
||||
|
||||
def instantiate(self):
|
||||
"""Instantiate the python class from the entities"""
|
||||
import inspect
|
||||
|
||||
# load the needed schema module
|
||||
if self._p21loader.get_schema_name() == 'config_control_design':
|
||||
if self._p21loader.get_schema_name() == "config_control_design":
|
||||
import config_control_design
|
||||
|
||||
self.schemaModule = config_control_design
|
||||
if self._p21loader.get_schema_name() == 'automotive_design':
|
||||
if self._p21loader.get_schema_name() == "automotive_design":
|
||||
import automotive_design
|
||||
|
||||
self.schemaModule = automotive_design
|
||||
|
||||
if self.schemaModule:
|
||||
self.schemaClasses = dict(inspect.getmembers(self.schemaModule))
|
||||
|
||||
for i in list(self._p21loader._instances_definition):
|
||||
#print i
|
||||
# print i
|
||||
if i not in self.instanceMape:
|
||||
self._create_entity_instance(i)
|
||||
|
||||
def _create_entity_instance(self, instance_id):
|
||||
if instance_id in self._p21loader._instances_definition:
|
||||
instance_definition = self._p21loader._instances_definition[instance_id]
|
||||
#print "Instance definition to process",instance_definition
|
||||
# print "Instance definition to process",instance_definition
|
||||
# first find class name
|
||||
class_name = instance_definition[0].lower()
|
||||
#print "Class name:%s"%class_name
|
||||
# print "Class name:%s"%class_name
|
||||
|
||||
if not class_name=='':
|
||||
if not class_name == "":
|
||||
classDef = self.schemaClasses[class_name]
|
||||
# then attributes
|
||||
#print object_.__doc__
|
||||
# print object_.__doc__
|
||||
instance_attributes = instance_definition[1]
|
||||
self._transformAttributes(instance_attributes)
|
||||
print('Attribute list after transform: ',instance_attributes)
|
||||
print("Attribute list after transform: ", instance_attributes)
|
||||
|
||||
self.instanceMape[instance_id] = str('dummy#:'+str(instance_id)) # dummy instance to test
|
||||
self.instanceMape[instance_id] = str(
|
||||
"dummy#:" + str(instance_id)
|
||||
) # dummy instance to test
|
||||
else:
|
||||
print('############################# lost entity: ',instance_id)
|
||||
self.instanceMape[instance_id] = int(41) # dummy
|
||||
#print "instance_attributes:",instance_attributes
|
||||
#a = object_(*instance_attributes)
|
||||
print("############################# lost entity: ", instance_id)
|
||||
self.instanceMape[instance_id] = int(41) # dummy
|
||||
# print "instance_attributes:",instance_attributes
|
||||
# a = object_(*instance_attributes)
|
||||
|
||||
def _transformAttributes(self,attrList):
|
||||
def _transformAttributes(self, attrList):
|
||||
n = 0
|
||||
for i in attrList:
|
||||
if isinstance(i,list):
|
||||
if isinstance(i, list):
|
||||
self._transformAttributes(i)
|
||||
elif isinstance(i,str):
|
||||
if i == '':
|
||||
print('empty string')
|
||||
elif i[0] == '#':
|
||||
elif isinstance(i, str):
|
||||
if i == "":
|
||||
print("empty string")
|
||||
elif i[0] == "#":
|
||||
key = int(i[1:])
|
||||
#print 'Item: ',int(i[1:])
|
||||
# print 'Item: ',int(i[1:])
|
||||
if key in self.instanceMape:
|
||||
attrList[n] = self.instanceMape[key]
|
||||
attrList[n] = self.instanceMape[key]
|
||||
else:
|
||||
self._create_entity_instance(key)
|
||||
if key not in self.instanceMape:
|
||||
raise NameError("Needed instance not instantiated: ",key)
|
||||
raise NameError("Needed instance not instantiated: ", key)
|
||||
else:
|
||||
attrList[n] = self.instanceMape[key]
|
||||
elif i[0] == '$':
|
||||
#print 'Dollar'
|
||||
attrList[n] = self.instanceMape[key]
|
||||
elif i[0] == "$":
|
||||
# print 'Dollar'
|
||||
pass
|
||||
elif i[0] == "'":
|
||||
print('Dopelstring: ',i[1:-1])
|
||||
print("Dopelstring: ", i[1:-1])
|
||||
else:
|
||||
print('String: ',i)
|
||||
print("String: ", i)
|
||||
else:
|
||||
raise NameError("Unknown attribute type")
|
||||
n = n+1
|
||||
n = n + 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.path.append('..') # path where config_control_design.py is found
|
||||
parser = SimpleReader("Aufspannung.stp") # simple test file
|
||||
#parser.instantiate()
|
||||
parser.writeGraphViz('TestGrap.gv')
|
||||
#dot.exe -Tsvg -o Test.svg e:\fem-dev\src\Mod\Import\App\SCL\TestGrap-geo.gv
|
||||
sys.path.append("..") # path where config_control_design.py is found
|
||||
parser = SimpleReader("Aufspannung.stp") # simple test file
|
||||
# parser.instantiate()
|
||||
parser.writeGraphViz("TestGrap.gv")
|
||||
# dot.exe -Tsvg -o Test.svg e:\fem-dev\src\Mod\Import\App\SCL\TestGrap-geo.gv
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
@@ -35,67 +35,89 @@ from . import BaseType
|
||||
RAISE_EXCEPTION_IF_TYPE_DOES_NOT_MATCH = True
|
||||
DEBUG = False
|
||||
|
||||
|
||||
def cast_python_object_to_aggregate(obj, aggregate):
|
||||
""" This function casts a python object to an aggregate type. For instance:
|
||||
"""This function casts a python object to an aggregate type. For instance:
|
||||
[1.,2.,3.]-> ARRAY(1,3,REAL)"""
|
||||
aggregate_lower_bound = aggregate.bound_1()
|
||||
aggregate_upper_bound = aggregate.bound_2()
|
||||
if type(obj)==list:
|
||||
for idx in range(aggregate_lower_bound,aggregate_upper_bound+1):
|
||||
aggregate[idx] = obj[idx-aggregate_lower_bound]
|
||||
if type(obj) == list:
|
||||
for idx in range(aggregate_lower_bound, aggregate_upper_bound + 1):
|
||||
aggregate[idx] = obj[idx - aggregate_lower_bound]
|
||||
return aggregate
|
||||
|
||||
|
||||
def check_type(instance, expected_type):
|
||||
""" This function checks whether an object is an instance of a given class
|
||||
"""This function checks whether an object is an instance of a given class
|
||||
returns False or True
|
||||
"""
|
||||
type_match = False #by default, will be set to True if any match
|
||||
type_match = False # by default, will be set to True if any match
|
||||
if DEBUG:
|
||||
print("===")
|
||||
print("Instance passed: ",instance)
|
||||
print("Instance passed: ", instance)
|
||||
print("Expected type: ", expected_type)
|
||||
# in the case of an enumeration, we have to check if the instance is in the list
|
||||
if (isinstance(expected_type,ENUMERATION)):
|
||||
if isinstance(expected_type, ENUMERATION):
|
||||
allowed_ids = expected_type.get_enum_ids()
|
||||
if instance in allowed_ids:
|
||||
type_match = True
|
||||
else:
|
||||
raise TypeError('Enumeration ids must be %s ( passed %s)'%(allowed_ids,type(instance)))
|
||||
elif (isinstance(expected_type,SELECT)):
|
||||
raise TypeError(
|
||||
"Enumeration ids must be %s ( passed %s)" % (allowed_ids, type(instance))
|
||||
)
|
||||
elif isinstance(expected_type, SELECT):
|
||||
# we check if the instance is of the type of any of the types that are in the SELECT
|
||||
allowed_types = expected_type.get_allowed_basic_types()
|
||||
for allowed_type in allowed_types:
|
||||
if isinstance(instance,allowed_type):
|
||||
if isinstance(instance, allowed_type):
|
||||
type_match = True
|
||||
if not type_match:
|
||||
if RAISE_EXCEPTION_IF_TYPE_DOES_NOT_MATCH:
|
||||
raise TypeError('Argument type must be %s (you passed %s)'%(allowed_types,type(instance)))
|
||||
raise TypeError(
|
||||
"Argument type must be %s (you passed %s)" % (allowed_types, type(instance))
|
||||
)
|
||||
else:
|
||||
print("WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"%(allowed_types, type(instance)))
|
||||
print(
|
||||
"WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"
|
||||
% (allowed_types, type(instance))
|
||||
)
|
||||
return False
|
||||
elif (isinstance(expected_type, BaseType.Aggregate)):
|
||||
elif isinstance(expected_type, BaseType.Aggregate):
|
||||
# first check that they are instance of the same class
|
||||
if not (type(instance) == type(expected_type)):
|
||||
raise TypeError('Expected %s but passed %s'%(type(expected_type),type(instance)))
|
||||
raise TypeError("Expected %s but passed %s" % (type(expected_type), type(instance)))
|
||||
# then check that the base type is the same
|
||||
elif not (instance.get_type() == expected_type.get_type()):
|
||||
#print instance.get_type()
|
||||
#print expected_type.get_type()
|
||||
raise TypeError('Expected %s:%s base type but passed %s:%s base type'%(type(expected_type),expected_type.get_type(),type(instance), instance.get_type()))
|
||||
# print instance.get_type()
|
||||
# print expected_type.get_type()
|
||||
raise TypeError(
|
||||
"Expected %s:%s base type but passed %s:%s base type"
|
||||
% (
|
||||
type(expected_type),
|
||||
expected_type.get_type(),
|
||||
type(instance),
|
||||
instance.get_type(),
|
||||
)
|
||||
)
|
||||
# check optional and unique attributes
|
||||
#elif not (instance._unique == expected_type._unique):
|
||||
# elif not (instance._unique == expected_type._unique):
|
||||
# raise TypeError('Aggregate expects UNIQUE:%s property but passed UNIQUE:%s'%(expected_type._unique, instance._unique))
|
||||
#elif not (instance._optional == expected_type._optional):
|
||||
# elif not (instance._optional == expected_type._optional):
|
||||
# raise TypeError('Aggregate expects OPTIONAL:%s property but passed OPTIONAL:%s'%(expected_type._optional, instance._optional))
|
||||
# @TODO: check aggregate bounds
|
||||
else:
|
||||
type_match = True
|
||||
else: # simple data types
|
||||
type_match = isinstance(instance,expected_type)
|
||||
else: # simple data types
|
||||
type_match = isinstance(instance, expected_type)
|
||||
if not type_match:
|
||||
if RAISE_EXCEPTION_IF_TYPE_DOES_NOT_MATCH:
|
||||
raise TypeError('Argument type must be %s (you passed %s)'%(expected_type,type(instance)))
|
||||
raise TypeError(
|
||||
"Argument type must be %s (you passed %s)" % (expected_type, type(instance))
|
||||
)
|
||||
else:
|
||||
print("WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"%(expected_type, type(instance)))
|
||||
print(
|
||||
"WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"
|
||||
% (expected_type, type(instance))
|
||||
)
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -23,48 +23,47 @@
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
''' This module provide string utils'''
|
||||
""" This module provide string utils"""
|
||||
|
||||
def process_nested_parent_str(attr_str,idx=0):
|
||||
'''
|
||||
|
||||
def process_nested_parent_str(attr_str, idx=0):
|
||||
"""
|
||||
The first letter should be a parenthesis
|
||||
input string: "(1,4,(5,6),7)"
|
||||
output: ['1','4',['5','6'],'7']
|
||||
'''
|
||||
"""
|
||||
params = []
|
||||
current_param = ''
|
||||
current_param = ""
|
||||
k = 0
|
||||
while (k<len(attr_str)):
|
||||
while k < len(attr_str):
|
||||
ch = attr_str[k]
|
||||
k += 1
|
||||
if ch==',':
|
||||
if ch == ",":
|
||||
params.append(current_param)
|
||||
current_param = ''
|
||||
elif ch=='(':
|
||||
current_param = ""
|
||||
elif ch == "(":
|
||||
nv = attr_str[k:]
|
||||
current_param, progress = process_nested_parent_str(nv)
|
||||
params.append(current_param)
|
||||
current_param = ''
|
||||
k += progress+1
|
||||
elif ch==')':
|
||||
current_param = ""
|
||||
k += progress + 1
|
||||
elif ch == ")":
|
||||
params.append(current_param)
|
||||
return params,k
|
||||
return params, k
|
||||
else:
|
||||
current_param += ch
|
||||
params.append(current_param)
|
||||
return params,k
|
||||
return params, k
|
||||
|
||||
if __name__=="__main__":
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(process_nested_parent_str2("'A'")[0])
|
||||
print(process_nested_parent_str2("30.0,0.0,5.0")[0])
|
||||
print(process_nested_parent_str2("1,2,(3,4,5),6,7,8")[0])
|
||||
print(process_nested_parent_str2("(#9149,#9166),#9142,.T.")[0])
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1 +1,10 @@
|
||||
__all__ = ['SCLBase','SimpleDataTypes','AggregationDataTypes','TypeChecker','ConstructedDataTypes','Expr','Part21','SimpleParser']
|
||||
__all__ = [
|
||||
"SCLBase",
|
||||
"SimpleDataTypes",
|
||||
"AggregationDataTypes",
|
||||
"TypeChecker",
|
||||
"ConstructedDataTypes",
|
||||
"Expr",
|
||||
"Part21",
|
||||
"SimpleParser",
|
||||
]
|
||||
|
||||
@@ -1,74 +1,74 @@
|
||||
def process_nested_parent_str(attr_str):
|
||||
'''
|
||||
"""
|
||||
The first letter should be a parenthesis
|
||||
input string: "(1,4,(5,6),7)"
|
||||
output: tuple (1,4,(4,6),7)
|
||||
'''
|
||||
"""
|
||||
params = []
|
||||
agg_scope_level = 0
|
||||
current_param = ''
|
||||
for i,ch in enumerate(attr_str):
|
||||
if ch==',':
|
||||
current_param = ""
|
||||
for i, ch in enumerate(attr_str):
|
||||
if ch == ",":
|
||||
params.append(current_param)
|
||||
current_param = ''
|
||||
elif ch=='(':
|
||||
agg_scope_level +=1
|
||||
elif ch==')':
|
||||
current_param = ""
|
||||
elif ch == "(":
|
||||
agg_scope_level += 1
|
||||
elif ch == ")":
|
||||
agg_scope_level = 0
|
||||
elif agg_scope_level == 0:
|
||||
current_param += ch
|
||||
return params
|
||||
|
||||
def process_nested_parent_str2(attr_str,idx=0):
|
||||
'''
|
||||
|
||||
def process_nested_parent_str2(attr_str, idx=0):
|
||||
"""
|
||||
The first letter should be a parenthesis
|
||||
input string: "(1,4,(5,6),7)"
|
||||
output: ['1','4',['5','6'],'7']
|
||||
'''
|
||||
#print 'Entering function with string %s'%(attr_str)
|
||||
"""
|
||||
# print 'Entering function with string %s'%(attr_str)
|
||||
params = []
|
||||
current_param = ''
|
||||
current_param = ""
|
||||
k = 0
|
||||
while (k<len(attr_str)):
|
||||
#print 'k in this function:%i'%k
|
||||
while k < len(attr_str):
|
||||
# print 'k in this function:%i'%k
|
||||
ch = attr_str[k]
|
||||
k += 1
|
||||
if ch==',':
|
||||
#print "Add param:",current_param
|
||||
if ch == ",":
|
||||
# print "Add param:",current_param
|
||||
params.append(current_param)
|
||||
current_param = ''
|
||||
elif ch=='(':
|
||||
current_param = ""
|
||||
elif ch == "(":
|
||||
nv = attr_str[k:]
|
||||
#print "Up one level parenthesis:%s"%(nv)
|
||||
# print "Up one level parenthesis:%s"%(nv)
|
||||
current_param, progress = process_nested_parent_str2(nv)
|
||||
#print "Adding the list returned from nested",current_param
|
||||
# print "Adding the list returned from nested",current_param
|
||||
params.append(current_param)
|
||||
current_param = ''
|
||||
k += progress+1
|
||||
elif ch==')':
|
||||
#print "Down one level parenthesis: %i characters parsed"%k
|
||||
current_param = ""
|
||||
k += progress + 1
|
||||
elif ch == ")":
|
||||
# print "Down one level parenthesis: %i characters parsed"%k
|
||||
params.append(current_param)
|
||||
#print "Current params:",params#k -= acc-2
|
||||
return params,k
|
||||
# print "Current params:",params#k -= acc-2
|
||||
return params, k
|
||||
else:
|
||||
current_param += ch
|
||||
#print "Ch:",ch
|
||||
#print "k:",k
|
||||
|
||||
#raw_input("")
|
||||
#idx += 1
|
||||
|
||||
# print "Ch:",ch
|
||||
# print "k:",k
|
||||
|
||||
# raw_input("")
|
||||
# idx += 1
|
||||
|
||||
params.append(current_param)
|
||||
return params,k
|
||||
#print process_nested_parent_str2('1,2,3,4,5,6')
|
||||
#idx=0
|
||||
#print process_nested_parent_str2("'A','B','C'")
|
||||
return params, k
|
||||
|
||||
|
||||
# print process_nested_parent_str2('1,2,3,4,5,6')
|
||||
# idx=0
|
||||
# print process_nested_parent_str2("'A','B','C'")
|
||||
print(process_nested_parent_str2("'A'")[0])
|
||||
print(process_nested_parent_str2("30.0,0.0,5.0")[0])
|
||||
print(process_nested_parent_str2("(Thomas)")[0])
|
||||
print(process_nested_parent_str2("Thomas, Paviot, ouais")[0])
|
||||
print(process_nested_parent_str2("1,2,(3,4,5),6,7,8")[0])
|
||||
print(process_nested_parent_str2("(#9149,#9166),#9142,.T.")[0])
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -217,4 +217,4 @@ DATA;
|
||||
REPRESENTATION_CONTEXT('CONTEXT for advanced brep test case gasket','This is a 3d context using millimeters for linear dimension'));
|
||||
#9240 = ADVANCED_BREP_SHAPE_REPRESENTATION('ABShapeRep1',(#9220),#9230);
|
||||
ENDSEC;
|
||||
END-ISO-10303-21;
|
||||
END-ISO-10303-21;
|
||||
|
||||
@@ -39689,7 +39689,7 @@ def get_name_value(obj,):
|
||||
if (SIZEOF(name_bag) == 1):
|
||||
return name_bag[1].attribute_value
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION validate_countersink_radii #
|
||||
@@ -40036,7 +40036,7 @@ def shell_reversed(a_shell,):
|
||||
if ('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF.CLOSED_SHELL' == TYPEOF(a_shell)):
|
||||
return closed_shell_reversed(a_shell)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION topology_reversed #
|
||||
@@ -40060,7 +40060,7 @@ def topology_reversed(an_item,):
|
||||
return set_of_topology_reversed(an_item)
|
||||
if ('LIST' == TYPEOF(an_item)):
|
||||
return list_of_topology_reversed(an_item)
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION first_proj_axis #
|
||||
@@ -40073,7 +40073,7 @@ def first_proj_axis(z_axis,arg,):
|
||||
:type arg:direction
|
||||
'''
|
||||
if ( not EXISTS(z_axis)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
z = normalise(z_axis)
|
||||
if ( not EXISTS(arg)):
|
||||
@@ -40083,9 +40083,9 @@ def first_proj_axis(z_axis,arg,):
|
||||
v = dummy_gri == direction([0,1,0])
|
||||
else:
|
||||
if (arg.dim != 3):
|
||||
return None
|
||||
return None
|
||||
if (cross_product(arg,z).magnitude == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
v = normalise(arg)
|
||||
x_vec = scalar_times_vector(dot_product(v,z),z)
|
||||
@@ -40145,7 +40145,7 @@ def orthogonal_complement(vec,):
|
||||
:type vec:direction
|
||||
'''
|
||||
if ((vec.dim != 2) or ( not EXISTS(vec))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
result = dummy_gri == direction([-vec.direction_ratios[2],vec.direction_ratios[1]])
|
||||
return result
|
||||
@@ -40187,13 +40187,13 @@ def make_array_of_array(lis,low1,u1,low2,u2,):
|
||||
:type u2:INTEGER
|
||||
'''
|
||||
if (((u1 - low1) + 1) != SIZEOF(lis)):
|
||||
return None
|
||||
return None
|
||||
if (((u2 - low2) + 1) != SIZEOF(lis[1])):
|
||||
return None
|
||||
return None
|
||||
res = [list_to_array(lis[1],low2,u2),(u1 - low1) + 1]
|
||||
for i in range(2,HIINDEX(lis),1):
|
||||
if (((u2 - low2) + 1) != SIZEOF(lis[i])):
|
||||
return None
|
||||
return None
|
||||
res[(low1 + i) - 1] = list_to_array(lis[i],low2,u2)
|
||||
return res
|
||||
|
||||
@@ -40292,7 +40292,7 @@ def vector_difference(arg1,arg2,):
|
||||
:type arg2:vector_or_direction
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or ( not EXISTS(arg2))) or (arg1.dim != arg2.dim)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
# begin/end block
|
||||
if ('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF.VECTOR' == TYPEOF(arg1)):
|
||||
@@ -40510,7 +40510,7 @@ def list_to_array(lis,low,u,):
|
||||
'''
|
||||
n = SIZEOF(lis)
|
||||
if (n != ((u - low) + 1)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
res = [lis[1],n]
|
||||
for i in range(2,n,1):
|
||||
@@ -40712,7 +40712,7 @@ def scalar_times_vector(scalar,vec,):
|
||||
:type vec:vector_or_direction
|
||||
'''
|
||||
if (( not EXISTS(scalar)) or ( not EXISTS(vec))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
if ('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF.VECTOR' == TYPEOF(vec)):
|
||||
v = dummy_gri == direction(vec.vector.orientation.direction_ratios)
|
||||
@@ -40793,7 +40793,7 @@ def dimensions_for_si_unit(n,):
|
||||
elif case_selector == sievert:
|
||||
return dimensional_exponents(2,0,-2,0,0,0,0)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION surface_condition_correlation #
|
||||
@@ -40916,14 +40916,14 @@ def normalise(arg,):
|
||||
:type arg:vector_or_direction
|
||||
'''
|
||||
if ( not EXISTS(arg)):
|
||||
result = None
|
||||
result = None
|
||||
else:
|
||||
ndim = arg.dim
|
||||
if ('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF.VECTOR' == TYPEOF(arg)):
|
||||
# begin/end block
|
||||
v = dummy_gri == direction(arg.vector.orientation.direction_ratios)
|
||||
if (arg.magnitude == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
vec = dummy_gri == vector(v,1)
|
||||
else:
|
||||
@@ -40941,7 +40941,7 @@ def normalise(arg,):
|
||||
else:
|
||||
result = v
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
return result
|
||||
|
||||
####################
|
||||
@@ -41112,7 +41112,7 @@ def get_id_value(obj,):
|
||||
if (SIZEOF(id_bag) == 1):
|
||||
return id_bag[1].attribute_value
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION aspect_ratio #
|
||||
@@ -41125,7 +41125,7 @@ def aspect_ratio(p,):
|
||||
if ((p.size_in_x > 0) and (p.size_in_y > 0)):
|
||||
return p.size_in_x / p.size_in_y
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION is_acyclic #
|
||||
@@ -41187,7 +41187,7 @@ def get_description_value(obj,):
|
||||
if (SIZEOF(description_bag) == 1):
|
||||
return description_bag[1].attribute_value
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION constraints_param_b_spline #
|
||||
@@ -41392,7 +41392,7 @@ def cross_product(arg1,arg2,):
|
||||
:type arg2:direction
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or (arg1.dim == 2)) or (( not EXISTS(arg2)) or (arg2.dim == 2))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
# begin/end block
|
||||
v1 = normalise(arg1).direction_ratios
|
||||
@@ -41712,10 +41712,10 @@ def dot_product(arg1,arg2,):
|
||||
:type arg2:direction
|
||||
'''
|
||||
if (( not EXISTS(arg1)) or ( not EXISTS(arg2))):
|
||||
scalar = None
|
||||
scalar = None
|
||||
else:
|
||||
if (arg1.dim != arg2.dim):
|
||||
scalar = None
|
||||
scalar = None
|
||||
else:
|
||||
# begin/end block
|
||||
vec1 = normalise(arg1)
|
||||
@@ -41737,7 +41737,7 @@ def get_role(obj,):
|
||||
if (SIZEOF(role_bag) == 1):
|
||||
return role_bag[1].role
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION acyclic_curve_replica #
|
||||
|
||||
@@ -40840,7 +40840,7 @@ def get_name_value(obj,):
|
||||
if (SIZEOF(name_bag) == 1):
|
||||
return name_bag[1].attribute_value
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION convert_spatial_to_ypr_rotation #
|
||||
@@ -40863,7 +40863,7 @@ def convert_spatial_to_ypr_rotation(pair,rotation,):
|
||||
dz = axis.direction_ratios[3]
|
||||
conv_angle = plane_angle_for_pair_in_radian(pair,angle)
|
||||
if (conv_angle == None ):
|
||||
return None
|
||||
return None
|
||||
ucf = angle / conv_angle
|
||||
s_a = SIN(conv_angle)
|
||||
c_a = COS(conv_angle)
|
||||
@@ -40890,7 +40890,7 @@ def convert_spatial_to_ypr_rotation(pair,rotation,):
|
||||
ya = 0
|
||||
ra = 0
|
||||
else:
|
||||
ya = ucf * PI
|
||||
ya = ucf * PI
|
||||
ra = ya
|
||||
pa = ucf * ATAN(s_a,ABS(c_a))
|
||||
if (dy < 0):
|
||||
@@ -40900,29 +40900,29 @@ def convert_spatial_to_ypr_rotation(pair,rotation,):
|
||||
rotmat = [[((dx * dx) * cm1) + c_a,((dx * dy) * cm1) - (dz * s_a),((dx * dz) * cm1) + (dy * s_a)],[((dx * dy) * cm1) + (dz * s_a),((dy * dy) * cm1) + c_a,((dy * dz) * cm1) - (dx * s_a)],[((dx * dz) * cm1) - (dy * s_a),((dy * dz) * cm1) + (dx * s_a),((dz * dz) * cm1) + c_a]]
|
||||
if (ABS(rotmat[1][3]) == 1):
|
||||
if (rotmat[1][3] == 1):
|
||||
pa = 0.5 * PI
|
||||
pa = 0.5 * PI
|
||||
else:
|
||||
pa = (-0.5) * PI
|
||||
pa = (-0.5) * PI
|
||||
ra = 0
|
||||
ya = ATAN(rotmat[2][1],rotmat[2][2])
|
||||
if (rotmat[2][2] < 0):
|
||||
if (ya <= 0):
|
||||
ya = ya + PI
|
||||
ya = ya + PI
|
||||
else:
|
||||
ya = ya - PI
|
||||
ya = ya - PI
|
||||
else:
|
||||
ya = ATAN(-rotmat[1][2],rotmat[1][1])
|
||||
if (rotmat[1][1] < 0):
|
||||
if (ya <= 0):
|
||||
ya = ya + PI
|
||||
ya = ya + PI
|
||||
else:
|
||||
ya = ya - PI
|
||||
ya = ya - PI
|
||||
ra = ATAN(-rotmat[2][3],rotmat[3][3])
|
||||
if (rotmat[3][3] < 0):
|
||||
if (ra <= 0):
|
||||
ra = ra + PI
|
||||
ra = ra + PI
|
||||
else:
|
||||
ra = ra - PI
|
||||
ra = ra - PI
|
||||
s_y = SIN(ya)
|
||||
c_y = COS(ya)
|
||||
s_r = SIN(ra)
|
||||
@@ -41187,7 +41187,7 @@ def get_diameter_for_round_hole(rh,):
|
||||
for l in range(1,HIINDEX(ri_set),1):
|
||||
if (('AUTOMOTIVE_DESIGN.MEASURE_REPRESENTATION_ITEM' == TYPEOF(ri_set[l])) and ('AUTOMOTIVE_DESIGN.LENGTH_MEASURE_WITH_UNIT' == TYPEOF(ri_set[l]))):
|
||||
return ri_set[l].measure_with_unit.value_component
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION list_of_topology_reversed #
|
||||
@@ -41258,7 +41258,7 @@ def shell_reversed(a_shell,):
|
||||
if ('AUTOMOTIVE_DESIGN.CLOSED_SHELL' == TYPEOF(a_shell)):
|
||||
return closed_shell_reversed(a_shell)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION topology_reversed #
|
||||
@@ -41282,7 +41282,7 @@ def topology_reversed(an_item,):
|
||||
return set_of_topology_reversed(an_item)
|
||||
if ('LIST' == TYPEOF(an_item)):
|
||||
return list_of_topology_reversed(an_item)
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION first_proj_axis #
|
||||
@@ -41295,7 +41295,7 @@ def first_proj_axis(z_axis,arg,):
|
||||
:type arg:direction
|
||||
'''
|
||||
if ( not EXISTS(z_axis)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
z = normalise(z_axis)
|
||||
if ( not EXISTS(arg)):
|
||||
@@ -41305,9 +41305,9 @@ def first_proj_axis(z_axis,arg,):
|
||||
v = dummy_gri == direction([0,1,0])
|
||||
else:
|
||||
if (arg.dim != 3):
|
||||
return None
|
||||
return None
|
||||
if (cross_product(arg,z).magnitude == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
v = normalise(arg)
|
||||
x_vec = scalar_times_vector(dot_product(v,z),z)
|
||||
@@ -41367,7 +41367,7 @@ def orthogonal_complement(vec,):
|
||||
:type vec:direction
|
||||
'''
|
||||
if ((vec.dim != 2) or ( not EXISTS(vec))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
result = dummy_gri == direction([-vec.direction_ratios[2],vec.direction_ratios[1]])
|
||||
return result
|
||||
@@ -41404,13 +41404,13 @@ def make_array_of_array(lis,low1,u1,low2,u2,):
|
||||
:type u2:INTEGER
|
||||
'''
|
||||
if (((u1 - low1) + 1) != SIZEOF(lis)):
|
||||
return None
|
||||
return None
|
||||
if (((u2 - low2) + 1) != SIZEOF(lis[1])):
|
||||
return None
|
||||
return None
|
||||
res = [list_to_array(lis[1],low2,u2),(u1 - low1) + 1]
|
||||
for i in range(2,HIINDEX(lis),1):
|
||||
if (((u2 - low2) + 1) != SIZEOF(lis[i])):
|
||||
return None
|
||||
return None
|
||||
res[(low1 + i) - 1] = list_to_array(lis[i],low2,u2)
|
||||
return res
|
||||
|
||||
@@ -41515,7 +41515,7 @@ def vector_difference(arg1,arg2,):
|
||||
:type arg2:vector_or_direction
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or ( not EXISTS(arg2))) or (arg1.dim != arg2.dim)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
if ('AUTOMOTIVE_DESIGN.VECTOR' == TYPEOF(arg1)):
|
||||
mag1 = arg1.magnitude
|
||||
@@ -41712,7 +41712,7 @@ def list_to_array(lis,low,u,):
|
||||
'''
|
||||
n = SIZEOF(lis)
|
||||
if (n != ((u - low) + 1)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
res = [lis[1],n]
|
||||
for i in range(2,n,1):
|
||||
@@ -41933,7 +41933,7 @@ def scalar_times_vector(scalar,vec,):
|
||||
:type vec:vector_or_direction
|
||||
'''
|
||||
if (( not EXISTS(scalar)) or ( not EXISTS(vec))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
if ('AUTOMOTIVE_DESIGN.VECTOR' == TYPEOF(vec)):
|
||||
v = dummy_gri == direction(vec.vector.orientation.direction_ratios)
|
||||
@@ -42014,7 +42014,7 @@ def dimensions_for_si_unit(n,):
|
||||
elif case_selector == sievert:
|
||||
return dimensional_exponents(2,0,-2,0,0,0,0)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION assembly_shape_is_defined #
|
||||
@@ -42175,13 +42175,13 @@ def normalise(arg,):
|
||||
:type arg:vector_or_direction
|
||||
'''
|
||||
if ( not EXISTS(arg)):
|
||||
result = None
|
||||
result = None
|
||||
else:
|
||||
ndim = arg.dim
|
||||
if ('AUTOMOTIVE_DESIGN.VECTOR' == TYPEOF(arg)):
|
||||
v = dummy_gri == direction(arg.vector.orientation.direction_ratios)
|
||||
if (arg.magnitude == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
vec = dummy_gri == vector(v,1)
|
||||
else:
|
||||
@@ -42199,7 +42199,7 @@ def normalise(arg,):
|
||||
else:
|
||||
result = v
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
return result
|
||||
|
||||
####################
|
||||
@@ -42370,7 +42370,7 @@ def get_id_value(obj,):
|
||||
if (SIZEOF(id_bag) == 1):
|
||||
return id_bag[1].attribute_value
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION aspect_ratio #
|
||||
@@ -42383,7 +42383,7 @@ def aspect_ratio(p,):
|
||||
if ((p.size_in_x > 0) and (p.size_in_y > 0)):
|
||||
return p.size_in_x / p.size_in_y
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION convert_plane_angle_for_pair_from_radian #
|
||||
@@ -42397,19 +42397,19 @@ def convert_plane_angle_for_pair_from_radian(pair,angle_expr,):
|
||||
'''
|
||||
link_cntxt = link_rep.representation.context_of_items
|
||||
if ( not ('AUTOMOTIVE_DESIGN.GLOBAL_UNIT_ASSIGNED_CONTEXT' == TYPEOF(link_cntxt))):
|
||||
return None
|
||||
return None
|
||||
pa_units = None
|
||||
if (SIZEOF(pa_units) != 1):
|
||||
return None
|
||||
return None
|
||||
pau = pa_units[1]
|
||||
if (( not ('AUTOMOTIVE_DESIGN.SI_UNIT' == TYPEOF(pau))) and ( not ('AUTOMOTIVE_DESIGN.CONVERSION_BASED_UNIT' == TYPEOF(pau)))):
|
||||
return None
|
||||
return None
|
||||
for while 'AUTOMOTIVE_DESIGN.CONVERSION_BASED_UNIT' == TYPEOF(pau) conv_factor = conv_factor * pau.conversion_based_unit.conversion_factor.value_component
|
||||
pau = pau.conversion_based_unit.conversion_factor.unit_component
|
||||
if ((( not ('AUTOMOTIVE_DESIGN.SI_UNIT' == TYPEOF(pau))) and ( not ('AUTOMOTIVE_DESIGN.CONVERSION_BASED_UNIT' == TYPEOF(pau)))) or ( not ('AUTOMOTIVE_DESIGN.PLANE_ANGLE_UNIT' == TYPEOF(pau)))):
|
||||
return None
|
||||
return None
|
||||
if (pau.si_unit.name != si_unit_name.radian):
|
||||
return None
|
||||
return None
|
||||
case_selector = pau.si_unit.prefix
|
||||
if case_selector == si_prefix.exa:
|
||||
conv_factor = 1e+018 * conv_factor
|
||||
@@ -42506,7 +42506,7 @@ def get_description_value(obj,):
|
||||
if (SIZEOF(description_bag) == 1):
|
||||
return description_bag[1].attribute_value
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION constraints_param_b_spline #
|
||||
@@ -42597,7 +42597,7 @@ def representation_of_link(link,):
|
||||
'''
|
||||
link_rep_rel = USEDIN(link,'AUTOMOTIVE_DESIGN.KINEMATIC_LINK_REPRESENTATION_RELATION.TOPOLOGICAL_ASPECTS')
|
||||
if (SIZEOF(link_rep_rel) == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
return link_rep_rel[1].geometric_aspects
|
||||
|
||||
@@ -42616,7 +42616,7 @@ def ypr_index(ypr,):
|
||||
return 2
|
||||
elif case_selector == roll:
|
||||
return 3
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION acyclic_mapped_item_usage #
|
||||
@@ -42649,19 +42649,19 @@ def plane_angle_for_pair_in_radian(pair,angle,):
|
||||
'''
|
||||
link_cntxt = link_rep.representation.context_of_items
|
||||
if ( not ('AUTOMOTIVE_DESIGN.GLOBAL_UNIT_ASSIGNED_CONTEXT' == TYPEOF(link_cntxt))):
|
||||
return None
|
||||
return None
|
||||
pa_units = None
|
||||
if (SIZEOF(pa_units) != 1):
|
||||
return None
|
||||
return None
|
||||
pau = pa_units[1]
|
||||
if (( not ('AUTOMOTIVE_DESIGN.SI_UNIT' == TYPEOF(pau))) and ( not ('AUTOMOTIVE_DESIGN.CONVERSION_BASED_UNIT' == TYPEOF(pau)))):
|
||||
return None
|
||||
return None
|
||||
for while 'AUTOMOTIVE_DESIGN.CONVERSION_BASED_UNIT' == TYPEOF(pau) converted_angle = converted_angle * pau.conversion_based_unit.conversion_factor.value_component
|
||||
pau = pau.conversion_based_unit.conversion_factor.unit_component
|
||||
if ((( not ('AUTOMOTIVE_DESIGN.SI_UNIT' == TYPEOF(pau))) and ( not ('AUTOMOTIVE_DESIGN.CONVERSION_BASED_UNIT' == TYPEOF(pau)))) or ( not ('AUTOMOTIVE_DESIGN.PLANE_ANGLE_UNIT' == TYPEOF(pau)))):
|
||||
return None
|
||||
return None
|
||||
if (pau.si_unit.name != si_unit_name.radian):
|
||||
return None
|
||||
return None
|
||||
case_selector = pau.si_unit.prefix
|
||||
if case_selector == si_prefix.exa:
|
||||
return 1e+018 * converted_angle
|
||||
@@ -42708,7 +42708,7 @@ def get_multi_language(x,):
|
||||
'''
|
||||
if (SIZEOF(alas) > 0):
|
||||
return alas[1].language
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION unique_link_usage #
|
||||
@@ -42806,7 +42806,7 @@ def cross_product(arg1,arg2,):
|
||||
:type arg2:direction
|
||||
'''
|
||||
if (((( not EXISTS(arg1)) or (arg1.dim == 2)) or ( not EXISTS(arg2))) or (arg2.dim == 2)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
v1 = normalise(arg1).direction_ratios
|
||||
v2 = normalise(arg2).direction_ratios
|
||||
@@ -43138,10 +43138,10 @@ def dot_product(arg1,arg2,):
|
||||
:type arg2:direction
|
||||
'''
|
||||
if (( not EXISTS(arg1)) or ( not EXISTS(arg2))):
|
||||
scalar = None
|
||||
scalar = None
|
||||
else:
|
||||
if (arg1.dim != arg2.dim):
|
||||
scalar = None
|
||||
scalar = None
|
||||
else:
|
||||
vec1 = normalise(arg1)
|
||||
vec2 = normalise(arg2)
|
||||
@@ -43162,7 +43162,7 @@ def get_role(obj,):
|
||||
if (SIZEOF(role_bag) == 1):
|
||||
return role_bag[1].role
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION acyclic_curve_replica #
|
||||
|
||||
@@ -35949,7 +35949,7 @@ def ifcnormalise(arg,):
|
||||
:type arg:ifcvectorordirection
|
||||
'''
|
||||
if ( not EXISTS(arg)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
ndim = arg.dim
|
||||
if ('IFC2X3.IFCVECTOR' == TYPEOF(arg)):
|
||||
@@ -35958,7 +35958,7 @@ def ifcnormalise(arg,):
|
||||
vec.magnitude = arg.ifcvector.magnitude
|
||||
vec.orientation = v
|
||||
if (arg.magnitude == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
vec.magnitude = 1
|
||||
else:
|
||||
@@ -35976,7 +35976,7 @@ def ifcnormalise(arg,):
|
||||
else:
|
||||
result = v
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
return result
|
||||
|
||||
####################
|
||||
@@ -36033,7 +36033,7 @@ def ifcvectorsum(arg1,arg2,):
|
||||
:type arg2:ifcvectorordirection
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or ( not EXISTS(arg2))) or (arg1.dim != arg2.dim)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
# begin/end block
|
||||
if ('IFC2X3.IFCVECTOR' == TYPEOF(arg1)):
|
||||
@@ -36073,7 +36073,7 @@ def ifcvectordifference(arg1,arg2,):
|
||||
:type arg2:ifcvectorordirection
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or ( not EXISTS(arg2))) or (arg1.dim != arg2.dim)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
# begin/end block
|
||||
if ('IFC2X3.IFCVECTOR' == TYPEOF(arg1)):
|
||||
@@ -36114,7 +36114,7 @@ def ifccorrectlocalplacement(axisplacement,relplacement,):
|
||||
'''
|
||||
if (EXISTS(relplacement)):
|
||||
if ('IFC2X3.IFCGRIDPLACEMENT' == TYPEOF(relplacement)):
|
||||
return None
|
||||
return None
|
||||
if ('IFC2X3.IFCLOCALPLACEMENT' == TYPEOF(relplacement)):
|
||||
if ('IFC2X3.IFCAXIS2PLACEMENT2D' == TYPEOF(axisplacement)):
|
||||
return TRUE
|
||||
@@ -36125,7 +36125,7 @@ def ifccorrectlocalplacement(axisplacement,relplacement,):
|
||||
return FALSE
|
||||
else:
|
||||
return TRUE
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION ifccorrectfillareastyle #
|
||||
@@ -36185,7 +36185,7 @@ def ifccurvedim(curve,):
|
||||
return 2
|
||||
if ('IFC2X3.IFCOFFSETCURVE3D' == TYPEOF(curve)):
|
||||
return 3
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION ifcsamedirection #
|
||||
@@ -36219,7 +36219,7 @@ def ifclisttoarray(lis,low,u,):
|
||||
'''
|
||||
n = SIZEOF(lis)
|
||||
if (n != ((u - low) + 1)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
res = [lis[1],n]
|
||||
for i in range(2,n,1):
|
||||
@@ -36268,7 +36268,7 @@ def ifctopologyrepresentationtypes(reptype,items,):
|
||||
elif case_selector == 'Undefined':
|
||||
return TRUE
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
return count == SIZEOF(items)
|
||||
|
||||
####################
|
||||
@@ -36300,10 +36300,10 @@ def ifcdotproduct(arg1,arg2,):
|
||||
:type arg2:ifcdirection
|
||||
'''
|
||||
if (( not EXISTS(arg1)) or ( not EXISTS(arg2))):
|
||||
scalar = None
|
||||
scalar = None
|
||||
else:
|
||||
if (arg1.dim != arg2.dim):
|
||||
scalar = None
|
||||
scalar = None
|
||||
else:
|
||||
# begin/end block
|
||||
vec1 = ifcnormalise(arg1)
|
||||
@@ -36344,7 +36344,7 @@ def ifcfirstprojaxis(zaxis,arg,):
|
||||
:type arg:ifcdirection
|
||||
'''
|
||||
if ( not EXISTS(zaxis)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
z = ifcnormalise(zaxis)
|
||||
if ( not EXISTS(arg)):
|
||||
@@ -36354,9 +36354,9 @@ def ifcfirstprojaxis(zaxis,arg,):
|
||||
v = (ifcrepresentationitem() == ifcgeometricrepresentationitem()) == ifcdirection([0,1,0])
|
||||
else:
|
||||
if (arg.dim != 3):
|
||||
return None
|
||||
return None
|
||||
if (ifccrossproduct(arg,z).magnitude == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
v = ifcnormalise(arg)
|
||||
xvec = ifcscalartimesvector(ifcdotproduct(v,z),z)
|
||||
@@ -36424,7 +36424,7 @@ def ifcshaperepresentationtypes(reptype,items,):
|
||||
# begin/end block
|
||||
count = SIZEOF(None)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
return count == SIZEOF(items)
|
||||
|
||||
####################
|
||||
@@ -36509,7 +36509,7 @@ def ifcscalartimesvector(scalar,vec,):
|
||||
:type vec:ifcvectorordirection
|
||||
'''
|
||||
if (( not EXISTS(scalar)) or ( not EXISTS(vec))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
if ('IFC2X3.IFCVECTOR' == TYPEOF(vec)):
|
||||
v = vec.ifcvector.orientation
|
||||
@@ -36583,7 +36583,7 @@ def ifcorthogonalcomplement(vec,):
|
||||
:type vec:ifcdirection
|
||||
'''
|
||||
if (( not EXISTS(vec)) or (vec.dim != 2)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
result = (ifcrepresentationitem() == ifcgeometricrepresentationitem()) == ifcdirection([-vec.directionratios[2],vec.directionratios[1]])
|
||||
return result
|
||||
@@ -36889,7 +36889,7 @@ def ifccorrectobjectassignment(constraint,objects,):
|
||||
count = SIZEOF(None)
|
||||
return count == 0
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION ifcvalidcalendardate #
|
||||
@@ -36968,7 +36968,7 @@ def ifccrossproduct(arg1,arg2,):
|
||||
:type arg2:ifcdirection
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or (arg1.dim == 2)) or (( not EXISTS(arg2)) or (arg2.dim == 2))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
# begin/end block
|
||||
v1 = ifcnormalise(arg1).directionratios
|
||||
|
||||
@@ -42688,7 +42688,7 @@ def ifcnormalise(arg,):
|
||||
:type arg:ifcvectorordirection
|
||||
'''
|
||||
if ( not EXISTS(arg)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
if ('IFC4.IFCVECTOR' == TYPEOF(arg)):
|
||||
# begin/end block
|
||||
@@ -42697,7 +42697,7 @@ def ifcnormalise(arg,):
|
||||
vec.magnitude = arg.ifcvector.magnitude
|
||||
vec.orientation = v
|
||||
if (arg.ifcvector.magnitude == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
vec.magnitude = 1
|
||||
else:
|
||||
@@ -42717,7 +42717,7 @@ def ifcnormalise(arg,):
|
||||
else:
|
||||
result = v
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
return result
|
||||
|
||||
####################
|
||||
@@ -42796,7 +42796,7 @@ def ifcvectorsum(arg1,arg2,):
|
||||
:type arg2:ifcvectorordirection
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or ( not EXISTS(arg2))) or (arg1.dim != arg2.dim)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
# begin/end block
|
||||
if ('IFC4.IFCVECTOR' == TYPEOF(arg1)):
|
||||
@@ -42836,7 +42836,7 @@ def ifcvectordifference(arg1,arg2,):
|
||||
:type arg2:ifcvectorordirection
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or ( not EXISTS(arg2))) or (arg1.dim != arg2.dim)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
# begin/end block
|
||||
if ('IFC4.IFCVECTOR' == TYPEOF(arg1)):
|
||||
@@ -42877,7 +42877,7 @@ def ifccorrectlocalplacement(axisplacement,relplacement,):
|
||||
'''
|
||||
if (EXISTS(relplacement)):
|
||||
if ('IFC4.IFCGRIDPLACEMENT' == TYPEOF(relplacement)):
|
||||
return None
|
||||
return None
|
||||
if ('IFC4.IFCLOCALPLACEMENT' == TYPEOF(relplacement)):
|
||||
if ('IFC4.IFCAXIS2PLACEMENT2D' == TYPEOF(axisplacement)):
|
||||
return TRUE
|
||||
@@ -42888,7 +42888,7 @@ def ifccorrectlocalplacement(axisplacement,relplacement,):
|
||||
return FALSE
|
||||
else:
|
||||
return TRUE
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION ifccorrectfillareastyle #
|
||||
@@ -42953,13 +42953,13 @@ def ifcmakearrayofarray(lis,low1,u1,low2,u2,):
|
||||
:type u2:INTEGER
|
||||
'''
|
||||
if (((u1 - low1) + 1) != SIZEOF(lis)):
|
||||
return None
|
||||
return None
|
||||
if (((u2 - low2) + 1) != SIZEOF(lis[1])):
|
||||
return None
|
||||
return None
|
||||
res = [ifclisttoarray(lis[1],low2,u2),(u1 - low1) + 1]
|
||||
for i in range(2,HIINDEX(lis),1):
|
||||
if (((u2 - low2) + 1) != SIZEOF(lis[i])):
|
||||
return None
|
||||
return None
|
||||
res[(low1 + i) - 1] = ifclisttoarray(lis[i],low2,u2)
|
||||
return res
|
||||
|
||||
@@ -42989,7 +42989,7 @@ def ifccurvedim(curve,):
|
||||
return 3
|
||||
if ('IFC4.IFCPCURVE' == TYPEOF(curve)):
|
||||
return 3
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION ifcsamedirection #
|
||||
@@ -43023,7 +43023,7 @@ def ifclisttoarray(lis,low,u,):
|
||||
'''
|
||||
n = SIZEOF(lis)
|
||||
if (n != ((u - low) + 1)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
res = [lis[1],n]
|
||||
for i in range(2,n,1):
|
||||
@@ -43059,7 +43059,7 @@ def ifctopologyrepresentationtypes(reptype,items,):
|
||||
elif case_selector == 'Undefined':
|
||||
return TRUE
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
return count == SIZEOF(items)
|
||||
|
||||
####################
|
||||
@@ -43091,10 +43091,10 @@ def ifcdotproduct(arg1,arg2,):
|
||||
:type arg2:ifcdirection
|
||||
'''
|
||||
if (( not EXISTS(arg1)) or ( not EXISTS(arg2))):
|
||||
scalar = None
|
||||
scalar = None
|
||||
else:
|
||||
if (arg1.dim != arg2.dim):
|
||||
scalar = None
|
||||
scalar = None
|
||||
else:
|
||||
# begin/end block
|
||||
vec1 = ifcnormalise(arg1)
|
||||
@@ -43116,7 +43116,7 @@ def ifcfirstprojaxis(zaxis,arg,):
|
||||
:type arg:ifcdirection
|
||||
'''
|
||||
if ( not EXISTS(zaxis)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
z = ifcnormalise(zaxis)
|
||||
if ( not EXISTS(arg)):
|
||||
@@ -43126,9 +43126,9 @@ def ifcfirstprojaxis(zaxis,arg,):
|
||||
v = (ifcrepresentationitem() == ifcgeometricrepresentationitem()) == ifcdirection([0,1,0])
|
||||
else:
|
||||
if (arg.dim != 3):
|
||||
return None
|
||||
return None
|
||||
if (ifccrossproduct(arg,z).magnitude == 0):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
v = ifcnormalise(arg)
|
||||
xvec = ifcscalartimesvector(ifcdotproduct(v,z),z)
|
||||
@@ -43238,7 +43238,7 @@ def ifcshaperepresentationtypes(reptype,items,):
|
||||
# begin/end block
|
||||
count = SIZEOF(None)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
return count == SIZEOF(items)
|
||||
|
||||
####################
|
||||
@@ -43323,7 +43323,7 @@ def ifcscalartimesvector(scalar,vec,):
|
||||
:type vec:ifcvectorordirection
|
||||
'''
|
||||
if (( not EXISTS(scalar)) or ( not EXISTS(vec))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
if ('IFC4.IFCVECTOR' == TYPEOF(vec)):
|
||||
v = vec.ifcvector.orientation
|
||||
@@ -43428,7 +43428,7 @@ def ifcorthogonalcomplement(vec,):
|
||||
:type vec:ifcdirection
|
||||
'''
|
||||
if (( not EXISTS(vec)) or (vec.dim != 2)):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
result = (ifcrepresentationitem() == ifcgeometricrepresentationitem()) == ifcdirection([-vec.directionratios[2],vec.directionratios[1]])
|
||||
return result
|
||||
@@ -43734,7 +43734,7 @@ def ifccorrectobjectassignment(constraint,objects,):
|
||||
count = SIZEOF(None)
|
||||
return count == 0
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
####################
|
||||
# FUNCTION ifccurveweightspositive #
|
||||
@@ -43824,7 +43824,7 @@ def ifccrossproduct(arg1,arg2,):
|
||||
:type arg2:ifcdirection
|
||||
'''
|
||||
if ((( not EXISTS(arg1)) or (arg1.dim == 2)) or (( not EXISTS(arg2)) or (arg2.dim == 2))):
|
||||
return None
|
||||
return None
|
||||
else:
|
||||
# begin/end block
|
||||
v1 = ifcnormalise(arg1).ifcdirection.directionratios
|
||||
|
||||
@@ -19,6 +19,6 @@ BLOCK
|
||||
3
|
||||
*MODEL_SPACE
|
||||
1
|
||||
|
||||
|
||||
0
|
||||
ENDBLK
|
||||
|
||||
@@ -67,6 +67,6 @@ txt
|
||||
42
|
||||
1
|
||||
4
|
||||
|
||||
|
||||
0
|
||||
ENDTAB
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<RCC>
|
||||
<qresource>
|
||||
<qresource>
|
||||
<file>ui/preferences-import.ui</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user