Merge remote-tracking branch 'origin/v0.8.0' into ifcviewer-wgpu

This commit is contained in:
Thomas Krijnen
2026-07-09 13:21:39 +02:00
373 changed files with 22411 additions and 4242 deletions
+21
View File
@@ -36,7 +36,17 @@ else()
endif()
macro(build_example exe_name)
set(_target_schema "")
set(additional_targets ${ARGN})
list(LENGTH additional_targets _argc)
if(_argc GREATER 0)
list(GET additional_targets 0 _first_arg)
if("${_first_arg}" IN_LIST SCHEMA_VERSIONS)
set(_target_schema ${_first_arg})
list(REMOVE_AT additional_targets 0)
endif()
endif()
add_executable(${exe_name} ${exe_name}.cpp)
if(STANDALONE_PROJECT)
@@ -50,6 +60,17 @@ macro(build_example exe_name)
target_link_libraries(${exe_name} IfcParse ${additional_targets})
set_target_properties(${exe_name} PROPERTIES FOLDER Examples)
endif()
if(_target_schema)
set_target_properties(
${exe_name}
PROPERTIES COMPILE_FLAGS "-DIfcSchema=Ifc${_target_schema}"
)
endif()
unset(_target_schema)
unset(_argc)
unset(_first_arg)
install(TARGETS ${exe_name})
endmacro()
+10 -3
View File
@@ -38,10 +38,17 @@
#include <Standard_Version.hxx>
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#include "../ifcparse/macros.h"
#include "../ifcparse/schemas/Ifc2x3.h"
#include "../ifcparse/hierarchy_helper.h"
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcBaseClass.h"
#include "ifcparse/IfcHierarchyHelper.h"
#include "../ifcgeom/Serialization/Serialization.h"
+219 -245
View File
@@ -35,10 +35,17 @@
#include <Precision.hxx>
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#include "../ifcparse/macros.h"
#include "../ifcparse/schemas/Ifc2x3.h"
#include "../ifcparse/hierarchy_helper.h"
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcBaseClass.h"
#include "ifcparse/IfcHierarchyHelper.h"
#include "../ifcgeom/Serialization/Serialization.h"
@@ -51,6 +58,11 @@ using namespace std::string_literals;
// Some convenience typedefs and definitions.
typedef ifcopenshell::global_id guid;
typedef std::pair<double, double> XY;
#ifdef SCHEMA_HAS_IfcPresentationStyleAssignment
typedef IfcSchema::IfcPresentationStyleAssignment surface_style_t;
#else
typedef IfcSchema::IfcPresentationStyle surface_style_t;
#endif
boost::none_t const null = boost::none;
// The creation of Nurbs-surface for the IfcSite mesh, to be implemented lateron
@@ -63,12 +75,18 @@ int main() {
hierarchy_helper<IfcSchema> file;
file.header().file_name().setname("IfcOpenHouse.ifc");
// Start by adding a wall to the file, initially leaving most attributes blank.
auto south_wall = file.create<IfcSchema::IfcWallStandardCase>();
south_wall.setGlobalId(guid());
south_wall.setName("South wall");
#ifdef USE_IFC4
south_wall.setPredefinedType(IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD);
// Start by adding a wall to the file, initially leaving most attributes blank.
IfcSchema::IfcWallStandardCase* south_wall = new IfcSchema::IfcWallStandardCase(
guid(), // GlobalId
0, // OwnerHistory
"South wall"s, // Name
null, // Description
null, // ObjectType
0, // ObjectPlacement
0, // Representation
null // Tag
#ifdef SCHEMA_IfcWall_HAS_PredefinedType
, IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD
#endif
file.addBuildingProduct(south_wall);
@@ -96,8 +114,8 @@ int main() {
south_wall.setRepresentation(south_wall_shape);
south_wall.setObjectPlacement(file.addLocalPlacement(storey_placement));
// A pale white colour is assigned to the wall.
auto wall_colour = setSurfaceColour(file, south_wall_shape, 0.75, 0.73, 0.68);
// A pale white colour is assigned to the wall.
surface_style_t* wall_colour = setSurfaceColour(file, south_wall_shape, 0.75, 0.73, 0.68);
// Now create a footing for the wall to rest on.
auto footing = file.create<IfcSchema::IfcFooting>();
@@ -108,26 +126,24 @@ int main() {
file.addBuildingProduct(footing);
// The footing will span the entire floor plan of our building. The IfcRepresentationContext is
// something that has been created automatically as well, but representations could have been
// assigned to a specific context, for example to add a two dimensional plan representation as well.
footing.setRepresentation(file.addBox(10100, 5460, 2000));
footing.setObjectPlacement(file.addLocalPlacement(storey_placement, 0, 2500, -2000));
// The footing will have a dark gray colour
auto footing_colour = setSurfaceColour(file, footing.Representation(), 0.26, 0.22, 0.18);
// The footing will span the entire floor plan of our building. The IfcRepresentationContext is
// something that has been created automatically as well, but representations could have been
// assigned to a specific context, for example to add a two dimensional plan representation as well.
footing->setRepresentation(file.addBox(10100, 5460, 2000));
footing->setObjectPlacement(file.addLocalPlacement(storey_placement, 0, 2500, -2000));
// The footing will have a dark gray colour
surface_style_t* footing_colour = setSurfaceColour(file,footing->Representation(), 0.26, 0.22, 0.18);
// IFC has two ways to apply boolean operations to geometry. IfcBooleanResults are commonly used
// to clip geometry to a surface, for example to a slanted roof. For openings that are filled
// with another element, for example a door or a window, an IfcOpeningElement is used instead.
// An opening element is created with rectangular geometry:
auto west_opening = file.create<IfcSchema::IfcOpeningElement>();
west_opening.setGlobalId(guid());
west_opening.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
west_opening.setObjectPlacement(file.addLocalPlacement(south_wall.ObjectPlacement(), -2500, 0, 400));
west_opening.setRepresentation(file.addBox(6000, 3630, 1600));
#ifdef USE_IFC4
west_opening.setPredefinedType(IfcSchema::IfcOpeningElementTypeEnum::IfcOpeningElementType_OPENING);
// An opening element is created with rectangular geometry:
IfcSchema::IfcOpeningElement* west_opening = new IfcSchema::IfcOpeningElement(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
null, null, null, file.addLocalPlacement(south_wall->ObjectPlacement(), -2500, 0, 400),
file.addBox(6000, 3630, 1600), null
#ifdef SCHEMA_IfcOpeningElement_HAS_PredefinedType
, IfcSchema::IfcOpeningElementTypeEnum::IfcOpeningElementType_OPENING
#endif
// Relate the opening element to the wall.
@@ -137,14 +153,12 @@ int main() {
void_element.setRelatingBuildingElement(south_wall);
void_element.setRelatedOpeningElement(west_opening);
// Now create an additional opening
auto south_opening = file.create<IfcSchema::IfcOpeningElement>();
south_opening.setGlobalId(guid());
south_opening.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
south_opening.setObjectPlacement(file.addLocalPlacement(storey_placement, 3000, 0, 400));
south_opening.setRepresentation(file.addBox(1860, 3000, 1600));
#ifdef USE_IFC4
south_opening.setPredefinedType(IfcSchema::IfcOpeningElementTypeEnum::IfcOpeningElementType_OPENING);
// Now create an additional opening
IfcSchema::IfcOpeningElement* south_opening = new IfcSchema::IfcOpeningElement(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
null, null, null, file.addLocalPlacement(storey_placement, 3000, 0, 400),
file.addBox(1860, 3000, 1600), null
#ifdef SCHEMA_IfcOpeningElement_HAS_PredefinedType
, IfcSchema::IfcOpeningElementTypeEnum::IfcOpeningElementType_OPENING
#endif
// Relate the opening element to the wall.
@@ -154,17 +168,46 @@ int main() {
void_element2.setRelatingBuildingElement(south_wall);
void_element2.setRelatedOpeningElement(south_opening);
// Create a roof element that will consist of two slabs:
auto roof = file.create<IfcSchema::IfcRoof>();
roof.setGlobalId(guid());
roof.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
roof.setName("Roof");
roof.setObjectPlacement(file.addLocalPlacement(storey_placement));
#ifdef USE_IFC4
roof.setPredefinedType(IfcSchema::IfcRoofTypeEnum::IfcRoofType_GABLE_ROOF);
#else
roof.setShapeType(IfcSchema::IfcRoofTypeEnum::IfcRoofType_GABLE_ROOF);
#endif
// CV-2x3-144: Roofs are aggregates and shall have at least one contained element and no own geometry
IfcSchema::IfcSlab* south_roof_part = new IfcSchema::IfcSlab(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), "South roof"s,
null, null, 0, 0, null, IfcSchema::IfcSlabTypeEnum::IfcSlabType_ROOF);
// The geometry is instantiated by using IfcMappedItems. This way geometry definitions can
// be reused while maintaining the cardinality constraint that the ShapeOfProduct relation
// imposes on the IfcProductDefinitionShape. Note that this constrained is lifted in IFC4.
south_roof_part->setRepresentation(file.addMappedItem(roof_rep));
south_roof_part->setObjectPlacement(file.addLocalPlacement(roof->ObjectPlacement(), 0, -400, 2700));
// The same roof geometry is re-used on the north side of the roof, by inverting the X-axis of
// the local placement the roof is rotated 180 degrees around the Z-axis
IfcSchema::IfcSlab* north_roof_part = new IfcSchema::IfcSlab(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), "North roof"s,
null, null, 0, 0, null, IfcSchema::IfcSlabTypeEnum::IfcSlabType_ROOF);
north_roof_part->setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
north_roof_part->setRepresentation(file.addMappedItem(roof_rep));
north_roof_part->setObjectPlacement(file.addLocalPlacement(roof->ObjectPlacement(), 0, 5400, 2700, 0, 0, 1, -1, 0, 0));
IfcSchema::IfcObjectDefinition::list::ptr roof_parts(new IfcSchema::IfcObjectDefinition::list);
roof_parts->push(south_roof_part);
roof_parts->push(north_roof_part);
IfcSchema::IfcRelDecomposes* roof_decomposition = new IfcSchema::IfcRelAggregates(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
null, null, roof, roof_parts);
file.addEntity(roof_decomposition);
file.addBuildingProduct(south_roof_part);
file.addBuildingProduct(north_roof_part);
file.addBuildingProduct(roof);
setSurfaceColour(file, roof_rep, 0.24, 0.08, 0.04);
// Copy the south wall to the north
IfcSchema::IfcWallStandardCase* north_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), "North wall"s,
null, null, file.addLocalPlacement(storey_placement, 0, 5000, 0), file.addAxisBox(10000, 360, 3000), null
#ifdef SCHEMA_IfcWall_HAS_PredefinedType
, IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD
#endif
);
file.addBuildingProduct(north_wall);
setSurfaceColour(file,north_wall->Representation(), wall_colour);
// The roof geometry is slanted 45 degrees by specifying a direction for the box extrusion
auto roof_rep = file.addEmptyRepresentation();
@@ -183,116 +226,38 @@ int main() {
south_roof_part.setRepresentation(file.addMappedItem(roof_rep));
south_roof_part.setObjectPlacement(file.addLocalPlacement(roof.ObjectPlacement(), 0, -400, 2700));
// The same roof geometry is re-used on the north side of the roof, by inverting the X-axis of
// the local placement the roof is rotated 180 degrees around the Z-axis
auto north_roof_part = file.create<IfcSchema::IfcSlab>();
north_roof_part.setGlobalId(guid());
north_roof_part.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
north_roof_part.setName("North roof");
north_roof_part.setPredefinedType(IfcSchema::IfcSlabTypeEnum::IfcSlabType_ROOF);
// Now create a wall on the east of the building, again starting with just a box shape
IfcSchema::IfcWallStandardCase* east_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
"East wall"s, null, null, file.addLocalPlacement(storey_placement, 4820, 2500, 0, 0, 0, 1, 0, 1, 0), clipped_wall_body_reps[0], null
#ifdef SCHEMA_IfcWall_HAS_PredefinedType
, IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD
#endif
);
file.addBuildingProduct(east_wall);
north_roof_part.setRepresentation(file.addMappedItem(roof_rep));
north_roof_part.setObjectPlacement(file.addLocalPlacement(roof.ObjectPlacement(), 0, 5400, 2700, 0, 0, 1, -1, 0, 0));
{
auto rel = file.create<IfcSchema::IfcRelAggregates>();
rel.setGlobalId(guid());
rel.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
rel.setRelatingObject(roof);
rel.setRelatedObjects({south_roof_part, north_roof_part});
}
file.addBuildingProduct(south_roof_part);
file.addBuildingProduct(north_roof_part);
file.addBuildingProduct(roof);
setSurfaceColour(file, roof_rep, 0.24, 0.08, 0.04);
// Copy the south wall to the north
auto north_wall = file.create<IfcSchema::IfcWallStandardCase>();
north_wall.setGlobalId(guid());
north_wall.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
north_wall.setName("North wall");
north_wall.setObjectPlacement(file.addLocalPlacement(storey_placement, 0, 5000, 0));
north_wall.setRepresentation(file.addAxisBox(10000, 360, 3000));
#ifdef USE_IFC4
north_wall.setPredefinedType(IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD);
#endif
file.addBuildingProduct(north_wall);
setSurfaceColour(file, north_wall.Representation(), wall_colour);
// Two identical representations are created for the two remaining walls. Mapped items
// are not used, because it is not allowed by the standard for wall body representations.
// MappedItems are not allowed for Axis representations as per CV-2x3-161
IfcSchema::IfcProductDefinitionShape clipped_wall_body_reps[2];
for (int i = 0; i < 2; ++i) {
auto body = file.addEmptyRepresentation();
file.addBox(body, 5000, 360, 6000);
// The wall geometry is clipped using two IfcHalfSpaceSolids, created from an
// 'axis 3d placement' that specifies the plane against which the geometry is clipped.
file.clipRepresentation(body, file.addPlacement3d(-2500, 0, 3000, -1, 0, 1), false);
file.clipRepresentation(body, file.addPlacement3d(2500, 0, 3000, 1, 0, 1), false);
setSurfaceColour(file, body, wall_colour);
auto axis = file.addEmptyRepresentation("Axis", "Curve2D");
file.addAxis(axis, 5000);
clipped_wall_body_reps[i] = file.create<IfcSchema::IfcProductDefinitionShape>();
clipped_wall_body_reps[i].setRepresentations({body, axis});
}
// Now create a wall on the east of the building, again starting with just a box shape
auto east_wall = file.create<IfcSchema::IfcWallStandardCase>();
east_wall.setGlobalId(guid());
east_wall.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
east_wall.setName("East wall");
east_wall.setObjectPlacement(file.addLocalPlacement(storey_placement, 4820, 2500, 0, 0, 0, 1, 0, 1, 0));
east_wall.setRepresentation(clipped_wall_body_reps[0]);
#ifdef USE_IFC4
east_wall.setPredefinedType(IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD);
#endif
// The east wall is copied to the west location of the house
IfcSchema::IfcWallStandardCase* west_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
"West wall"s, null, null, file.addLocalPlacement(storey_placement, -4820, 2500, 0, 0, 0, 1, 0, -1, 0), clipped_wall_body_reps[1], null
#ifdef SCHEMA_IfcWall_HAS_PredefinedType
, IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD
#endif
);
file.addBuildingProduct(west_wall);
file.addBuildingProduct(east_wall);
// The east wall is copied to the west location of the house
auto west_wall = file.create<IfcSchema::IfcWallStandardCase>();
west_wall.setGlobalId(guid());
west_wall.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
west_wall.setName("West wall");
west_wall.setObjectPlacement(file.addLocalPlacement(storey_placement, -4820, 2500, 0, 0, 0, 1, 0, -1, 0));
west_wall.setRepresentation(clipped_wall_body_reps[1]);
#ifdef USE_IFC4
west_wall.setPredefinedType(IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD);
#endif
file.addBuildingProduct(west_wall);
// The west wall is assigned an opening element we created for the south wall, opening elements are
// not shared across building elements, even if they share the same representation. Hence, the east
// wall will not feature this opening.
// NB: an Opening Element can only be used to create a single void within a single Element, as per:
// http://www.buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcproductextension/lexical/ifcfeatureelementsubtraction.htm
// Not all viewers support opening elements with mapped representations, hence an exact copy of the
// same subtraction box is instantiated for the otherwise identical opening element.
auto west_opening_copy = file.create<IfcSchema::IfcOpeningElement>();
west_opening_copy.setGlobalId(guid());
west_opening_copy.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
west_opening_copy.setObjectPlacement(file.addLocalPlacement(west_wall.ObjectPlacement(), 2500, -2500 + 4820, 400, 0, 0, 1, 0, 1, 0));
west_opening_copy.setRepresentation(file.addBox(6000, 3630, 1600));
#ifdef USE_IFC4
west_opening_copy.setPredefinedType(IfcSchema::IfcOpeningElementTypeEnum::IfcOpeningElementType_OPENING);
#endif
{
auto rel = file.create<IfcSchema::IfcRelVoidsElement>();
rel.setGlobalId(guid());
rel.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
rel.setRelatingBuildingElement(west_wall);
rel.setRelatedOpeningElement(west_opening_copy);
}
// Not all viewers support opening elements with mapped representations, hence an exact copy of the
// same subtraction box is instantiated for the otherwise identical opening element.
IfcSchema::IfcOpeningElement* west_opening_copy = new IfcSchema::IfcOpeningElement(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
null, null, null, file.addLocalPlacement(west_wall->ObjectPlacement(), 2500, -2500+4820, 400, 0, 0, 1, 0, 1, 0),
file.addBox(6000, 3630, 1600), null
#ifdef SCHEMA_IfcOpeningElement_HAS_PredefinedType
, IfcSchema::IfcOpeningElementTypeEnum::IfcOpeningElementType_OPENING
#endif
);
file.addEntity(west_opening_copy);
file.addEntity(new IfcSchema::IfcRelVoidsElement(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), null, null, west_wall, west_opening_copy));
// Up until now we have only used simple extrusions for the creation of the geometry. For the
// ground mesh of the IfcSite we will use a Nurbs surface created in Open Cascade. The surface
// will be tessellated using the deflection specified.
@@ -305,11 +270,17 @@ int main() {
BRepGProp::SurfaceProperties(shape, prop);
const double site_area = prop.Mass() / 1000 / 1000;
auto total_area = file.create<IfcSchema::IfcPropertySingleValue>();
total_area.setName("TotalArea");
auto area = file.create<IfcSchema::IfcAreaMeasure>();
area.set_attribute_value(0, site_area);
total_area.setNominalValue(area);
IfcSchema::IfcProperty::list::ptr properties(new IfcSchema::IfcProperty::list);
properties->push(new IfcSchema::IfcPropertySingleValue("TotalArea", null, new IfcSchema::IfcAreaMeasure(site_area), 0));
IfcSchema::IfcPropertySet* pset = new IfcSchema::IfcPropertySet(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), "Pset_SiteCommon"s, null, properties);
#ifdef SCHEMA_HAS_IfcDefinitionSelect
IfcSchema::IfcObjectDefinition::list::ptr related_objs(new IfcSchema::IfcObjectDefinition::list);
#else
IfcSchema::IfcObject::list::ptr related_objs(new IfcSchema::IfcObject::list);
#endif
related_objs->push(file.getSingle<IfcSchema::IfcSite>());
IfcSchema::IfcRelDefinesByProperties* site_prop = new IfcSchema::IfcRelDefinesByProperties(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), null, null, related_objs, pset);
file.addEntity(site_prop);
auto pset = file.create<IfcSchema::IfcPropertySet>();
pset.setGlobalId(guid());
@@ -337,12 +308,52 @@ int main() {
// Some BIM authoring applications, such as Autodesk Revit, ignore the geometrical representation
// by and large and construct native walls using the layer thickness and reference line offset
// provided here.
auto material = file.create<IfcSchema::IfcMaterial>();
material.setName("Brick");
#ifdef SCHEMA_IfcMaterial_HAS_Description
IfcSchema::IfcMaterial* material = new IfcSchema::IfcMaterial("Brick", null, null);
#else
IfcSchema::IfcMaterial* material = new IfcSchema::IfcMaterial("Brick");
#endif
IfcSchema::IfcMaterialLayer* layer = new IfcSchema::IfcMaterialLayer(
material,
360,
null
#ifdef SCHEMA_IfcMaterialLayer_HAS_Name
, null
, null
, null
, null
#endif
);
IfcSchema::IfcMaterialLayer::list::ptr layers (new aggregate_of<IfcSchema::IfcMaterialLayer>());
layers->push(layer);
IfcSchema::IfcMaterialLayerSet* layer_set = new IfcSchema::IfcMaterialLayerSet(
layers,
"Wall"s
#ifdef SCHEMA_IfcMaterialLayerSet_HAS_Description
, null
#endif
);
IfcSchema::IfcMaterialLayerSetUsage* layer_usage = new IfcSchema::IfcMaterialLayerSetUsage(
layer_set,
IfcSchema::IfcLayerSetDirectionEnum::IfcLayerSetDirection_AXIS2,
IfcSchema::IfcDirectionSenseEnum::IfcDirectionSense_POSITIVE,
-180
#ifdef SCHEMA_IfcMaterialLayerSetUsage_HAS_ReferenceExtent
, null
#endif
);
auto layer = file.create<IfcSchema::IfcMaterialLayer>();
layer.setMaterial(material);
layer.setLayerThickness(360);
IfcSchema::IfcRelAssociatesMaterial* associates_material = new IfcSchema::IfcRelAssociatesMaterial(
guid(),
file.getSingle<IfcSchema::IfcOwnerHistory>(),
null,
null,
#ifdef SCHEMA_HAS_IfcDefinitionSelect
file.instances_by_type<IfcSchema::IfcWallStandardCase>()->as<IfcSchema::IfcDefinitionSelect>(),
#else
file.instances_by_type<IfcSchema::IfcWallStandardCase>()->as<IfcSchema::IfcRoot>(),
#endif
layer_usage);
auto layer_set = file.create<IfcSchema::IfcMaterialLayerSet>();
layer_set.setMaterialLayers({layer});
@@ -369,53 +380,34 @@ int main() {
stair_points.push_back(XY(500, 200));
stair_points.push_back(XY(500, 400));
stair_points.push_back(XY( 0, 400));
auto stair = file.create<IfcSchema::IfcStairFlight>();
stair.setGlobalId(guid());
stair.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
stair.setObjectPlacement(file.addLocalPlacement(storey_placement, 5050, 1000, 0, 0, 1, 0, 1, 0, 0));
stair.setRepresentation(file.addExtrudedPolyline(stair_points, 1200));
#ifdef USE_IFC4
stair.setNumberOfRisers(2);
#else
stair.setNumberOfRiser(2);
#endif
stair.setNumberOfTreads(2);
stair.setRiserHeight(0.2);
stair.setTreadLength(0.25);
#ifdef USE_IFC4
stair.setPredefinedType(IfcSchema::IfcStairFlightTypeEnum::IfcStairFlightType_STRAIGHT);
IfcSchema::IfcStairFlight* stair = new IfcSchema::IfcStairFlight(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
null, null, null, file.addLocalPlacement(storey_placement, 5050, 1000, 0, 0, 1, 0, 1, 0, 0),
file.addExtrudedPolyline(stair_points, 1200), null, 2, 2, 0.2, 0.25
#ifdef SCHEMA_IfcStairFlight_HAS_PredefinedType
, IfcSchema::IfcStairFlightTypeEnum::IfcStairFlightType_STRAIGHT
#endif
file.addBuildingProduct(stair);
setSurfaceColour(file, stair.Representation(), footing_colour);
auto door_opening = file.create<IfcSchema::IfcOpeningElement>();
door_opening.setGlobalId(guid());
door_opening.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
door_opening.setObjectPlacement(file.addLocalPlacement(storey_placement, 5000 - 180, 2500 - 900, 0));
door_opening.setRepresentation(file.addBox(1000, 1000, 2200));
#ifdef USE_IFC4
door_opening.setPredefinedType(IfcSchema::IfcOpeningElementTypeEnum::IfcOpeningElementType_OPENING);
#endif
auto rel3 = file.create<IfcSchema::IfcRelVoidsElement>();
rel3.setGlobalId(guid());
rel3.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
rel3.setRelatingBuildingElement(east_wall);
rel3.setRelatedOpeningElement(door_opening);
IfcSchema::IfcOpeningElement* door_opening = new IfcSchema::IfcOpeningElement(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
null, null, null, file.addLocalPlacement(storey_placement, 5000-180, 2500-900, 0), file.addBox(1000, 1000, 2200), null
#ifdef SCHEMA_IfcOpeningElement_HAS_PredefinedType
, IfcSchema::IfcOpeningElementTypeEnum::IfcOpeningElementType_OPENING
#endif
);
file.addEntity(door_opening);
file.addEntity(new IfcSchema::IfcRelVoidsElement(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), null, null, east_wall, door_opening));
// A single shape representation can contain multiple representiation items. This way a product
// can be a composition of multiple solids. The following door will be composed of four boxes
// which constitute the door and its frame.
auto door = file.create<IfcSchema::IfcDoor>();
door.setGlobalId(guid());
door.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
door.setObjectPlacement(file.addLocalPlacement(storey_placement, 4800, 1600, 0, 0, 0, 1, 0, 1, 0));
door.setOverallWidth(1000);
door.setOverallHeight(2200);
#ifdef USE_IFC4
door.setPredefinedType(IfcSchema::IfcDoorTypeEnum::IfcDoorType_DOOR);
door.setOperationType(IfcSchema::IfcDoorTypeOperationEnum::IfcDoorTypeOperation_SINGLE_SWING_LEFT);
IfcSchema::IfcDoor* door = new IfcSchema::IfcDoor(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), null, null, null,
file.addLocalPlacement(storey_placement, 4800, 1600, 0, 0, 0, 1, 0, 1, 0), 0, null, 2200, 1000
#ifdef SCHEMA_IfcDoor_HAS_PredefinedType
, IfcSchema::IfcDoorTypeEnum::IfcDoorType_DOOR
, IfcSchema::IfcDoorTypeOperationEnum::IfcDoorTypeOperation_SINGLE_SWING_LEFT
, null
#endif
door.setRepresentation(file.addBox(80, 80, 2120, IfcSchema::IfcAxis2Placement2D{}, file.addPlacement3d(460, 0, 0)));
@@ -433,27 +425,15 @@ int main() {
file.addBox(door_body, 860, 30, 2120);
file.addBuildingProduct(door);
setSurfaceColour(file, door.Representation(), 0.9, 0.9, 0.9);
{
auto rel = file.create<IfcSchema::IfcRelFillsElement>();
rel.setGlobalId(guid());
rel.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
rel.setRelatingOpeningElement(door_opening);
rel.setRelatedBuildingElement(door);
}
auto door_style = file.create<IfcSchema::IfcDoorStyle>();
door_style.setGlobalId(guid());
door_style.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
door_style.setName("Door type");
door_style.setOperationType(IfcSchema::IfcDoorStyleOperationEnum::IfcDoorStyleOperation_SINGLE_SWING_LEFT);
door_style.setConstructionType(IfcSchema::IfcDoorStyleConstructionEnum::IfcDoorStyleConstruction_WOOD);
door_style.setParameterTakesPrecedence(false);
door_style.setSizeable(false);
// NOTE: typing by IfcDoorStyle will cause validation errors in IFC4+ but it's allowed for backwards compatibility
// better to use IfcDoorType in the actual use case
#ifdef SCHEMA_HAS_IfcDoorType
IfcSchema::IfcDoorType* door_type = new IfcSchema::IfcDoorType(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), "Door type"s, null, null, null, null, null, null,
IfcSchema::IfcDoorTypeEnum::IfcDoorType_DOOR, IfcSchema::IfcDoorTypeOperationEnum::IfcDoorTypeOperation_SINGLE_SWING_LEFT, false, null);
file.addRelatedObject<IfcSchema::IfcRelDefinesByType>(door_type, door);
#elif defined(SCHEMA_HAS_IfcDoorStyle)
IfcSchema::IfcDoorStyle* door_style = new IfcSchema::IfcDoorStyle(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), "Door type"s, null, null, null, null, null,
IfcSchema::IfcDoorStyleOperationEnum::IfcDoorStyleOperation_SINGLE_SWING_LEFT, IfcSchema::IfcDoorStyleConstructionEnum::IfcDoorStyleConstruction_WOOD, false, false);
file.addRelatedObject<IfcSchema::IfcRelDefinesByType>(door_style, door);
#endif
// Surface styles are assigned to representation items, hence there is no real limitation to
// assign different colours within the same representation. However, some viewers have
@@ -479,8 +459,8 @@ int main() {
frame_representations.push_back(vertical_bar); // Add another reference to the vertical bar created above
// The beams all have the same surface style assigned
IfcSchema::IfcPresentationStyleAssignment frame_style;
for (auto i = frame_representations.begin(); i != frame_representations.end(); i += 2) {
surface_style_t* frame_style = 0;
for (IfcSchema::IfcShapeRepresentation::list::it i = frame_representations->begin(); i != frame_representations->end(); i += 2) {
if (frame_style) {
setSurfaceColour(file, *i, frame_style);
} else {
@@ -498,16 +478,16 @@ int main() {
window_placements.push_back(file.addLocalPlacement(storey_placement, 3000-930, -45, 400));
window_placements.push_back(file.addLocalPlacement(storey_placement, -4855+45, 885-930, 400, 0, 0, 1, 0, 1, 0));
for (auto& place : window_placements) {
auto window = file.create<IfcSchema::IfcWindow>();
window.setGlobalId(guid());
window.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
window.setObjectPlacement(place);
window.setOverallWidth(1860);
window.setOverallHeight(1600);
#ifdef USE_IFC4
window.setPredefinedType(IfcSchema::IfcWindowTypeEnum::IfcWindowType_WINDOW);
window.setPartitioningType(IfcSchema::IfcWindowTypePartitioningEnum::IfcWindowTypePartitioning_SINGLE_PANEL);
for (IfcSchema::IfcLocalPlacement::list::it it = window_placements->begin(); it != window_placements->end(); ++it) {
// Create the window at the current location
IfcSchema::IfcLocalPlacement* place = *it;
IfcSchema::IfcWindow* window = new IfcSchema::IfcWindow(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
null, null, null, place, 0, null, 1600, 1860
#ifdef SCHEMA_IfcWindow_HAS_PredefinedType
, IfcSchema::IfcWindowTypeEnum::IfcWindowType_WINDOW
, IfcSchema::IfcWindowTypePartitioningEnum::IfcWindowTypePartitioning_SINGLE_PANEL
, null
#endif
file.addBuildingProduct(window);
@@ -529,26 +509,20 @@ int main() {
frame_placement != frame_placements.end() && frame_representation != frame_representations.end();
++frame_placement, ++frame_representation)
{
auto frame_part = file.create<IfcSchema::IfcMember>();
frame_part.setGlobalId(guid());
frame_part.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
frame_part.setObjectPlacement(*frame_placement);
frame_part.setRepresentation(file.addMappedItem(*frame_representation));
#ifdef USE_IFC4
frame_part.setPredefinedType(IfcSchema::IfcMemberTypeEnum::IfcMemberType_MULLION);
IfcSchema::IfcMember* frame_part = new IfcSchema::IfcMember(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
null, null, null, *frame_placement, file.addMappedItem(*frame_representation), null
#ifdef SCHEMA_IfcMember_HAS_PredefinedType
, IfcSchema::IfcMemberTypeEnum::IfcMemberType_MULLION
#endif
window_parts.push_back(frame_part);
file.relatePlacements(window, frame_part);
}
// Add the glass plate to the list of parts
auto glass_part = file.create<IfcSchema::IfcPlate>();
glass_part.setGlobalId(guid());
glass_part.setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
glass_part.setObjectPlacement(file.addLocalPlacement(storey_placement, 930, 45, 90));
glass_part.setRepresentation(file.addBox(1860, 10, 1420));
#ifdef USE_IFC4
glass_part.setPredefinedType(IfcSchema::IfcPlateTypeEnum::IfcPlateType_SHEET);
IfcSchema::IfcPlate* glass_part = new IfcSchema::IfcPlate(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), null,
null, null, file.addLocalPlacement(storey_placement, 930, 45, 90), file.addBox(1680, 10, 1420), null
#ifdef SCHEMA_IfcPlate_HAS_PredefinedType
, IfcSchema::IfcPlateTypeEnum::IfcPlateType_SHEET
#endif
window_parts.push_back(glass_part);
+213 -8
View File
@@ -17,18 +17,223 @@
* *
********************************************************************************/
// TODO: Multiple schemas
#define IfcSchema Ifc2x3
#include "ifcparse/macros.h"
#include "../helpers/pset.h"
#include "../ifcparse/file.h"
#include "../ifcparse/logger.h"
#include "../ifcparse/schemas/Ifc2x3.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#endif
#include "ifcparse/IfcFile.h"
#include "ifcparse/IfcLogger.h"
#include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/seq/pop_back.hpp>
#include <boost/preprocessor/comparison/greater.hpp>
#include <boost/preprocessor/selection/min.hpp>
#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif
#ifndef SCHEMA_SEQ
static_assert(false, "A boost preprocessor sequence of schema identifiers is needed for this file to compile.");
#endif
// A macro cannot expand to an include directive, so unroll enough includes for
// the maximum number of schemas supported by the build configuration.
#define INCLUDE_SCHEMA_N(n) \
BOOST_PP_IIF(BOOST_PP_GREATER(BOOST_PP_SEQ_SIZE(SCHEMA_SEQ), n), \
BOOST_PP_STRINGIZE(ifcparse/BOOST_PP_CAT(Ifc, BOOST_PP_SEQ_ELEM(BOOST_PP_MIN(n, BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_POP_BACK(SCHEMA_SEQ))), SCHEMA_SEQ)).h), \
"ifcgeom/empty.h")
#include INCLUDE_SCHEMA_N(0)
#include INCLUDE_SCHEMA_N(1)
#include INCLUDE_SCHEMA_N(2)
#include INCLUDE_SCHEMA_N(3)
#include INCLUDE_SCHEMA_N(4)
#include INCLUDE_SCHEMA_N(5)
#include INCLUDE_SCHEMA_N(6)
#include INCLUDE_SCHEMA_N(7)
#include INCLUDE_SCHEMA_N(8)
#include INCLUDE_SCHEMA_N(9)
#include INCLUDE_SCHEMA_N(10)
#include INCLUDE_SCHEMA_N(11)
#include INCLUDE_SCHEMA_N(12)
#include INCLUDE_SCHEMA_N(13)
#include INCLUDE_SCHEMA_N(14)
#include INCLUDE_SCHEMA_N(15)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/, IfcSchema)
#include <iomanip>
#if USE_VLD
#include <vld.h>
#endif
template<class T, class = void>
struct is_ifc4_or_higher : std::false_type {};
template<class T>
struct is_ifc4_or_higher<T, std::void_t<decltype(T::IfcMaterialDefinition)>> : std::true_type { };
typedef std::map<std::string, std::map<std::string, std::string>> element_properties;
#ifdef SCHEMA_HAS_IfcBuildingElement
typedef IfcSchema::IfcBuildingElement element_t;
#else
typedef IfcSchema::IfcBuiltElement element_t;
#endif
std::string format_string(const AttributeValue& argument) {
// Argument is a runtime tagged variant for the various data types in a IFC model,
// in this particular case we only care about flattening it to a string.
// @todo mostly duplicated from XmlSerializer.cpp
if (argument.isNull()) {
return "-";
}
auto argument_type = argument.type();
switch (argument_type) {
case IfcUtil::Argument_BOOL: {
const bool b = argument;
return b ? "true" : "false";
}
case IfcUtil::Argument_DOUBLE: {
const double d = argument;
std::stringstream stream;
stream << std::setprecision(std::numeric_limits< double >::max_digits10) << d;
return stream.str();
break; }
case IfcUtil::Argument_STRING:
case IfcUtil::Argument_ENUMERATION: {
return static_cast<std::string>(argument);
break; }
case IfcUtil::Argument_INT: {
const int v = argument;
std::stringstream stream;
stream << v;
return stream.str();
break; }
}
return "?";
}
template <typename Schema, typename T>
void process_pset(element_properties& props, const T* inst) {
// Process an individual Property or Quantity set.
if (auto pset = inst->template as<typename Schema::IfcPropertySet>()) {
if (!pset->Name()) {
return;
}
auto ps = pset->HasProperties();
for (auto it = ps->begin(); it != ps->end(); ++it) {
auto& p = *it;
if (auto singleval = p->template as<typename Schema::IfcPropertySingleValue>()) {
std::string propname, propvalue;
if constexpr (is_ifc4_or_higher<Schema>::value) {
if (!singleval->Name()) {
continue;
}
propname = *singleval->Name();
}
if constexpr (!is_ifc4_or_higher<Schema>::value) {
propname = singleval->Name();
}
if (!singleval->NominalValue()) {
propvalue = "-";
} else {
props[*pset->Name()][propname] = format_string(singleval->NominalValue()->template as<IfcUtil::IfcBaseClass>()->get_attribute_value(0));
}
}
}
}
if (auto qset = inst->template as<typename Schema::IfcElementQuantity>()) {
if (!qset->Name()) {
return;
}
auto qs = qset->Quantities();
for (auto it = qs->begin(); it != qs->end(); ++it) {
auto& q = *it;
if (q->template as<typename Schema::IfcPhysicalSimpleQuantity>() && q->get_attribute_value(3).type() == IfcUtil::Argument_DOUBLE) {
double v = q->get_attribute_value(3);
props[*qset->Name()][q->Name()] = std::to_string(v);
}
}
}
if constexpr (is_ifc4_or_higher<Schema>::value) {
if (auto extprops = inst->template as<typename Schema::IfcExtendedProperties>()) {
// @todo
}
}
}
template <typename Schema>
void get_psets_s(element_properties& props, const typename Schema::IfcObjectDefinition* inst) {
// Extracts the property definitions for an IFC instance.
if (auto tyob = inst->template as<typename Schema::IfcTypeObject>()) {
if (tyob->HasPropertySets()) {
auto defs = *tyob->HasPropertySets();
for (auto it = defs->begin(); it != defs->end(); ++it) {
auto& def = *it;
process_pset<Schema>(props, def);
}
}
}
if constexpr (is_ifc4_or_higher<Schema>::value) {
if (auto mdef = inst->template as<typename Schema::IfcMaterialDefinition>()) {
auto defs = mdef->HasProperties();
for (auto it = defs->begin(); it != defs->end(); ++it) {
auto& def = *it;
process_pset<Schema>(props, def);
}
}
if (auto pdef = inst->template as<typename Schema::IfcProfileDef>()) {
auto defs = pdef->HasProperties();
for (auto it = defs->begin(); it != defs->end(); ++it) {
auto& def = *it;
process_pset<Schema>(props, def);
}
}
}
if (auto ob = inst->template as<typename Schema::IfcObject>()) {
if constexpr (is_ifc4_or_higher<Schema>::value) {
auto rels = ob->IsTypedBy();
for (auto it = rels->begin(); it != rels->end(); ++it) {
auto& rel = *it;
get_psets_s<Schema>(props, rel->RelatingType());
}
}
{
auto rels = ob->IsDefinedBy();
for (auto it = rels->begin(); it != rels->end(); ++it) {
auto& rel = *it;
if (auto bytype = rel->template as<typename Schema::IfcRelDefinesByType>()) {
get_psets_s<Schema>(props, bytype->RelatingType());
} else if (auto byprops = rel->template as<typename Schema::IfcRelDefinesByProperties>()) {
process_pset<Schema>(props, byprops->RelatingPropertyDefinition());
}
}
}
}
}
// What follows is machinery to create a preprocessor-based dispatch mechanism to dispatch to the
// correct get_psets_s<Schema>() based on inst->declaration().schema()->name().
#define EXPAND_AND_CONCATENATE(elem) Ifc##elem
#define GENERATE_LITERAL_STRING(elem) "Ifc" # elem
#define TEST_AND_DISPATCH(r, data, elem) \
if (strcasecmp(schema_name, GENERATE_LITERAL_STRING(elem)) == 0) { get_psets_s<EXPAND_AND_CONCATENATE(elem)>(props, inst->as<EXPAND_AND_CONCATENATE(elem)::IfcObjectDefinition>()); }
void get_psets(element_properties& props, const IfcUtil::IfcBaseClass* inst) {
auto schema_name = inst->declaration().schema()->name().c_str();
BOOST_PP_SEQ_FOR_EACH(TEST_AND_DISPATCH, , SCHEMA_SEQ)
}
int main(int argc, char** argv) {
if (argc != 2) {
std::cout << "usage: IfcParseExamples <filename.ifc>" << std::endl;
@@ -36,7 +241,7 @@ int main(int argc, char** argv) {
}
// Redirect the output (both progress and log) to stdout
logger::set_output(&std::cout, &std::cout);
Logger::Root().SetOutput(&std::cout, &std::cout);
// Parse the IFC file provided in argv[1]
ifcopenshell::file file(argv[1]);
@@ -61,7 +266,7 @@ int main(int argc, char** argv) {
// we need to cast them to IfcWindows. Since these properties
// are optional we need to make sure the properties are
// defined for the window in question before accessing them.
auto elements = file.instances_by_type<IfcSchema::IfcBuildingElement>();
auto elements = file.instances_by_type<element_t>();
std::cout << "Found " << elements.size() << " elements in " << argv[1] << ":" << std::endl;
+10 -2
View File
@@ -28,8 +28,16 @@
#include <iostream>
#include <fstream>
#include "../ifcparse/schemas/Ifc2x3.h"
#include "../ifcparse/hierarchy_helper.h"
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc4
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
+42 -11
View File
@@ -27,14 +27,45 @@
#include <iostream>
#include <fstream>
#include "../ifcparse/schemas/Ifc2x3.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/hierarchy_helper.h"
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
boost::none_t const null = boost::none;
#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius
#define IFC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS , null, null
#else
#define IFC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
#ifdef SCHEMA_IfcLShapeProfileDef_HAS_CentreOfGravityInX
#define IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS , null, null
#else
#define IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
#ifdef SCHEMA_IfcTShapeProfileDef_HAS_CentreOfGravityInY
#define IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS , null
#else
#define IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
#ifdef SCHEMA_IfcCShapeProfileDef_HAS_CentreOfGravityInX
#define IFC_C_SHAPE_PROFILE_DEF_EXTRA_ARGS , null
#else
#define IFC_C_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
int main(int argc, char** argv) {
const char filename[] = "IfcCompositeProfileDef.ifc";
hierarchy_helper file;
@@ -49,21 +80,21 @@ int main(int argc, char** argv) {
IfcSchema::IfcCartesianTransformationOperator2D* transform1 = new IfcSchema::IfcCartesianTransformationOperator2D(file.addDoublet<IfcSchema::IfcDirection>(1, 0), file.addDoublet<IfcSchema::IfcDirection>(0, -1), file.addDoublet<IfcSchema::IfcCartesianPoint>(40, 0), null);
IfcSchema::IfcCartesianTransformationOperator2D* transform2 = new IfcSchema::IfcCartesianTransformationOperator2D(file.addDoublet<IfcSchema::IfcDirection>(0, -1), file.addDoublet<IfcSchema::IfcDirection>(1, 0), file.addDoublet<IfcSchema::IfcCartesianPoint>(40, 0), 0.3);
IfcSchema::IfcProfileDef* p1 = new Ifc2x3::IfcIShapeProfileDef(
IfcSchema::IfcProfileDef* p1 = new IfcSchema::IfcIShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, file.addPlacement2d(), 25.0, 50.0, 5.0, 5.0, 2.0);
null, file.addPlacement2d(), 25.0, 50.0, 5.0, 5.0, 2.0 IFC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS);
IfcSchema::IfcProfileDef* p2 = new Ifc2x3::IfcLShapeProfileDef(
IfcSchema::IfcProfileDef* p2 = new IfcSchema::IfcLShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, file.addPlacement2d(), 50.0, 25.0, 5.0, 1.0, 2.0, 2.0, null, null);
null, file.addPlacement2d(), 50.0, 25.0, 5.0, 1.0, 2.0, 2.0 IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS);
IfcSchema::IfcProfileDef* p3 = new Ifc2x3::IfcTShapeProfileDef(
IfcSchema::IfcProfileDef* p3 = new IfcSchema::IfcTShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, file.addPlacement2d(), 50.0, 40.0, 10.0, 10.0, 3.0, 2.0, 1.0, 2.0, 2.0, null);
null, file.addPlacement2d(), 50.0, 40.0, 10.0, 10.0, 3.0, 2.0, 1.0, 2.0, 2.0 IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS);
IfcSchema::IfcProfileDef* p4 = new Ifc2x3::IfcCShapeProfileDef(
IfcSchema::IfcProfileDef* p4 = new IfcSchema::IfcCShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, file.addPlacement2d(80.), 50.0, 25.0, 5.0, 10.0, 2.0, null);
null, file.addPlacement2d(80.), 50.0, 25.0, 5.0, 10.0, 2.0 IFC_C_SHAPE_PROFILE_DEF_EXTRA_ARGS);
file.add_entity(p2);
file.add_entity(p3);
+10 -3
View File
@@ -27,9 +27,16 @@
#include <iostream>
#include <fstream>
#include "../ifcparse/schemas/Ifc2x3.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/hierarchy_helper.h"
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
+38 -25
View File
@@ -27,14 +27,27 @@
#include <iostream>
#include <fstream>
#include "../ifcparse/schemas/Ifc2x3.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/hierarchy_helper.h"
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
boost::none_t const null = boost::none;
#ifdef SCHEMA_HAS_IfcSegment
typedef IfcSchema::IfcSegment curve_segment_tt;
#else
typedef IfcSchema::IfcCompositeCurveSegment curve_segment_tt;
#endif
typedef struct {
double r1;
double r2;
@@ -54,46 +67,46 @@ void create_testcase_for(hierarchy_helper& file, const EllipsePie& pie, Ifc2x3::
std::vector<double> coords2(flt2, flt2 + 2);
std::vector<double> coords3(flt3, flt3 + 2);
Ifc2x3::IfcCartesianPoint* p1 = new Ifc2x3::IfcCartesianPoint(coords1);
Ifc2x3::IfcCartesianPoint* p2 = new Ifc2x3::IfcCartesianPoint(coords2);
Ifc2x3::IfcCartesianPoint* p3 = new Ifc2x3::IfcCartesianPoint(coords3);
IfcSchema::IfcCartesianPoint* p1 = new IfcSchema::IfcCartesianPoint(coords1);
IfcSchema::IfcCartesianPoint* p2 = new IfcSchema::IfcCartesianPoint(coords2);
IfcSchema::IfcCartesianPoint* p3 = new IfcSchema::IfcCartesianPoint(coords3);
Ifc2x3::IfcCartesianPoint::list::ptr points(new Ifc2x3::IfcCartesianPoint::list());
IfcSchema::IfcCartesianPoint::list::ptr points(new IfcSchema::IfcCartesianPoint::list());
points->push(p3);
points->push(p1);
points->push(p2);
file.addEntities(points->generalize());
Ifc2x3::IfcEllipse* ellipse = new Ifc2x3::IfcEllipse(file.addPlacement2d(), pie.r1, pie.r2);
file.add_entity(ellipse);
IfcEntityList::ptr trim1(new IfcEntityList);
IfcEntityList::ptr trim2(new IfcEntityList);
if (pref == Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER) {
trim1->push(new Ifc2x3::IfcParameterValue(pie.t1));
trim2->push(new Ifc2x3::IfcParameterValue(pie.t2));
IfcSchema::IfcEllipse* ellipse = new IfcSchema::IfcEllipse(file.addPlacement2d(), pie.r1, pie.r2);
file.addEntity(ellipse);
aggregate_of_instance::ptr trim1(new aggregate_of_instance);
aggregate_of_instance::ptr trim2(new aggregate_of_instance);
if (pref == IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER) {
trim1->push(new IfcSchema::IfcParameterValue(pie.t1));
trim2->push(new IfcSchema::IfcParameterValue(pie.t2));
} else {
trim1->push(p2);
trim2->push(p3);
}
Ifc2x3::IfcTrimmedCurve* trim = new Ifc2x3::IfcTrimmedCurve(ellipse, trim1, trim2, true, pref);
file.add_entity(trim);
IfcSchema::IfcTrimmedCurve* trim = new IfcSchema::IfcTrimmedCurve(ellipse, trim1->as<IfcSchema::IfcTrimmingSelect>(), trim2->as<IfcSchema::IfcTrimmingSelect>(), true, pref);
file.addEntity(trim);
Ifc2x3::IfcCompositeCurveSegment::list::ptr segments(new Ifc2x3::IfcCompositeCurveSegment::list());
Ifc2x3::IfcCompositeCurveSegment* s2 = new Ifc2x3::IfcCompositeCurveSegment(Ifc2x3::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, trim);
curve_segment_tt::list::ptr segments(new curve_segment_tt::list());
IfcSchema::IfcCompositeCurveSegment* s2 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, trim);
Ifc2x3::IfcPolyline* poly = new Ifc2x3::IfcPolyline(points);
file.add_entity(poly);
Ifc2x3::IfcCompositeCurveSegment* s1 = new Ifc2x3::IfcCompositeCurveSegment(Ifc2x3::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, poly);
IfcSchema::IfcPolyline* poly = new IfcSchema::IfcPolyline(points);
file.addEntity(poly);
IfcSchema::IfcCompositeCurveSegment* s1 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, poly);
segments->push(s1);
segments->push(s2);
file.addEntities(segments->generalize());
Ifc2x3::IfcCompositeCurve* ccurve = new Ifc2x3::IfcCompositeCurve(segments, false);
Ifc2x3::IfcArbitraryClosedProfileDef* profile = new Ifc2x3::IfcArbitraryClosedProfileDef(Ifc2x3::IfcProfileTypeEnum::IfcProfileType_AREA, null, ccurve);
file.add_entity(ccurve);
file.add_entity(profile);
IfcSchema::IfcCompositeCurve* ccurve = new IfcSchema::IfcCompositeCurve(segments, false);
IfcSchema::IfcArbitraryClosedProfileDef* profile = new IfcSchema::IfcArbitraryClosedProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, ccurve);
file.addEntity(ccurve);
file.addEntity(profile);
IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy(
guid(), 0, S("profile"), null, null, 0, 0, null, null);
+10 -3
View File
@@ -23,9 +23,16 @@
* *
********************************************************************************/
#include "../ifcparse/schemas/Ifc2x3.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/hierarchy_helper.h"
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
+28 -7
View File
@@ -27,16 +27,37 @@
#include <string>
#include <fstream>
#include "ifcparse\Ifc2x3.h"
#include "ifcparse\IfcUtil.h"
#include "ifcparse\hierarchy_helper.h"
#include "ifcgeom\IfcGeom.h"
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include <boost/math/constants/constants.hpp>
const static double PI = boost::math::constants::pi<double>();
typedef std::string S;
typedef ifcopenshell::global_id guid;
boost::none_t const null = boost::none;
void create_curve_rebar(hierarchy_helper& file)
#ifdef SCHEMA_HAS_IfcSegment
typedef IfcSchema::IfcSegment curve_segment_t;
#else
typedef IfcSchema::IfcCompositeCurveSegment curve_segment_t;
#endif
#ifdef SCHEMA_IfcReinforcingBar_HAS_PredefinedType
#define IFC_REINFORCING_BAR_TYPE IfcSchema::IfcReinforcingBarTypeEnum::IfcReinforcingBarType_LIGATURE
#else
#define IFC_REINFORCING_BAR_TYPE IfcSchema::IfcReinforcingBarRoleEnum::IfcReinforcingBarRole_LIGATURE
#endif
void create_curve_rebar(IfcHierarchyHelper<IfcSchema>& file)
{
int dia = 24;
int R = 3 * dia;
@@ -50,14 +71,14 @@ void create_curve_rebar(hierarchy_helper& file)
dia, //diameter
crossSectionarea, //crossSectionarea = math.pi*(12.0/2)**2
0,
IfcSchema::IfcReinforcingBarRoleEnum::IfcReinforcingBarRoleEnum::IfcReinforcingBarRole_LIGATURE,
IFC_REINFORCING_BAR_TYPE,
IfcSchema::IfcReinforcingBarSurfaceEnum::IfcReinforcingBarSurfaceEnum::IfcReinforcingBarSurface_PLAIN //PLAIN or TEXTURED
);
file.addBuildingProduct(rebar);
rebar->setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
IfcSchema::IfcCompositeCurveSegment::list::ptr segments(new IfcSchema::IfcCompositeCurveSegment::list());
curve_segment_t::list::ptr segments(new curve_segment_t::list());
IfcSchema::IfcCartesianPoint* p1 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, 0, 1000.);
IfcSchema::IfcCartesianPoint* p2 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, 0, 0);
+77 -34
View File
@@ -27,14 +27,57 @@
#include <iostream>
#include <fstream>
#include "../ifcparse/schemas/Ifc2x3.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/hierarchy_helper.h"
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
typedef std::string S;
typedef IfcWrite::IfcGuidHelper guid;
boost::none_t const null = (static_cast<boost::none_t>(0));
#ifdef SCHEMA_IfcUShapeProfileDef_HAS_CentreOfGravityInX
#define IFC_U_SHAPE_PROFILE_DEF_EXTRA_ARGS , null
#else
#define IFC_U_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
#ifdef SCHEMA_IfcTShapeProfileDef_HAS_CentreOfGravityInY
#define IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS , null
#else
#define IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius
#define IFC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS , null, null
#else
#define IFC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
#ifdef SCHEMA_IfcAsymmetricIShapeProfileDef_HAS_BottomFlangeSlope
#define IFC_ASYMMETRIC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS , null, null, null
#else
#define IFC_ASYMMETRIC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
#ifdef SCHEMA_IfcLShapeProfileDef_HAS_CentreOfGravityInX
#define IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS , null, null
#else
#define IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
#ifdef SCHEMA_IfcCShapeProfileDef_HAS_CentreOfGravityInX
#define IFC_C_SHAPE_PROFILE_DEF_EXTRA_ARGS , null
#else
#define IFC_C_SHAPE_PROFILE_DEF_EXTRA_ARGS
#endif
void create_testcase_for(IfcSchema::IfcProfileDef::list::ptr profiles) {
IfcSchema::IfcProfileDef* profile = *profiles->begin();
const std::string profile_type = IfcSchema::Type::ToString(profile->type());
@@ -87,31 +130,31 @@ int main(int argc, char** argv) {
{ IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list);
profiles->push(new Ifc2x3::IfcUShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null, null));
profiles->push(new Ifc2x3::IfcUShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null IFC_U_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcUShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 5.0, 2.0, 2.0, null, null));
profiles->push(new Ifc2x3::IfcUShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, 5.0, 2.0, 2.0, null IFC_U_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcUShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 5.0, null, null, 4.0, null));
profiles->push(new Ifc2x3::IfcUShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, 5.0, null, null, 4.0 IFC_U_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcUShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 5.0, 1.0, 3.0, 6.0, null));
null, 0, 50.0, 25.0, 5.0, 5.0, 1.0, 3.0, 6.0 IFC_U_SHAPE_PROFILE_DEF_EXTRA_ARGS));
create_testcase_for(profiles); }
{ IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list);
profiles->push(new Ifc2x3::IfcTShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null, null, null, null));
profiles->push(new Ifc2x3::IfcTShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null, null, null IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcTShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 5.0, 2.0, 2.0, 2.0, null, null, null));
profiles->push(new Ifc2x3::IfcTShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, 5.0, 2.0, 2.0, 2.0, null, null IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcTShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null, 2.0, 2.0, null));
profiles->push(new Ifc2x3::IfcTShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null, 2.0, 2.0 IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcTShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 5.0, 3.0, 2.0, 1.0, 2.0, 2.0, null));
null, 0, 50.0, 25.0, 5.0, 5.0, 3.0, 2.0, 1.0, 2.0, 2.0 IFC_T_SHAPE_PROFILE_DEF_EXTRA_ARGS));
create_testcase_for(profiles); }
{ IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list);
@@ -132,40 +175,40 @@ int main(int argc, char** argv) {
null, 0, 15.0, 25.0));
create_testcase_for(profiles); }
{ IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list);
profiles->push(new Ifc2x3::IfcIShapeProfileDef(
{ IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list);
profiles->push(new IfcSchema::IfcIShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 25.0, 50.0, 5.0, 5.0, null));
profiles->push(new Ifc2x3::IfcIShapeProfileDef(
null, 0, 25.0, 50.0, 5.0, 5.0, null IFC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcIShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 25.0, 50.0, 5.0, 5.0, 2.0));
profiles->push(new Ifc2x3::IfcAsymmetricIShapeProfileDef(
null, 0, 25.0, 50.0, 5.0, 5.0, 2.0 IFC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcAsymmetricIShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 25.0, 50.0, 5.0, 5.0, 2.0, 20.0, 10.0, 5.0, null));
null, 0, 25.0, 50.0, 5.0, 5.0, 2.0, 20.0, 10.0, 5.0, null IFC_ASYMMETRIC_I_SHAPE_PROFILE_DEF_EXTRA_ARGS));
create_testcase_for(profiles); }
{ IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list);
profiles->push(new Ifc2x3::IfcLShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, null, null, null, null, null));
profiles->push(new Ifc2x3::IfcLShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, null, null, null IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcLShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 2.0, 2.0, null, null, null));
profiles->push(new Ifc2x3::IfcLShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, 2.0, 2.0, null IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcLShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, null, null, 2.0, null, null));
profiles->push(new Ifc2x3::IfcLShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, null, null, 2.0 IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcLShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 1.0, 2.0, 2.0, null, null));
null, 0, 50.0, 25.0, 5.0, 1.0, 2.0, 2.0 IFC_L_SHAPE_PROFILE_DEF_EXTRA_ARGS));
create_testcase_for(profiles); }
{ IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list);
profiles->push(new Ifc2x3::IfcCShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 10.0, null, null));
profiles->push(new Ifc2x3::IfcCShapeProfileDef(
null, 0, 50.0, 25.0, 5.0, 10.0, null IFC_C_SHAPE_PROFILE_DEF_EXTRA_ARGS));
profiles->push(new IfcSchema::IfcCShapeProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA,
null, 0, 50.0, 25.0, 5.0, 10.0, 2.0, null));
null, 0, 50.0, 25.0, 5.0, 10.0, 2.0 IFC_C_SHAPE_PROFILE_DEF_EXTRA_ARGS));
create_testcase_for(profiles); }
{ IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list);
+20 -4
View File
@@ -23,8 +23,20 @@
* *
********************************************************************************/
#include "../ifcparse/schemas/Ifc4.h"
#include "../ifcparse/hierarchy_helper.h"
#include <iostream>
#include <fstream>
#include <optional>
#include "ifcparse/macros.h"
#ifndef IfcSchema
#define IfcSchema Ifc4
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "suzanne_geometry.h"
@@ -62,8 +74,12 @@ int main(int argc, char** argv) {
std::vector< std::vector< double > > vertices_vector = create_vector_from_array(vertices, sizeof(vertices) / sizeof(vertices[0]));
std::vector< std::vector< int > > indices_vector = create_vector_from_array(indices, sizeof(indices) / sizeof(indices[0]));
Ifc4::IfcCartesianPointList3D coordinates = file.create<Ifc4::IfcCartesianPointList3D>().initialize(vertices_vector);
Ifc4::IfcTriangulatedFaceSet faceset = file.create<Ifc4::IfcTriangulatedFaceSet>().initialize(coordinates, std::nullopt, std::nullopt, indices_vector, std::nullopt);
IfcSchema::IfcCartesianPointList3D* coordinates = new IfcSchema::IfcCartesianPointList3D(vertices_vector
#ifdef SCHEMA_IfcCartesianPointList3D_HAS_TagList
, boost::none
#endif
);
IfcSchema::IfcTriangulatedFaceSet* faceset = new IfcSchema::IfcTriangulatedFaceSet(coordinates, null, null, indices_vector, null);
Ifc4::IfcShapeRepresentation rep = file.create<Ifc4::IfcShapeRepresentation>().initialize(
file.getRepresentationContext("Model"), "Body", "SurfaceModel", {faceset});