examples: fix missing includes

This commit is contained in:
Dirk Olbrich
2024-02-22 20:51:45 +01:00
committed by Thomas Krijnen
parent eb50be5c52
commit 28c7da2336
2 changed files with 48 additions and 48 deletions
+45 -46
View File
@@ -20,8 +20,9 @@
// TODO: Multiple schemas
#define IfcSchema Ifc2x3
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/Ifc2x3.h"
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/IfcLogger.h"
#if USE_VLD
#include <vld.h>
@@ -29,54 +30,52 @@
int main(int argc, char** argv) {
if ( argc != 2 ) {
std::cout << "usage: IfcParseExamples <filename.ifc>" << std::endl;
return 1;
}
if (argc != 2) {
std::cout << "usage: IfcParseExamples <filename.ifc>" << std::endl;
return 1;
}
// Redirect the output (both progress and log) to stdout
Logger::SetOutput(&std::cout,&std::cout);
// Redirect the output (both progress and log) to stdout
Logger::SetOutput(&std::cout, &std::cout);
// Parse the IFC file provided in argv[1]
IfcParse::IfcFile file(argv[1]);
if (!file.good()) {
std::cout << "Unable to parse .ifc file" << std::endl;
return 1;
}
// Parse the IFC file provided in argv[1]
IfcParse::IfcFile file(argv[1]);
if (!file.good()) {
std::cout << "Unable to parse .ifc file" << std::endl;
return 1;
}
// Lets get a list of IfcBuildingElements, this is the parent
// type of things like walls, windows and doors.
// entitiesByType is a templated function and returns a
// templated class that behaves like a std::vector.
// Note that the return types are all typedef'ed as members of
// the generated classes, ::list for the templated vector class,
// ::ptr for a shared pointer and ::it for an iterator.
// We will simply iterate over the vector and print a string
// representation of the entity to stdout.
//
// Secondly, lets find out which of them are IfcWindows.
// In order to access the additional properties that windows
// have on top af the properties of building elements,
// 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.
IfcSchema::IfcBuildingElement::list::ptr elements = file.instances_by_type<IfcSchema::IfcBuildingElement>();
// Lets get a list of IfcBuildingElements, this is the parent
// type of things like walls, windows and doors.
// entitiesByType is a templated function and returns a
// templated class that behaves like a std::vector.
// Note that the return types are all typedef'ed as members of
// the generated classes, ::list for the templated vector class,
// ::ptr for a shared pointer and ::it for an iterator.
// We will simply iterate over the vector and print a string
// representation of the entity to stdout.
//
// Secondly, lets find out which of them are IfcWindows.
// In order to access the additional properties that windows
// have on top af the properties of building elements,
// 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.
IfcSchema::IfcBuildingElement::list::ptr elements = file.instances_by_type<IfcSchema::IfcBuildingElement>();
std::cout << "Found " << elements->size() << " elements in " << argv[1] << ":" << std::endl;
for (IfcSchema::IfcBuildingElement::list::it it = elements->begin(); it != elements->end(); ++it) {
const IfcSchema::IfcBuildingElement* element = *it;
std::cout << element->data().toString() << std::endl;
const IfcSchema::IfcWindow* window;
if ((window = element->as<IfcSchema::IfcWindow>()) != 0) {
if (window->OverallWidth() && window->OverallHeight()) {
const double area = *window->OverallWidth() * *window->OverallHeight();
std::cout << "The area of this window is " << area << std::endl;
}
}
std::cout << "Found " << elements->size() << " elements in " << argv[1] << ":" << std::endl;
}
for (IfcSchema::IfcBuildingElement::list::it it = elements->begin(); it != elements->end(); ++it) {
}
const IfcSchema::IfcBuildingElement* element = *it;
std::cout << element->data().toString() << std::endl;
const IfcSchema::IfcWindow* window;
if ((window = element->as<IfcSchema::IfcWindow>()) != 0) {
if (window->OverallWidth() && window->OverallHeight()) {
const double area = *window->OverallWidth() * *window->OverallHeight();
std::cout << "The area of this window is " << area << std::endl;
}
}
}
}