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
+3 -2
View File
@@ -25,12 +25,13 @@
// Sections and page number for this document are cited in the code comments. // Sections and page number for this document are cited in the code comments.
// Disable warnings coming from IfcOpenShell // Disable warnings coming from IfcOpenShell
#pragma warning(disable:4018 4267 4250 4984 4985) #pragma warning(disable : 4018 4267 4250 4984 4985)
#include "../ifcparse/IfcHierarchyHelper.h"
#include "../ifcparse/Ifc4x3_add2.h" #include "../ifcparse/Ifc4x3_add2.h"
#include "../ifcparse/IfcHierarchyHelper.h"
#include <boost/math/constants/constants.hpp> #include <boost/math/constants/constants.hpp>
#include <fstream>
const double PI = boost::math::constants::pi<double>(); const double PI = boost::math::constants::pi<double>();
double to_radian(double deg) { return PI * deg / 180; } double to_radian(double deg) { return PI * deg / 180; }
+45 -46
View File
@@ -20,8 +20,9 @@
// TODO: Multiple schemas // TODO: Multiple schemas
#define IfcSchema Ifc2x3 #define IfcSchema Ifc2x3
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/Ifc2x3.h" #include "../ifcparse/Ifc2x3.h"
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/IfcLogger.h"
#if USE_VLD #if USE_VLD
#include <vld.h> #include <vld.h>
@@ -29,54 +30,52 @@
int main(int argc, char** argv) { int main(int argc, char** argv) {
if ( argc != 2 ) { if (argc != 2) {
std::cout << "usage: IfcParseExamples <filename.ifc>" << std::endl; std::cout << "usage: IfcParseExamples <filename.ifc>" << std::endl;
return 1; return 1;
} }
// Redirect the output (both progress and log) to stdout // Redirect the output (both progress and log) to stdout
Logger::SetOutput(&std::cout,&std::cout); Logger::SetOutput(&std::cout, &std::cout);
// Parse the IFC file provided in argv[1] // Parse the IFC file provided in argv[1]
IfcParse::IfcFile file(argv[1]); IfcParse::IfcFile file(argv[1]);
if (!file.good()) { if (!file.good()) {
std::cout << "Unable to parse .ifc file" << std::endl; std::cout << "Unable to parse .ifc file" << std::endl;
return 1; return 1;
} }
// Lets get a list of IfcBuildingElements, this is the parent // Lets get a list of IfcBuildingElements, this is the parent
// type of things like walls, windows and doors. // type of things like walls, windows and doors.
// entitiesByType is a templated function and returns a // entitiesByType is a templated function and returns a
// templated class that behaves like a std::vector. // templated class that behaves like a std::vector.
// Note that the return types are all typedef'ed as members of // Note that the return types are all typedef'ed as members of
// the generated classes, ::list for the templated vector class, // the generated classes, ::list for the templated vector class,
// ::ptr for a shared pointer and ::it for an iterator. // ::ptr for a shared pointer and ::it for an iterator.
// We will simply iterate over the vector and print a string // We will simply iterate over the vector and print a string
// representation of the entity to stdout. // representation of the entity to stdout.
// //
// Secondly, lets find out which of them are IfcWindows. // Secondly, lets find out which of them are IfcWindows.
// In order to access the additional properties that windows // In order to access the additional properties that windows
// have on top af the properties of building elements, // have on top af the properties of building elements,
// we need to cast them to IfcWindows. Since these properties // we need to cast them to IfcWindows. Since these properties
// are optional we need to make sure the properties are // are optional we need to make sure the properties are
// defined for the window in question before accessing them. // defined for the window in question before accessing them.
IfcSchema::IfcBuildingElement::list::ptr elements = file.instances_by_type<IfcSchema::IfcBuildingElement>(); IfcSchema::IfcBuildingElement::list::ptr elements = file.instances_by_type<IfcSchema::IfcBuildingElement>();
std::cout << "Found " << elements->size() << " elements in " << argv[1] << ":" << 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;
}
}
} 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;
}
}
}
}