diff --git a/src/examples/IfcAlignment.cpp b/src/examples/IfcAlignment.cpp index 10dc994915..89a6ee45a7 100644 --- a/src/examples/IfcAlignment.cpp +++ b/src/examples/IfcAlignment.cpp @@ -25,12 +25,13 @@ // Sections and page number for this document are cited in the code comments. // 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/IfcHierarchyHelper.h" #include +#include const double PI = boost::math::constants::pi(); double to_radian(double deg) { return PI * deg / 180; } diff --git a/src/examples/IfcParseExamples.cpp b/src/examples/IfcParseExamples.cpp index c5eedae235..93b9b3f2eb 100644 --- a/src/examples/IfcParseExamples.cpp +++ b/src/examples/IfcParseExamples.cpp @@ -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 @@ -29,54 +30,52 @@ int main(int argc, char** argv) { - if ( argc != 2 ) { - std::cout << "usage: IfcParseExamples " << std::endl; - return 1; - } + if (argc != 2) { + std::cout << "usage: IfcParseExamples " << 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(); + // 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(); - 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()) != 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) { -} \ No newline at end of file + const IfcSchema::IfcBuildingElement* element = *it; + std::cout << element->data().toString() << std::endl; + + const IfcSchema::IfcWindow* window; + if ((window = element->as()) != 0) { + if (window->OverallWidth() && window->OverallHeight()) { + const double area = *window->OverallWidth() * *window->OverallHeight(); + std::cout << "The area of this window is " << area << std::endl; + } + } + } +}