Skip to content

Commit 8581fed

Browse files
committed
Track inverse attributes more correctly
Rename Size() to size() on EntityList and friends
1 parent 1d319f7 commit 8581fed

22 files changed

+396
-402
lines changed

src/examples/IfcParseExamples.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int main(int argc, char** argv) {
5656
// defined for the window in question before accessing them.
5757
IfcBuildingElement::list::ptr elements = file.EntitiesByType<IfcBuildingElement>();
5858

59-
std::cout << "Found " << elements->Size() << " elements in " << argv[1] << ":" << std::endl;
59+
std::cout << "Found " << elements->size() << " elements in " << argv[1] << ":" << std::endl;
6060

6161
for ( IfcBuildingElement::list::it it = elements->begin(); it != elements->end(); ++ it ) {
6262

src/ifcexpressparser/implementation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@ def find_template(arg):
128128
'index' : arg['index']-1,
129129
'stmt' : impl}
130130
constructor_implementations.append(impl)
131+
132+
def get_attribute_index(entity, attr_name):
133+
related_entity = mapping.schema.entities[entity]
134+
return [a['name'] for a in mapping.get_assignable_arguments(related_entity, include_derived=True)].index(attr_name)
131135

132136
inverse = [templates.const_function % {
133137
'class_name' : name,
134138
'name' : i.name,
135139
'arguments' : '',
136140
'return_type' : '%s::list::ptr' % i.entity,
137-
'body' : templates.get_inverse % {'type': i.entity}
141+
'body' : templates.get_inverse % {'type': i.entity, 'index':get_attribute_index(i.entity, i.attribute)}
138142
} for i in (type.inverse.elements if type.inverse else [])]
139143

140144
superclass = "%s((IfcAbstractEntity*)0)" % type.supertypes[0] if len(type.supertypes) == 1 else 'IfcUtil::IfcBaseEntity()'

src/ifcexpressparser/templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class %(name)s %(superclass)s{
392392
get_attr_stmt_array = "IfcEntityList::ptr es = *entity->getArgument(%(index)d); return es->as<%(list_instance_type)s>();"
393393
get_attr_stmt_nested_array = "IfcEntityListList::ptr es = *entity->getArgument(%(index)d); return es->as<%(list_instance_type)s>();"
394394

395-
get_inverse = "return entity->getInverse(Type::%(type)s)->as<%(type)s>();"
395+
get_inverse = "return entity->getInverse(Type::%(type)s, %(index)d)->as<%(type)s>();"
396396

397397
set_attr_stmt = "if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(%(index)d,v);"
398398
set_attr_stmt_enum = "if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(%(index)d,v,%(type)s::ToString(v));"

src/ifcgeom/IfcGeomFaces.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
113113
er = mf.Error();
114114
}
115115
if ( er != BRepBuilderAPI_FaceDone ) return false;
116-
if ( bounds->Size() == 1 ) {
116+
if ( bounds->size() == 1 ) {
117117
face = mf.Face();
118118
} else {
119119
for( ++it; it != bounds->end(); ++ it) {
@@ -807,7 +807,7 @@ bool convert_surf(IfcSchema::IfcBSplineSurfaceWithKnots* l, Handle_Geom_Surface&
807807
std::vector<int> umults = l->UMultiplicities();
808808
std::vector<int> vmults = l->VMultiplicities();
809809

810-
TColgp_Array2OfPnt Poles (0, cps->Size() - 1, 0, (*cps->begin()).size() - 1);
810+
TColgp_Array2OfPnt Poles (0, cps->size() - 1, 0, (*cps->begin()).size() - 1);
811811
TColStd_Array1OfReal UKnots(0, uknots.size() - 1);
812812
TColStd_Array1OfReal VKnots(0, vknots.size() - 1);
813813
TColStd_Array1OfInteger UMults(0, umults.size() - 1);

src/ifcgeom/IfcGeomFunctions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
871871
const std::string product_type = IfcSchema::Type::ToString(product->type());
872872
ElementSettings element_settings(settings, getValue(GV_LENGTH_UNIT), product_type);
873873

874-
if ( !settings.disable_opening_subtractions() && openings && openings->Size() ) {
874+
if ( !settings.disable_opening_subtractions() && openings && openings->size() ) {
875875
IfcGeom::IfcRepresentationShapeItems opened_shapes;
876876
try {
877877
if ( settings.faster_booleans() ) {
@@ -921,15 +921,15 @@ IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchem
921921
if ( product->is(IfcSchema::Type::IfcOpeningElement ) ) {
922922
IfcSchema::IfcOpeningElement* opening = (IfcSchema::IfcOpeningElement*)product;
923923
IfcSchema::IfcRelVoidsElement::list::ptr voids = opening->VoidsElements();
924-
if ( voids->Size() ) {
924+
if ( voids->size() ) {
925925
IfcSchema::IfcRelVoidsElement* ifc_void = *voids->begin();
926926
parent = ifc_void->RelatingBuildingElement();
927927
}
928928
} else if ( product->is(IfcSchema::Type::IfcElement ) ) {
929929
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product;
930930
IfcSchema::IfcRelFillsElement::list::ptr fills = element->FillsVoids();
931931
// Incase of a RelatedBuildingElement parent to the opening element
932-
if ( fills->Size() ) {
932+
if ( fills->size() ) {
933933
for ( IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++ it ) {
934934
IfcSchema::IfcRelFillsElement* fill = *it;
935935
IfcSchema::IfcObjectDefinition* ifc_objectdef = fill->RelatingOpeningElement();
@@ -940,16 +940,16 @@ IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchem
940940
// Else simply parent to the containing structure
941941
if (!parent) {
942942
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr parents = element->ContainedInStructure();
943-
if ( parents->Size() ) {
943+
if ( parents->size() ) {
944944
IfcSchema::IfcRelContainedInSpatialStructure* container = *parents->begin();
945945
parent = container->RelatingStructure();
946946
}
947947
}
948948
}
949949
// Parent decompositions to the RelatingObject
950950
if (!parent) {
951-
IfcEntityList::ptr parents = product->entity->getInverse(IfcSchema::Type::IfcRelAggregates);
952-
parents->push(product->entity->getInverse(IfcSchema::Type::IfcRelNests));
951+
IfcEntityList::ptr parents = product->entity->getInverse(IfcSchema::Type::IfcRelAggregates, -1);
952+
parents->push(product->entity->getInverse(IfcSchema::Type::IfcRelNests, -1));
953953
for ( IfcEntityList::it it = parents->begin(); it != parents->end(); ++ it ) {
954954
IfcSchema::IfcRelDecomposes* decompose = (IfcSchema::IfcRelDecomposes*)*it;
955955
IfcSchema::IfcObjectDefinition* ifc_objectdef;
@@ -982,7 +982,7 @@ std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
982982

983983
try {
984984
IfcEntityList::ptr units = unit_assignment->Units();
985-
if (!units || !units->Size()) {
985+
if (!units || !units->size()) {
986986
Logger::Message(Logger::LOG_ERROR, "No unit information found");
987987
} else {
988988
for ( IfcEntityList::it it = units->begin(); it != units->end(); ++ it ) {

src/ifcgeom/IfcGeomIterator.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ namespace IfcGeom {
111111

112112
void initUnits() {
113113
IfcSchema::IfcProject::list::ptr projects = ifc_file->EntitiesByType<IfcSchema::IfcProject>();
114-
if (projects->Size() == 1) {
114+
if (projects->size() == 1) {
115115
IfcSchema::IfcProject* project = *projects->begin();
116116
std::pair<std::string, double> length_unit = kernel.initializeUnits(project->UnitsInContext());
117117
unit_name = length_unit.first;
@@ -162,7 +162,7 @@ namespace IfcGeom {
162162
}
163163
}
164164

165-
if (filtered_contexts->Size() == 0) {
165+
if (filtered_contexts->size() == 0) {
166166
filtered_contexts = contexts;
167167
}
168168

@@ -197,7 +197,7 @@ namespace IfcGeom {
197197
kernel.setValue(IfcGeom::Kernel::GV_PRECISION, 1.e-5);
198198
}
199199

200-
if (representations->Size() == 0) return false;
200+
if (representations->size() == 0) return false;
201201

202202
representation_iterator = representations->begin();
203203
entities.reset();
@@ -207,7 +207,7 @@ namespace IfcGeom {
207207
}
208208

209209
done = 0;
210-
total = representations->Size();
210+
total = representations->size();
211211

212212
return true;
213213
}
@@ -267,14 +267,14 @@ namespace IfcGeom {
267267

268268
// IfcProductRepresentation also lacks the INVERSE relation to IfcProduct
269269
// Let's find the IfcProducts that reference the IfcProductRepresentation anyway
270-
IfcEntityList::ptr products = (*it)->entity->getInverse(IfcSchema::Type::IfcProduct);
270+
IfcEntityList::ptr products = (*it)->entity->getInverse(IfcSchema::Type::IfcProduct, -1);
271271
for ( IfcEntityList::it it = products->begin(); it != products->end(); ++ it ) {
272272
entities->push((IfcSchema::IfcProduct*)*it);
273273
}
274274
}
275275
}
276276
// Does this representation have any IfcProducts?
277-
if ( ! entities->Size() ) {
277+
if ( ! entities->size() ) {
278278
_nextShape();
279279
continue;
280280
}

src/ifcgeom/IfcGeomShapes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
384384
bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Shape& shape) {
385385
IfcSchema::IfcFace::list::ptr faces = l->CfsFaces();
386386
bool facesAdded = false;
387-
const unsigned int num_faces = faces->Size();
387+
const unsigned int num_faces = faces->size();
388388
bool valid_shell = false;
389389
if ( num_faces < getValue(GV_MAX_FACES_TO_SEW) ) {
390390
BRepOffsetAPI_Sewing builder;
@@ -488,7 +488,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcMappedItem* l, IfcRepresentati
488488
bool IfcGeom::Kernel::convert(const IfcSchema::IfcShapeRepresentation* l, IfcRepresentationShapeItems& shapes) {
489489
IfcSchema::IfcRepresentationItem::list::ptr items = l->Items();
490490
bool part_succes = false;
491-
if ( items->Size() ) {
491+
if ( items->size() ) {
492492
for ( IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++ it ) {
493493
IfcSchema::IfcRepresentationItem* representation_item = *it;
494494
if ( is_shape_collection(representation_item) ) {
@@ -507,7 +507,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcShapeRepresentation* l, IfcRep
507507

508508
bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresentationShapeItems& shapes) {
509509
IfcEntityList::ptr elements = l->Elements();
510-
if ( !elements->Size() ) return false;
510+
if ( !elements->size() ) return false;
511511
bool part_succes = false;
512512
const IfcGeom::SurfaceStyle* parent_style = get_style(l);
513513
for ( IfcEntityList::it it = elements->begin(); it != elements->end(); ++ it ) {

0 commit comments

Comments
 (0)