Skip to content

Commit 1b54ba0

Browse files
committed
- Add support for IFC4 nurbs surfaces (IfcBSplineSurfaceWithKnots and IfcAdvancedFace)
- Remove unnecessary typedefs
1 parent e87b898 commit 1b54ba0

33 files changed

Lines changed: 17866 additions & 20434 deletions

src/examples/IfcOpenHouse.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ int main(int argc, char** argv) {
213213
// will be tesselated using the deflection specified.
214214
TopoDS_Shape shape;
215215
createGroundShape(shape);
216-
IfcEntities geometrical_entities(new IfcEntityList());
216+
IfcEntityList::ptr geometrical_entities(new IfcEntityList);
217217
IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(shape, 100., geometrical_entities);
218218
file.getSingle<IfcSchema::IfcSite>()->setRepresentation(ground_representation);
219219
file.AddEntities(geometrical_entities);
220-
IfcSchema::IfcShapeRepresentation::list ground_reps = geometrical_entities->as<IfcSchema::IfcShapeRepresentation>();
221-
for (IfcSchema::IfcShapeRepresentation::it it = ground_reps->begin(); it != ground_reps->end(); ++it) {
220+
IfcSchema::IfcShapeRepresentation::list::ptr ground_reps = geometrical_entities->as<IfcSchema::IfcShapeRepresentation>();
221+
for (IfcSchema::IfcShapeRepresentation::list::it it = ground_reps->begin(); it != ground_reps->end(); ++it) {
222222
(*it)->setContextOfItems(file.getSingle<IfcSchema::IfcRepresentationContext>());
223223
}
224224
file.setSurfaceColour(ground_representation, 0.15, 0.25, 0.05);
@@ -246,7 +246,7 @@ int main(int argc, char** argv) {
246246
, null
247247
#endif
248248
);
249-
IfcSchema::IfcMaterialLayer::list layers (new IfcTemplatedEntityList<IfcSchema::IfcMaterialLayer>());
249+
IfcSchema::IfcMaterialLayer::list::ptr layers (new IfcTemplatedEntityList<IfcSchema::IfcMaterialLayer>());
250250
layers->push(layer);
251251
IfcSchema::IfcMaterialLayerSet* layer_set = new IfcSchema::IfcMaterialLayerSet(
252252
layers,
@@ -324,9 +324,9 @@ int main(int argc, char** argv) {
324324
#endif
325325
);
326326
door->setRepresentation(file.addBox(80, 80, 2120, 0, file.addPlacement3d(460, 0, 0)));
327-
IfcSchema::IfcRepresentation::list door_representations = door->Representation()->Representations();
327+
IfcSchema::IfcRepresentation::list::ptr door_representations = door->Representation()->Representations();
328328
IfcSchema::IfcShapeRepresentation* door_body = 0;
329-
for (IfcSchema::IfcRepresentation::it i = door_representations->begin(); i != door_representations->end(); ++i) {
329+
for (IfcSchema::IfcRepresentation::list::it i = door_representations->begin(); i != door_representations->end(); ++i) {
330330
IfcSchema::IfcRepresentation* rep = *i;
331331
if (rep->is(IfcSchema::Type::IfcShapeRepresentation) && rep->RepresentationIdentifier() == "Body") {
332332
door_body = (IfcSchema::IfcShapeRepresentation*) rep;
@@ -350,15 +350,15 @@ int main(int argc, char** argv) {
350350
// Therefore the OverallWidth and OverallHeight of the window attributes will need to
351351
// match the bounding box of the representation. Furthermore, the window placement needs
352352
// to align with the lowerleft corner of the constituent parts.
353-
IfcSchema::IfcProductDefinitionShape::list frame_representations (new IfcTemplatedEntityList<IfcSchema::IfcProductDefinitionShape>());
353+
IfcSchema::IfcProductDefinitionShape::list::ptr frame_representations (new IfcTemplatedEntityList<IfcSchema::IfcProductDefinitionShape>());
354354
frame_representations->push(file.addBox(1860, 90, 90));
355355
frame_representations->push(*frame_representations->begin()); // Add a reference to the shape created above
356356
frame_representations->push(file.addBox(90, 90, 1420));
357357
frame_representations->push(*(frame_representations->end()-1)); // Add a reference to the shape created above
358358

359359
// The beams all have the same surface style assigned
360360
IfcSchema::IfcPresentationStyleAssignment* frame_style = 0;
361-
for (IfcSchema::IfcProductDefinitionShape::it i = frame_representations->begin(); i != frame_representations->end(); ++i) {
361+
for (IfcSchema::IfcProductDefinitionShape::list::it i = frame_representations->begin(); i != frame_representations->end(); ++i) {
362362
if (frame_style) {
363363
file.setSurfaceColour(*i, frame_style);
364364
} else {
@@ -368,14 +368,14 @@ int main(int argc, char** argv) {
368368

369369
// This window will be placed at five locations within the building. A list of placements is
370370
// created and is iterated over to create all window instances.
371-
IfcSchema::IfcLocalPlacement::list window_placements (new IfcTemplatedEntityList<IfcSchema::IfcLocalPlacement>());
371+
IfcSchema::IfcLocalPlacement::list::ptr window_placements (new IfcTemplatedEntityList<IfcSchema::IfcLocalPlacement>());
372372
window_placements->push(file.addLocalPlacement(2*-1770-430-930, -45, 400));
373373
window_placements->push(file.addLocalPlacement( -1770-430-930, -45, 400));
374374
window_placements->push(file.addLocalPlacement( -430-930, -45, 400));
375375
window_placements->push(file.addLocalPlacement( 3000-930, -45, 400));
376376
window_placements->push(file.addLocalPlacement( -4855+45, 885-930, 400, 0, 0, 1, 0, 1, 0));
377377

378-
for (IfcSchema::IfcLocalPlacement::it it = window_placements->begin(); it != window_placements->end(); ++it) {
378+
for (IfcSchema::IfcLocalPlacement::list::it it = window_placements->begin(); it != window_placements->end(); ++it) {
379379

380380
// Create the window at the current location
381381
IfcSchema::IfcLocalPlacement* place = *it;
@@ -390,19 +390,19 @@ int main(int argc, char** argv) {
390390
file.addBuildingProduct(window);
391391

392392
// Initalize a list of parts for the window to be composed of
393-
IfcSchema::IfcObjectDefinition::list window_parts(new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
393+
IfcSchema::IfcObjectDefinition::list::ptr window_parts(new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
394394

395395
// The placements for the beams are not shared accross the different windows because every
396396
// beam is placed relative to its parent window entity.
397-
IfcSchema::IfcLocalPlacement::list frame_placements (new IfcTemplatedEntityList<IfcSchema::IfcLocalPlacement>());
397+
IfcSchema::IfcLocalPlacement::list::ptr frame_placements (new IfcTemplatedEntityList<IfcSchema::IfcLocalPlacement>());
398398
frame_placements->push(file.addLocalPlacement( 930,45));
399399
frame_placements->push(file.addLocalPlacement( 930, 45, 1510));
400400
frame_placements->push(file.addLocalPlacement(-885+930, 45, 90));
401401
frame_placements->push(file.addLocalPlacement( 885+930, 45, 90));
402402

403403
// Now iterate over the placements and representations of the beam and add them to list of parts
404-
IfcSchema::IfcLocalPlacement::it frame_placement;
405-
IfcSchema::IfcProductDefinitionShape::it frame_representation;
404+
IfcSchema::IfcLocalPlacement::list::it frame_placement;
405+
IfcSchema::IfcProductDefinitionShape::list::it frame_representation;
406406
for (frame_placement = frame_placements->begin(), frame_representation = frame_representations->begin();
407407
frame_placement != frame_placements->end() && frame_representation != frame_representations->end();
408408
++frame_placement, ++frame_representation)

src/examples/IfcParseExamples.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int main(int argc, char** argv) {
6464
std::cout << element->entity->toString() << std::endl;
6565

6666
if ( element->is(IfcWindow::Class()) ) {
67-
const IfcWindow::ptr window = reinterpret_pointer_cast<IfcBuildingElement,IfcWindow>(element);
67+
const IfcWindow::ptr window = (IfcWindow*)element;
6868

6969
if ( window->hasOverallWidth() && window->hasOverallHeight() ) {
7070
const double area = window->OverallWidth()*window->OverallHeight();

src/examples/arbitrary_open_profile_def.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ int main(int argc, char** argv) {
124124

125125
IfcSchema::IfcEllipse* ellipse = new IfcSchema::IfcEllipse(file.addPlacement2d(), 50., 25.);
126126
file.AddEntity(ellipse);
127-
IfcEntities trim1(new IfcEntityList());
128-
IfcEntities trim2(new IfcEntityList());
127+
IfcEntityList::ptr trim1(new IfcEntityList);
128+
IfcEntityList::ptr trim2(new IfcEntityList);
129129
trim1->push(new IfcWrite::IfcSelectHelper( 0., Ifc2x3::Type::IfcParameterValue));
130130
trim2->push(new IfcWrite::IfcSelectHelper(180., Ifc2x3::Type::IfcParameterValue));
131131
IfcSchema::IfcTrimmedCurve* trim = new IfcSchema::IfcTrimmedCurve(ellipse, trim1, trim2, true, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER);

src/examples/ellipse_pies.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, Ifc2x3
6767

6868
Ifc2x3::IfcEllipse* ellipse = new Ifc2x3::IfcEllipse(file.addPlacement2d(), pie.r1, pie.r2);
6969
file.AddEntity(ellipse);
70-
IfcEntities trim1(new IfcEntityList());
71-
IfcEntities trim2(new IfcEntityList());
70+
IfcEntityList::ptr trim1(new IfcEntityList);
71+
IfcEntityList::ptr trim2(new IfcEntityList);
7272
if (pref == Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER) {
7373
trim1->push(new IfcWrite::IfcSelectHelper(pie.t1, Ifc2x3::Type::IfcParameterValue));
7474
trim2->push(new IfcWrite::IfcSelectHelper(pie.t2, Ifc2x3::Type::IfcParameterValue));

src/ifcexpressparser/header.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ def __init__(self, mapping):
6565
def write_method(attr):
6666
if attr.optional:
6767
attr_lines.append(templates.optional_attribute_description % (attr.name, name))
68-
attr_lines.append("bool has%s();"%(attr.name))
68+
attr_lines.append("bool has%s() const;"%(attr.name))
6969
attr_lines.extend(["/// %s"%d for d in documentation.description((name, attr.name))])
7070
type_str = mapping.get_parameter_type(attr, allow_optional=False, allow_entities=False)
7171
if mapping.make_argument_type(attr) != "IfcUtil::Argument_UNKNOWN":
72-
attr_lines.append("%s %s();"%(type_str, attr.name))
72+
attr_lines.append("%s %s() const;"%(type_str, attr.name))
7373
attr_lines.append("void set%s(%s v);"%(attr.name, type_str))
7474

7575
[write_method(attr) for attr in type.attributes]

src/ifcexpressparser/implementation.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,26 @@ def __init__(self, mapping):
6161
if not arg['is_inherited'] and not arg['is_derived']:
6262
if arg['is_optional']:
6363
write_attr(
64-
templates.function,
64+
templates.const_function,
6565
class_name = name,
6666
name = 'has%s'%arg['name'],
6767
arguments = '',
6868
return_type = 'bool',
6969
body = templates.optional_attr_stmt % {'index':arg['index']-1}
7070
)
71-
72-
tmpl = templates.get_attr_stmt_enum if arg['is_enum'] else templates.get_attr_stmt_array if arg['is_array'] and not mapping.schema.is_simpletype(arg['list_instance_type']) and arg['list_instance_type'] not in mapping.express_to_cpp_typemapping else templates.get_attr_stmt_entity if arg['non_optional_type'].endswith('*') else templates.get_attr_stmt
71+
72+
def find_template(arg):
73+
simple = mapping.schema.is_simpletype(arg['list_instance_type'])
74+
express = arg['list_instance_type'] in mapping.express_to_cpp_typemapping
75+
if arg['is_enum']: return templates.get_attr_stmt_enum
76+
elif arg['is_nested']: return templates.get_attr_stmt_nested_array
77+
elif arg['is_array'] and not (simple or express): return templates.get_attr_stmt_array
78+
elif arg['non_optional_type'].endswith('*'): return templates.get_attr_stmt_entity
79+
else: return templates.get_attr_stmt
80+
81+
tmpl = find_template(arg)
7382
write_attr(
74-
templates.function,
83+
templates.const_function,
7584
class_name = name,
7685
name = arg['name'],
7786
arguments = '',
@@ -111,15 +120,15 @@ def __init__(self, mapping):
111120
'stmt' : impl}
112121
constructor_implementations.append(impl)
113122

114-
inverse = [templates.function % {
123+
inverse = [templates.const_function % {
115124
'class_name' : name,
116125
'name' : i.name,
117126
'arguments' : '',
118-
'return_type' : '%s::list' % i.entity,
127+
'return_type' : '%s::list::ptr' % i.entity,
119128
'body' : templates.get_inverse % {'type': i.entity}
120129
} for i in (type.inverse.elements if type.inverse else [])]
121130

122-
superclass = "%s((IfcAbstractEntityPtr)0)" % type.supertypes[0] if len(type.supertypes) == 1 else 'IfcUtil::IfcBaseEntity()'
131+
superclass = "%s((IfcAbstractEntity*)0)" % type.supertypes[0] if len(type.supertypes) == 1 else 'IfcUtil::IfcBaseEntity()'
123132

124133
write(
125134
templates.entity_implementation,

src/ifcexpressparser/mapping.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def make_type_string(self, type):
3939
return self.express_to_cpp_typemapping.get(type, type)
4040
else:
4141
is_list = self.schema.is_entity(type.type)
42-
tmpl = templates.list_type if is_list else templates.array_type
42+
is_nested_list = isinstance(type.type, nodes.AggregationType)
43+
tmpl = templates.list_list_type if is_nested_list else templates.list_type if is_list else templates.array_type
4344
return tmpl % {
4445
'instance_type' : self.make_type_string(type.type),
4546
'lower' : type.bounds.lower,
@@ -71,9 +72,9 @@ def _make_argument_type(type):
7172
elif isinstance(type, nodes.AggregationType):
7273
ty = _make_argument_type(type.type)
7374
if ty == "UNKNOWN": return "UNKNOWN"
74-
return "ENTITY_LIST" if ty == "ENTITY" else ("VECTOR_%s"%ty)
75+
return "%s_LIST"%ty if ty.startswith("ENTITY") else ("VECTOR_%s"%ty)
7576
else: raise ValueError
76-
supported = {'INT', 'BOOL', 'DOUBLE', 'STRING', 'VECTOR_INT', 'VECTOR_DOUBLE', 'VECTOR_STRING', 'ENTITY', 'ENTITY_LIST', 'ENUMERATION'}
77+
supported = {'INT', 'BOOL', 'DOUBLE', 'STRING', 'VECTOR_INT', 'VECTOR_DOUBLE', 'VECTOR_STRING', 'ENTITY', 'ENTITY_LIST', 'ENTITY_LIST_LIST', 'ENUMERATION'}
7778
ty = _make_argument_type(attr.type)
7879
if ty not in supported: ty = 'UNKNOWN'
7980
return "IfcUtil::Argument_%s" % ty
@@ -90,7 +91,8 @@ def get_parameter_type(self, attr, allow_optional, allow_entities, allow_pointer
9091
if self.schema.is_enumeration(attr.type):
9192
type_str = '%s::%s'%(attr.type, attr.type)
9293
elif isinstance(type_str, nodes.AggregationType):
93-
ty = self.get_parameter_type(attr.type, False, allow_entities, allow_pointer=False)
94+
is_nested_list = isinstance(attr.type.type, nodes.AggregationType)
95+
ty = self.get_parameter_type(attr.type.type if is_nested_list else attr.type, False, allow_entities, allow_pointer=False)
9496
if allow_entities and self.schema.is_select(attr.type.type):
9597
type_str = templates.untyped_list
9698
elif self.schema.is_simpletype(ty) or ty in self.express_to_cpp_typemapping.values():
@@ -100,7 +102,8 @@ def get_parameter_type(self, attr, allow_optional, allow_entities, allow_pointer
100102
'upper' : attr.type.bounds.upper
101103
}
102104
else:
103-
type_str = templates.list_type % {
105+
tmpl = templates.list_list_type if is_nested_list else templates.list_type
106+
type_str = tmpl % {
104107
'instance_type': ty
105108
}
106109
elif allow_pointer and self.schema.is_entity(type_str):
@@ -127,11 +130,16 @@ def derived_in_supertype(self, t):
127130

128131
def list_instance_type(self, attr):
129132
f = lambda v : 'IfcUtil::IfcAbstractSelect' if self.schema.is_select(v) else v
130-
if self.is_array(attr.type) and not isinstance(attr.type, str):
131-
return f(attr.type.type)
132-
elif self.is_array(attr.type) and isinstance(attr.type, str):
133-
return f(attr.type)
134-
else: return None
133+
if self.is_array(attr.type):
134+
if not isinstance(attr.type, str) and self.is_array(attr.type.type):
135+
if isinstance(attr.type.type, str):
136+
return f(attr.type.type)
137+
else: return f(attr.type.type.type)
138+
else:
139+
if isinstance(attr.type, str):
140+
return f(attr.type)
141+
else: return f(attr.type.type)
142+
return None
135143

136144
def is_templated_list(self, attr):
137145
ty = self.list_instance_type(attr)
@@ -163,6 +171,7 @@ def include(attr):
163171
'is_inherited' : i < num_inherited,
164172
'is_enum' : attr.type in self.schema.enumerations,
165173
'is_array' : self.is_array(attr.type),
174+
'is_nested' : self.is_array(attr.type) and not isinstance(attr.type, str) and self.is_array(attr.type.type),
166175
'is_derived' : attr.name in derived,
167176
'is_templated_list' : self.is_templated_list(attr)
168177
} for i, attr in attrs if include(attr)]

0 commit comments

Comments
 (0)