Skip to content

Commit 4f60c7d

Browse files
committed
Provide concrete C++ implementations for all multidimensional aggregate types in IFC4
1 parent f70b371 commit 4f60c7d

File tree

12 files changed

+196
-51
lines changed

12 files changed

+196
-51
lines changed

src/ifcexpressparser/implementation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def find_template(arg):
7474
select = arg['list_instance_type'] == "IfcUtil::IfcBaseClass"
7575
express = mapping.flatten_type_string(arg['list_instance_type']) in mapping.express_to_cpp_typemapping
7676
if arg['is_enum']: return templates.get_attr_stmt_enum
77-
elif arg['is_nested']: return templates.get_attr_stmt_nested_array
77+
elif arg['is_nested'] and arg['is_templated_list']: return templates.get_attr_stmt_nested_array
7878
elif arg['is_templated_list'] and not (select or simple or express): return templates.get_attr_stmt_array
7979
elif arg['non_optional_type'].endswith('*'): return templates.get_attr_stmt_entity
8080
else: return templates.get_attr_stmt

src/ifcexpressparser/mapping.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# #
1818
###############################################################################
1919

20+
import sys
2021
import nodes
2122
import templates
2223

@@ -35,7 +36,7 @@ class Mapping:
3536
supported_argument_types = {
3637
'INT', 'BOOL', 'DOUBLE', 'STRING', 'BINARY', 'ENUMERATION', 'ENTITY_INSTANCE',
3738
'AGGREGATE_OF_INT', 'AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_STRING', 'AGGREGATE_OF_BINARY', 'AGGREGATE_OF_ENTITY_INSTANCE',
38-
'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE'
39+
'AGGREGATE_OF_AGGREGATE_OF_INT', 'AGGREGATE_OF_AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE',
3940
}
4041

4142
def __init__(self, schema):
@@ -96,9 +97,12 @@ def _make_argument_type(type):
9697
ty = _make_argument_type(type.type)
9798
if ty == "UNKNOWN": return "UNKNOWN"
9899
return "AGGREGATE_OF_" + ty
99-
else: raise ValueError
100+
else:
101+
raise ValueError("Unable to map type %r for attribute %r" % (type, attr))
100102
ty = _make_argument_type(attr.type if hasattr(attr, 'type') else attr)
101-
if ty not in self.supported_argument_types: ty = 'UNKNOWN'
103+
if ty not in self.supported_argument_types:
104+
print("Attribute %r mapped as 'unknown'" % (type, attr), file=sys.stderr)
105+
ty = 'UNKNOWN'
102106
return "IfcUtil::Argument_%s" % ty
103107

104108
def get_type_dep(self, type):
@@ -121,7 +125,8 @@ def get_parameter_type(self, attr, allow_optional, allow_entities, allow_pointer
121125
if self.schema.is_select(attr_type.type):
122126
type_str = templates.untyped_list
123127
elif self.schema.is_simpletype(ty) or ty in self.express_to_cpp_typemapping.values():
124-
type_str = templates.array_type % {
128+
tmpl = templates.nested_array_type if is_nested_list else templates.array_type
129+
type_str = tmpl % {
125130
'instance_type' : ty,
126131
'lower' : attr_type.bounds.lower,
127132
'upper' : attr_type.bounds.upper

src/ifcexpressparser/templates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ class %(name)s %(superclass)s{
409409
cast_function = "%(class_name)s::operator %(return_type)s() const { %(body)s }"
410410

411411
array_type = "std::vector< %(instance_type)s > /*[%(lower)s:%(upper)s]*/"
412+
nested_array_type = "std::vector< std::vector< %(instance_type)s > >"
412413
list_type = "IfcTemplatedEntityList< %(instance_type)s >::ptr"
413414
list_list_type = "IfcTemplatedEntityListList< %(instance_type)s >::ptr"
414415
untyped_list = "IfcEntityList::ptr"

src/ifcparse/Ifc4-latebound.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ void InitDescriptorMap() {
663663
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
664664
current = entity_descriptor_map[Type::IfcStructuralLoadConfiguration] = new IfcEntityDescriptor(Type::IfcStructuralLoadConfiguration,entity_descriptor_map.find(Type::IfcStructuralLoad)->second);
665665
current->add("Values",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcStructuralLoadOrResult);
666+
current->add("Locations",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcLengthMeasure);
666667
current = entity_descriptor_map[Type::IfcStructuralLoadOrResult] = new IfcEntityDescriptor(Type::IfcStructuralLoadOrResult,entity_descriptor_map.find(Type::IfcStructuralLoad)->second);
667668

668669
current = entity_descriptor_map[Type::IfcStructuralLoadStatic] = new IfcEntityDescriptor(Type::IfcStructuralLoadStatic,entity_descriptor_map.find(Type::IfcStructuralLoadOrResult)->second);
@@ -771,7 +772,7 @@ void InitDescriptorMap() {
771772
current = entity_descriptor_map[Type::IfcTextureVertex] = new IfcEntityDescriptor(Type::IfcTextureVertex,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
772773
current->add("Coordinates",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::IfcParameterValue);
773774
current = entity_descriptor_map[Type::IfcTextureVertexList] = new IfcEntityDescriptor(Type::IfcTextureVertexList,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
774-
775+
current->add("TexCoordsList",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcParameterValue);
775776
current = entity_descriptor_map[Type::IfcTimePeriod] = new IfcEntityDescriptor(Type::IfcTimePeriod,0);
776777
current->add("StartTime",false,IfcUtil::Argument_STRING,Type::IfcTime);
777778
current->add("EndTime",false,IfcUtil::Argument_STRING,Type::IfcTime);
@@ -830,7 +831,7 @@ void InitDescriptorMap() {
830831
current->add("Description",true,IfcUtil::Argument_STRING,Type::IfcText);
831832
current->add("Sort",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
832833
current = entity_descriptor_map[Type::IfcColourRgbList] = new IfcEntityDescriptor(Type::IfcColourRgbList,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
833-
834+
current->add("ColourList",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcNormalisedRatioMeasure);
834835
current = entity_descriptor_map[Type::IfcColourSpecification] = new IfcEntityDescriptor(Type::IfcColourSpecification,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
835836
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
836837
current = entity_descriptor_map[Type::IfcCompositeProfileDef] = new IfcEntityDescriptor(Type::IfcCompositeProfileDef,entity_descriptor_map.find(Type::IfcProfileDef)->second);
@@ -971,7 +972,7 @@ void InitDescriptorMap() {
971972
current->add("MappedTo",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTessellatedFaceSet);
972973
current->add("TexCoords",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTextureVertexList);
973974
current = entity_descriptor_map[Type::IfcIndexedTriangleTextureMap] = new IfcEntityDescriptor(Type::IfcIndexedTriangleTextureMap,entity_descriptor_map.find(Type::IfcIndexedTextureMap)->second);
974-
975+
current->add("TexCoordIndex",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::UNDEFINED);
975976
current = entity_descriptor_map[Type::IfcIrregularTimeSeries] = new IfcEntityDescriptor(Type::IfcIrregularTimeSeries,entity_descriptor_map.find(Type::IfcTimeSeries)->second);
976977
current->add("Values",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcIrregularTimeSeriesValue);
977978
current = entity_descriptor_map[Type::IfcLagTime] = new IfcEntityDescriptor(Type::IfcLagTime,entity_descriptor_map.find(Type::IfcSchedulingTime)->second);
@@ -1355,7 +1356,7 @@ void InitDescriptorMap() {
13551356
current = entity_descriptor_map[Type::IfcCartesianPointList] = new IfcEntityDescriptor(Type::IfcCartesianPointList,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
13561357

13571358
current = entity_descriptor_map[Type::IfcCartesianPointList3D] = new IfcEntityDescriptor(Type::IfcCartesianPointList3D,entity_descriptor_map.find(Type::IfcCartesianPointList)->second);
1358-
1359+
current->add("CoordList",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcLengthMeasure);
13591360
current = entity_descriptor_map[Type::IfcCartesianTransformationOperator] = new IfcEntityDescriptor(Type::IfcCartesianTransformationOperator,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
13601361
current->add("Axis1",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcDirection);
13611362
current->add("Axis2",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcDirection);
@@ -1796,11 +1797,13 @@ void InitDescriptorMap() {
17961797
current->add("WorkMethod",true,IfcUtil::Argument_STRING,Type::IfcLabel);
17971798
current = entity_descriptor_map[Type::IfcTessellatedFaceSet] = new IfcEntityDescriptor(Type::IfcTessellatedFaceSet,entity_descriptor_map.find(Type::IfcTessellatedItem)->second);
17981799
current->add("Coordinates",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCartesianPointList3D);
1800+
current->add("Normals",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcParameterValue);
17991801
current->add("Closed",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
18001802
current = entity_descriptor_map[Type::IfcTransportElementType] = new IfcEntityDescriptor(Type::IfcTransportElementType,entity_descriptor_map.find(Type::IfcElementType)->second);
18011803
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcTransportElementTypeEnum);
18021804
current = entity_descriptor_map[Type::IfcTriangulatedFaceSet] = new IfcEntityDescriptor(Type::IfcTriangulatedFaceSet,entity_descriptor_map.find(Type::IfcTessellatedFaceSet)->second);
1803-
1805+
current->add("CoordIndex",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::UNDEFINED);
1806+
current->add("NormalIndex",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::UNDEFINED);
18041807
current = entity_descriptor_map[Type::IfcWindowLiningProperties] = new IfcEntityDescriptor(Type::IfcWindowLiningProperties,entity_descriptor_map.find(Type::IfcPreDefinedPropertySet)->second);
18051808
current->add("LiningDepth",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
18061809
current->add("LiningThickness",true,IfcUtil::Argument_DOUBLE,Type::IfcNonNegativeLengthMeasure);
@@ -2100,7 +2103,7 @@ void InitDescriptorMap() {
21002103
current = entity_descriptor_map[Type::IfcRampType] = new IfcEntityDescriptor(Type::IfcRampType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
21012104
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcRampTypeEnum);
21022105
current = entity_descriptor_map[Type::IfcRationalBSplineSurfaceWithKnots] = new IfcEntityDescriptor(Type::IfcRationalBSplineSurfaceWithKnots,entity_descriptor_map.find(Type::IfcBSplineSurfaceWithKnots)->second);
2103-
2106+
current->add("WeightsData",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::UNDEFINED);
21042107
current = entity_descriptor_map[Type::IfcReinforcingElement] = new IfcEntityDescriptor(Type::IfcReinforcingElement,entity_descriptor_map.find(Type::IfcElementComponent)->second);
21052108
current->add("SteelGrade",true,IfcUtil::Argument_STRING,Type::IfcLabel);
21062109
current = entity_descriptor_map[Type::IfcReinforcingElementType] = new IfcEntityDescriptor(Type::IfcReinforcingElementType,entity_descriptor_map.find(Type::IfcElementComponentType)->second);

0 commit comments

Comments
 (0)