diff --git a/src/examples/arbitrary_open_profile_def.cpp b/src/examples/arbitrary_open_profile_def.cpp index d0d11087fd..de040cf827 100644 --- a/src/examples/arbitrary_open_profile_def.cpp +++ b/src/examples/arbitrary_open_profile_def.cpp @@ -29,7 +29,6 @@ #include #include "../ifcparse/schemas/Ifc2x3.h" -#include "../ifcparse/IfcUtil.h" #include "../ifcparse/hierarchy_helper.h" typedef std::string S; diff --git a/src/examples/triangulated_faceset.cpp b/src/examples/triangulated_faceset.cpp index 547fdb028e..55d243b208 100644 --- a/src/examples/triangulated_faceset.cpp +++ b/src/examples/triangulated_faceset.cpp @@ -23,15 +23,15 @@ * * ********************************************************************************/ -#include "../ifcparse/Ifc4.h" -#include "../ifcparse/IfcUtil.h" +#include "../ifcparse/schemas/Ifc4.h" #include "../ifcparse/hierarchy_helper.h" #include "suzanne_geometry.h" +#include + typedef std::string S; typedef ifcopenshell::global_id guid; -boost::none_t const null = (static_cast(0)); template std::vector< std::vector > create_vector_from_array(const T* arr, unsigned size) { @@ -50,36 +50,31 @@ std::vector< std::vector > create_vector_from_array(const T* arr, unsigned si } int main(int argc, char** argv) { - hierarchy_helper file; + hierarchy_helper file; - IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy( - guid(), 0, S("Blender's Suzanne"), null, null, 0, 0, null, null); + Ifc4::IfcBuildingElementProxy product = file.create().initialize( + guid(), std::nullopt, S("Blender's Suzanne"), std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt); file.addBuildingProduct(product); - product->setOwnerHistory(file.getSingle()); + product.setOwnerHistory(file.getSingle()); - product->setObjectPlacement(file.addLocalPlacement()); - - IfcSchema::IfcRepresentation::list::ptr reps (new IfcSchema::IfcRepresentation::list); - IfcSchema::IfcRepresentationItem::list::ptr items (new IfcSchema::IfcRepresentationItem::list); + product.setObjectPlacement(file.addLocalPlacement()); 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])); - IfcSchema::IfcCartesianPointList3D* coordinates = new IfcSchema::IfcCartesianPointList3D(vertices_vector); - IfcSchema::IfcTriangulatedFaceSet* faceset = new IfcSchema::IfcTriangulatedFaceSet(coordinates, null, null, indices_vector, null); + Ifc4::IfcCartesianPointList3D coordinates = file.create().initialize(vertices_vector); + Ifc4::IfcTriangulatedFaceSet faceset = file.create().initialize(coordinates, std::nullopt, std::nullopt, indices_vector, std::nullopt); - items->push(faceset); - IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation( - file.getRepresentationContext("Model"), S("Body"), S("SurfaceModel"), items); - reps->push(rep); + Ifc4::IfcShapeRepresentation rep = file.create().initialize( + file.getRepresentationContext("Model"), "Body", "SurfaceModel", {faceset}); - IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(0, 0, reps); + Ifc4::IfcProductDefinitionShape shape = file.create().initialize(std::nullopt, std::nullopt, {rep}); file.add_entity(shape); - product->setRepresentation(shape); + product.setRepresentation(shape); const std::string filename = "tesselated_faceset.ifc"; - file.header().file_name().name(filename); + file.header().file_name().setname(filename); std::ofstream f(filename.c_str()); f << file; } diff --git a/src/ifcparse/express.h b/src/ifcparse/express.h index a42ae158ba..e4e2dd699d 100644 --- a/src/ifcparse/express.h +++ b/src/ifcparse/express.h @@ -70,6 +70,7 @@ class IFC_PARSE_API Base { } Base() {}; + Base(std::nullopt_t) noexcept : Base() {} Base(const std::weak_ptr& data) : data_(data) {} // @todo try and make this private over time too @@ -132,8 +133,7 @@ class IFC_PARSE_API Base { class IFC_PARSE_API Entity : public Base { public: - Entity() {} - Entity(const std::weak_ptr& data) : Base(data) {} + using Base::Base; attribute_value get(const std::string& attribute_name) const; @@ -149,7 +149,8 @@ class IFC_PARSE_API Entity : public Base { class IFC_PARSE_API Select : public Base { public: Select() {} - // Select are constructed from Base as cast functions, not from data directly + Select(std::nullopt_t) noexcept : Base() {} + Select(const std::weak_ptr& data) : Base(data) {} Select(const Base& base) : Base(base.data_weak()) {} Base concrete() const { @@ -163,8 +164,7 @@ class IFC_PARSE_API Select : public Base { // Entity and DeclaredType class IFC_PARSE_API DeclaredType : public Base { public: - DeclaredType() {} - DeclaredType(const std::weak_ptr& data) : Base(data) {} + using Base::Base; }; } // namespace express