mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 02:21:02 +00:00
Changes after merge and fixes for examples
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "../ifcparse/IfcFile.h"
|
#include "../ifcparse/IfcFile.h"
|
||||||
#include "../ifcparse/IfcLogger.h"
|
#include "../ifcparse/IfcLogger.h"
|
||||||
|
#include "../ifcparse/Ifc2x3.h"
|
||||||
|
|
||||||
#include <boost/preprocessor/stringize.hpp>
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
#include <boost/preprocessor/seq/for_each.hpp>
|
#include <boost/preprocessor/seq/for_each.hpp>
|
||||||
@@ -79,31 +80,31 @@ struct is_ifc4_or_higher<T, std::void_t<decltype(T::IfcMaterialDefinition)>> : s
|
|||||||
|
|
||||||
typedef std::map<std::string, std::map<std::string, std::string>> element_properties;
|
typedef std::map<std::string, std::map<std::string, std::string>> element_properties;
|
||||||
|
|
||||||
std::string format_string(const Argument* argument) {
|
std::string format_string(const AttributeValue& argument) {
|
||||||
// Argument is a runtime tagged variant for the various data types in a IFC model,
|
// Argument is a runtime tagged variant for the various data types in a IFC model,
|
||||||
// in this particular case we only care about flattening it to a string.
|
// in this particular case we only care about flattening it to a string.
|
||||||
// @todo mostly duplicated from XmlSerializer.cpp
|
// @todo mostly duplicated from XmlSerializer.cpp
|
||||||
if (argument->isNull()) {
|
if (argument.isNull()) {
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
auto argument_type = argument->type();
|
auto argument_type = argument.type();
|
||||||
switch (argument_type) {
|
switch (argument_type) {
|
||||||
case IfcUtil::Argument_BOOL: {
|
case IfcUtil::Argument_BOOL: {
|
||||||
const bool b = *argument;
|
const bool b = argument;
|
||||||
return b ? "true" : "false";
|
return b ? "true" : "false";
|
||||||
}
|
}
|
||||||
case IfcUtil::Argument_DOUBLE: {
|
case IfcUtil::Argument_DOUBLE: {
|
||||||
const double d = *argument;
|
const double d = argument;
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << std::setprecision(std::numeric_limits< double >::max_digits10) << d;
|
stream << std::setprecision(std::numeric_limits< double >::max_digits10) << d;
|
||||||
return stream.str();
|
return stream.str();
|
||||||
break; }
|
break; }
|
||||||
case IfcUtil::Argument_STRING:
|
case IfcUtil::Argument_STRING:
|
||||||
case IfcUtil::Argument_ENUMERATION: {
|
case IfcUtil::Argument_ENUMERATION: {
|
||||||
return static_cast<std::string>(*argument);
|
return static_cast<std::string>(argument);
|
||||||
break; }
|
break; }
|
||||||
case IfcUtil::Argument_INT: {
|
case IfcUtil::Argument_INT: {
|
||||||
const int v = *argument;
|
const int v = argument;
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << v;
|
stream << v;
|
||||||
return stream.str();
|
return stream.str();
|
||||||
@@ -136,7 +137,7 @@ void process_pset(element_properties& props, const T* inst) {
|
|||||||
if (!singleval->NominalValue()) {
|
if (!singleval->NominalValue()) {
|
||||||
propvalue = "-";
|
propvalue = "-";
|
||||||
} else {
|
} else {
|
||||||
props[*pset->Name()][propname] = format_string(singleval->NominalValue()->template as<IfcUtil::IfcBaseClass>()->data().getArgument(0));
|
props[*pset->Name()][propname] = format_string(singleval->NominalValue()->template as<IfcUtil::IfcBaseClass>()->data().get_attribute_value(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,8 +149,8 @@ void process_pset(element_properties& props, const T* inst) {
|
|||||||
auto qs = qset->Quantities();
|
auto qs = qset->Quantities();
|
||||||
for (auto it = qs->begin(); it != qs->end(); ++it) {
|
for (auto it = qs->begin(); it != qs->end(); ++it) {
|
||||||
auto& q = *it;
|
auto& q = *it;
|
||||||
if (q->template as<typename Schema::IfcPhysicalSimpleQuantity>() && q->data().getArgument(3)->type() == IfcUtil::Argument_DOUBLE) {
|
if (q->template as<typename Schema::IfcPhysicalSimpleQuantity>() && q->data().get_attribute_value(3).type() == IfcUtil::Argument_DOUBLE) {
|
||||||
double v = *q->data().getArgument(3);
|
double v = q->data().get_attribute_value(3);
|
||||||
props[*qset->Name()][q->Name()] = std::to_string(v);
|
props[*qset->Name()][q->Name()] = std::to_string(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,7 +265,8 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
for (auto it = elements->begin(); it != elements->end(); ++it) {
|
for (auto it = elements->begin(); it != elements->end(); ++it) {
|
||||||
const auto* element = *it;
|
const auto* element = *it;
|
||||||
std::cout << element->data().toString() << std::endl;
|
element->toString(std::cout);
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
const IfcSchema::IfcWindow* window;
|
const IfcSchema::IfcWindow* window;
|
||||||
if ((window = element->as<IfcSchema::IfcWindow>()) != 0) {
|
if ((window = element->as<IfcSchema::IfcWindow>()) != 0) {
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
|
|||||||
if (associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>() || associated_material->as<IfcSchema::IfcMaterialLayerSet>()) {
|
if (associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>() || associated_material->as<IfcSchema::IfcMaterialLayerSet>()) {
|
||||||
IfcSchema::IfcMaterialLayerSet* layerset;
|
IfcSchema::IfcMaterialLayerSet* layerset;
|
||||||
if (auto *m = associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>()) {
|
if (auto *m = associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>()) {
|
||||||
if (m->get("ForLayerSet")->isNull()) {
|
if (m->get("ForLayerSet").isNull()) {
|
||||||
Logger::Warning("Missing ForLayerSet for:", m);
|
Logger::Warning("Missing ForLayerSet for:", m);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -322,7 +322,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
|
|||||||
if (associated_material->as<IfcSchema::IfcMaterialProfileSetUsage>() || associated_material->as<IfcSchema::IfcMaterialProfileSet>()) {
|
if (associated_material->as<IfcSchema::IfcMaterialProfileSetUsage>() || associated_material->as<IfcSchema::IfcMaterialProfileSet>()) {
|
||||||
IfcSchema::IfcMaterialProfileSet* profileset;
|
IfcSchema::IfcMaterialProfileSet* profileset;
|
||||||
if (auto* m = associated_material->as<IfcSchema::IfcMaterialProfileSetUsage>()) {
|
if (auto* m = associated_material->as<IfcSchema::IfcMaterialProfileSetUsage>()) {
|
||||||
if (m->get("ForProfileSet")->isNull()) {
|
if (m->get("ForProfileSet").isNull()) {
|
||||||
Logger::Warning("Missing ForProfileSet for:", m);
|
Logger::Warning("Missing ForProfileSet for:", m);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user