Skip to content

Commit 44ddc5e

Browse files
committed
Don't use IfcMappedItems for IfcOpenHouse walls, as suggested by Ian Clévy in https://sourceforge.net/p/ifcopenshell/discussion/1782716/thread/f9b586ca/?limit=25#ab87
1 parent c7ddc06 commit 44ddc5e

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

src/examples/IfcOpenHouse.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -195,43 +195,46 @@ int main(int argc, char** argv) {
195195
file.addBuildingProduct(north_wall);
196196
file.setSurfaceColour(north_wall->Representation(), wall_colour);
197197

198-
IfcSchema::IfcShapeRepresentation* clipped_wall_body_rep = file.addEmptyRepresentation();
199-
file.addBox(clipped_wall_body_rep, 5000, 360, 6000);
200-
// The east wall geometry is clipped using two IfcHalfSpaceSolids, created from an
201-
// 'axis 3d placement' that specifies the plane against which the geometry is clipped.
202-
file.clipRepresentation(clipped_wall_body_rep, file.addPlacement3d(-2500, 0, 3000, -1, 0, 1), false);
203-
file.clipRepresentation(clipped_wall_body_rep, file.addPlacement3d(2500, 0, 3000, 1, 0, 1), false);
198+
// Two identical representations are created for the two remaining walls. Mapped items
199+
// are not used, because it is not allowed by the standard for wall body representations.
200+
// MappedItems are not allowed for Axis representations as per CV-2x3-161
201+
IfcSchema::IfcProductDefinitionShape* clipped_wall_body_reps[2];
202+
for (int i = 0; i < 2; ++i) {
203+
IfcSchema::IfcShapeRepresentation* body = file.addEmptyRepresentation();
204+
file.addBox(body, 5000, 360, 6000);
205+
// The wall geometry is clipped using two IfcHalfSpaceSolids, created from an
206+
// 'axis 3d placement' that specifies the plane against which the geometry is clipped.
207+
file.clipRepresentation(body, file.addPlacement3d(-2500, 0, 3000, -1, 0, 1), false);
208+
file.clipRepresentation(body, file.addPlacement3d(2500, 0, 3000, 1, 0, 1), false);
209+
file.setSurfaceColour(body, wall_colour);
210+
211+
IfcSchema::IfcShapeRepresentation* axis = file.addEmptyRepresentation("Axis", "Curve2D");
212+
file.addAxis(axis, 5000);
213+
214+
IfcSchema::IfcRepresentation::list::ptr reps(new IfcSchema::IfcRepresentation::list);
215+
reps->push(body);
216+
reps->push(axis);
217+
clipped_wall_body_reps[i] = new IfcSchema::IfcProductDefinitionShape(null, null, reps);
218+
}
204219

205220
// Now create a wall on the east of the building, again starting with just a box shape
206221
IfcSchema::IfcWallStandardCase* east_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
207-
S("East wall"), null, null, file.addLocalPlacement(storey_placement, 4820, 2500, 0, 0, 0, 1, 0, 1, 0), file.addMappedItem(clipped_wall_body_rep), null
222+
S("East wall"), null, null, file.addLocalPlacement(storey_placement, 4820, 2500, 0, 0, 0, 1, 0, 1, 0), clipped_wall_body_reps[0], null
208223
#ifdef USE_IFC4
209224
, IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD
210225
#endif
211226
);
212227
file.addBuildingProduct(east_wall);
213228

214-
file.setSurfaceColour(clipped_wall_body_rep, wall_colour);
215-
216229
// The east wall is copied to the west location of the house
217230
IfcSchema::IfcWallStandardCase* west_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
218-
S("West wall"), null, null, file.addLocalPlacement(storey_placement, -4820, 2500, 0, 0, 0, 1, 0, -1, 0), file.addMappedItem(clipped_wall_body_rep), null
231+
S("West wall"), null, null, file.addLocalPlacement(storey_placement, -4820, 2500, 0, 0, 0, 1, 0, -1, 0), clipped_wall_body_reps[1], null
219232
#ifdef USE_IFC4
220233
, IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD
221234
#endif
222235
);
223236
file.addBuildingProduct(west_wall);
224237

225-
for (int i = 0; i < 2; ++i) {
226-
// CV-2x3-161: MappedItems are not allowed for Axis representations
227-
IfcSchema::IfcWallStandardCase* wall = i == 0 ? east_wall : west_wall;
228-
IfcSchema::IfcShapeRepresentation* wall_axis_rep = file.addEmptyRepresentation("Axis", "Curve2D");
229-
file.addAxis(wall_axis_rep, 5000);
230-
IfcSchema::IfcRepresentation::list::ptr reps = wall->Representation()->Representations();
231-
reps->push(wall_axis_rep);
232-
wall->Representation()->setRepresentations(reps);
233-
}
234-
235238
// The west wall is assigned an opening element we created for the south wall, opening elements are
236239
// not shared accross building elements, even if they share the same representation. Hence, the east
237240
// wall will not feature this opening.

0 commit comments

Comments
 (0)