diff --git a/src/examples/IfcAdvancedHouse.cpp b/src/examples/IfcAdvancedHouse.cpp index 946bd0b8fc..4372129fc9 100644 --- a/src/examples/IfcAdvancedHouse.cpp +++ b/src/examples/IfcAdvancedHouse.cpp @@ -40,13 +40,16 @@ #ifdef USE_IFC4 #include "../ifcparse/Ifc4.h" +#define IfcSchema Ifc4 #else #include "../ifcparse/Ifc2x3.h" +#define IfcSchema Ifc2x3 #endif #include "../ifcparse/IfcBaseClass.h" #include "../ifcparse/IfcHierarchyHelper.h" #include "../ifcgeom/IfcGeom.h" +#include "../ifcgeom_schema_agnostic/Serialization.h" #if USE_VLD #include @@ -59,7 +62,7 @@ int main() { // The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several // convenience functions for working with geometry in IFC files. - IfcHierarchyHelper file; + IfcHierarchyHelper file; file.header().file_name().name("IfcAdvancedHouse.ifc"); IfcSchema::IfcBuilding* building = file.addBuilding(); @@ -91,7 +94,7 @@ int main() { // IfcFacetedBRep. If it would not be a polyhedron, serialise() can only be successful when linked // to the IFC4 model and with `advanced` set to `true` which introduces IfcAdvancedFace. It would // return `0` otherwise. - IfcSchema::IfcProductDefinitionShape* building_shape = IfcGeom::serialise(building_shell, false); + IfcSchema::IfcProductDefinitionShape* building_shape = IfcGeom::serialise(STRINGIFY(IfcSchema), building_shell, false)->as(); file.addEntity(building_shape); IfcSchema::IfcRepresentation* rep = *building_shape->Representations()->begin(); @@ -108,9 +111,9 @@ int main() { TopoDS_Shape shape; createGroundShape(shape); - IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::serialise(shape, true); + IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::serialise(STRINGIFY(IfcSchema), shape, true)->as(); if (!ground_representation) { - ground_representation = IfcGeom::tesselate(shape, 100.); + ground_representation = IfcGeom::tesselate(STRINGIFY(IfcSchema), shape, 100.)->as(); } file.getSingle()->setRepresentation(ground_representation); diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index 90e4195c8b..e3d3138ccd 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -28,18 +28,23 @@ #include #include - #include +#include +#include + #ifdef USE_IFC4 #include "../ifcparse/Ifc4.h" +#define IfcSchema Ifc4 #else #include "../ifcparse/Ifc2x3.h" +#define IfcSchema Ifc2x3 #endif #include "../ifcparse/IfcBaseClass.h" #include "../ifcparse/IfcHierarchyHelper.h" #include "../ifcgeom/IfcGeom.h" +#include "../ifcgeom_schema_agnostic/Serialization.h" #if USE_VLD #include @@ -58,7 +63,7 @@ int main() { // The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several // convenience functions for working with geometry in IFC files. - IfcHierarchyHelper file; + IfcHierarchyHelper file; file.header().file_name().name("IfcOpenHouse.ifc"); // Start by adding a wall to the file, initially leaving most attributes blank. @@ -262,11 +267,13 @@ int main() { // will be tesselated using the deflection specified. TopoDS_Shape shape; createGroundShape(shape); - IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(shape, 100.); + IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(STRINGIFY(IfcSchema), shape, 100.)->as(); file.getSingle()->setRepresentation(ground_representation); - // Relate a property set to the IfcSite - const double site_area = IfcGeom::Kernel::face_area(TopoDS::Face(shape)) / 1000 / 1000; + GProp_GProps prop; + BRepGProp::SurfaceProperties(shape, prop); + const double site_area = prop.Mass() / 1000 / 1000; + 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(), S("Pset_SiteCommon"), null, properties); @@ -334,9 +341,9 @@ int main() { null, null, #ifdef USE_IFC4 - file.entitiesByType()->generalize(), + file.instances_by_type()->generalize(), #else - file.entitiesByType()->as(), + file.instances_by_type()->as(), #endif layer_usage); @@ -391,7 +398,7 @@ int main() { IfcSchema::IfcShapeRepresentation* door_body = 0; for (IfcSchema::IfcRepresentation::list::it i = door_representations->begin(); i != door_representations->end(); ++i) { IfcSchema::IfcRepresentation* rep = *i; - if (rep->is(IfcSchema::Type::IfcShapeRepresentation) && rep->RepresentationIdentifier() == "Body") { + if (rep->declaration().is(IfcSchema::IfcShapeRepresentation::Class()) && rep->RepresentationIdentifier() == "Body") { door_body = (IfcSchema::IfcShapeRepresentation*) rep; } } diff --git a/src/examples/IfcParseExamples.cpp b/src/examples/IfcParseExamples.cpp index 7ae158a67f..15807a35cc 100644 --- a/src/examples/IfcParseExamples.cpp +++ b/src/examples/IfcParseExamples.cpp @@ -17,14 +17,16 @@ * * ********************************************************************************/ +// TODO: Multiple schemas +#define IfcSchema Ifc2x3 + #include "../ifcparse/IfcFile.h" +#include "../ifcparse/Ifc2x3.h" #if USE_VLD #include #endif -using namespace IfcSchema; - int main(int argc, char** argv) { if ( argc != 2 ) { @@ -36,8 +38,8 @@ int main(int argc, char** argv) { Logger::SetOutput(&std::cout,&std::cout); // Parse the IFC file provided in argv[1] - IfcParse::IfcFile file; - if ( ! file.Init(argv[1]) ) { + IfcParse::IfcFile file(argv[1]); + if (!file.good()) { std::cout << "Unable to parse .ifc file" << std::endl; return 1; } @@ -58,19 +60,18 @@ 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. - IfcBuildingElement::list::ptr elements = file.entitiesByType(); + IfcSchema::IfcBuildingElement::list::ptr elements = file.instances_by_type(); std::cout << "Found " << elements->size() << " elements in " << argv[1] << ":" << std::endl; - for ( IfcBuildingElement::list::it it = elements->begin(); it != elements->end(); ++ it ) { + for (IfcSchema::IfcBuildingElement::list::it it = elements->begin(); it != elements->end(); ++it) { - const IfcBuildingElement* element = *it; - std::cout << element->entity->toString() << std::endl; + const IfcSchema::IfcBuildingElement* element = *it; + std::cout << element->data().toString() << std::endl; - if ( element->is(IfcWindow::Class()) ) { - const IfcWindow* window = (IfcWindow*)element; - - if ( window->hasOverallWidth() && window->hasOverallHeight() ) { + const IfcSchema::IfcWindow* window; + if ((window = element->as()) != 0) { + if (window->hasOverallWidth() && window->hasOverallHeight()) { const double area = window->OverallWidth()*window->OverallHeight(); std::cout << "The area of this window is " << area << std::endl; }