mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-16 10:34:31 +00:00
Merge branch 'v0.8.0' into tfk-rocksdb-storage
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
// @todo use std::numbers::pi when upgrading to C++ 20
|
||||
static const double PI = boost::math::constants::pi<double>();
|
||||
|
||||
#include <boost/math/quadrature/trapezoidal.hpp>
|
||||
|
||||
#ifdef HAS_SCHEMA_4x3_add2
|
||||
|
||||
@@ -207,7 +208,7 @@ Ifc4x3_add2::IfcAlignment* addHorizontalAlignment(IfcHierarchyHelper<Ifc4x3_add2
|
||||
|
||||
placement = file.addLocalPlacement();
|
||||
|
||||
// the alignment has two representations, a plan view footprint
|
||||
// the alignment has a plan view footprint representation
|
||||
typename aggregate_of<Ifc4x3_add2::IfcRepresentation>::ptr alignment_representations(new aggregate_of<Ifc4x3_add2::IfcRepresentation>());
|
||||
alignment_representations->push(footprint_shape_representation); // 2D footprint
|
||||
|
||||
@@ -243,21 +244,20 @@ std::tuple<typename aggregate_of<Ifc4x3_add2::IfcObjectDefinition>::ptr, typenam
|
||||
// back gradient
|
||||
auto dxBG = xPVI - xPBG;
|
||||
auto dyBG = yPVI - yPBG;
|
||||
auto start_slope = atan2(dyBG, dxBG);
|
||||
auto start_slope = tan(atan2(dyBG,dxBG));
|
||||
|
||||
// forward gradient
|
||||
point_iter++;
|
||||
std::tie(xPFG, yPFG) = *point_iter;
|
||||
auto dxFG = xPFG - xPVI;
|
||||
auto dyFG = yPFG - yPVI;
|
||||
auto end_slope = atan2(dyFG, dxFG);
|
||||
auto end_slope = tan(atan2(dyFG,dxFG));
|
||||
|
||||
double xEVC = xPVI + length / 2;
|
||||
double yEVC = yPVI + end_slope * length / 2;
|
||||
|
||||
// create gradient
|
||||
{
|
||||
file.addDoublet<Ifc4x3_add2::IfcCartesianPoint>(xPBG, yPBG);
|
||||
auto gradient_length = dxBG - length/2;
|
||||
auto design_parameters = new Ifc4x3_add2::IfcAlignmentVerticalSegment(boost::none, boost::none, xPBG, gradient_length, yPBG, start_slope, start_slope, boost::none, Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CONSTANTGRADIENT);
|
||||
auto alignment_segment = new Ifc4x3_add2::IfcAlignmentSegment(IfcParse::IfcGlobalId(), nullptr, boost::none, boost::none, boost::none, nullptr, nullptr, design_parameters);
|
||||
@@ -273,8 +273,6 @@ std::tuple<typename aggregate_of<Ifc4x3_add2::IfcObjectDefinition>::ptr, typenam
|
||||
double xBVC = xPVI - length / 2;
|
||||
double yBVC = yPVI - start_slope * length / 2;
|
||||
|
||||
file.addDoublet<Ifc4x3_add2::IfcCartesianPoint>(xBVC, yBVC);
|
||||
|
||||
auto design_parameters = new Ifc4x3_add2::IfcAlignmentVerticalSegment(boost::none, boost::none, xBVC, length, yBVC, start_slope, end_slope, 1 / k, Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_PARABOLICARC);
|
||||
auto alignment_segment = new Ifc4x3_add2::IfcAlignmentSegment(IfcParse::IfcGlobalId(), nullptr, boost::none, boost::none, boost::none, nullptr, nullptr, design_parameters);
|
||||
vertical_segments->push(alignment_segment);
|
||||
@@ -292,9 +290,9 @@ std::tuple<typename aggregate_of<Ifc4x3_add2::IfcObjectDefinition>::ptr, typenam
|
||||
// create last tangent run
|
||||
auto dx = xPVI - xPBG;
|
||||
auto dy = yPVI - yPBG;
|
||||
auto slope = atan2(dy, dx);
|
||||
auto gradient_length = sqrt(dx * dx + dy * dy);
|
||||
file.addDoublet<Ifc4x3_add2::IfcCartesianPoint>(xPBG, yPBG);
|
||||
auto slope = tan(atan2(dy,dx));
|
||||
auto gradient_length = dx;
|
||||
|
||||
auto design_parameters = new Ifc4x3_add2::IfcAlignmentVerticalSegment(boost::none, boost::none, xPBG, gradient_length, yPBG, slope, slope, boost::none, Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CONSTANTGRADIENT);
|
||||
auto alignment_segment = new Ifc4x3_add2::IfcAlignmentSegment(IfcParse::IfcGlobalId(), nullptr, boost::none, boost::none, boost::none, nullptr, nullptr, design_parameters);
|
||||
vertical_segments->push(alignment_segment);
|
||||
@@ -303,7 +301,6 @@ std::tuple<typename aggregate_of<Ifc4x3_add2::IfcObjectDefinition>::ptr, typenam
|
||||
}
|
||||
|
||||
// create zero length terminator segment
|
||||
file.addDoublet<Ifc4x3_add2::IfcCartesianPoint>(xPVI, yPVI);
|
||||
design_parameters = new Ifc4x3_add2::IfcAlignmentVerticalSegment(boost::none, boost::none, xPVI, 0.0, yPVI, slope, slope, boost::none, Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CONSTANTGRADIENT);
|
||||
alignment_segment = new Ifc4x3_add2::IfcAlignmentSegment(IfcParse::IfcGlobalId(), nullptr, boost::none, boost::none, boost::none, nullptr, nullptr, design_parameters);
|
||||
vertical_segments->push(alignment_segment);
|
||||
@@ -356,14 +353,14 @@ Ifc4x3_add2::IfcAlignment* addAlignment(IfcHierarchyHelper<Ifc4x3_add2>& file, c
|
||||
typename aggregate_of<Ifc4x3_add2::IfcRepresentationItem>::ptr alignment_representation_items(new aggregate_of<Ifc4x3_add2::IfcRepresentationItem>());
|
||||
alignment_representation_items->push(composite_curve);
|
||||
|
||||
// create the footprint representation
|
||||
auto footprint_shape_representation = new Ifc4x3_add2::IfcShapeRepresentation(axis_model_representation_subcontext, std::string("FootPrint"), std::string("Curve2D"), alignment_representation_items);
|
||||
file.addEntity(footprint_shape_representation);
|
||||
|
||||
// the gradient curve is a representation item
|
||||
typename aggregate_of<typename Ifc4x3_add2::IfcRepresentationItem>::ptr profile_representation_items(new aggregate_of<Ifc4x3_add2::IfcRepresentationItem>());
|
||||
profile_representation_items->push(gradient_curve);
|
||||
|
||||
// create footprint representation
|
||||
auto footprint_shape_representation = new Ifc4x3_add2::IfcShapeRepresentation(axis_model_representation_subcontext, std::string("FootPrint"), std::string("Curve2D"), alignment_representation_items);
|
||||
file.addEntity(footprint_shape_representation);
|
||||
|
||||
// create the axis representation
|
||||
auto axis3d_shape_representation = new Ifc4x3_add2::IfcShapeRepresentation(axis_model_representation_subcontext, std::string("Axis"), std::string("Curve3D"), profile_representation_items);
|
||||
file.addEntity(axis3d_shape_representation);
|
||||
@@ -373,10 +370,10 @@ Ifc4x3_add2::IfcAlignment* addAlignment(IfcHierarchyHelper<Ifc4x3_add2>& file, c
|
||||
_createSegmentRepresentations(file, placement, axis_model_representation_subcontext, horizontal_curve_segments, horizontal_segments);
|
||||
_createSegmentRepresentations(file, placement, axis_model_representation_subcontext, vertical_curve_segments, vertical_segments);
|
||||
|
||||
// the alignment has two representations, a plan view footprint and a 3d curve
|
||||
// the alignment has a 3d curve representation
|
||||
typename aggregate_of<typename Ifc4x3_add2::IfcRepresentation>::ptr alignment_representations(new aggregate_of<Ifc4x3_add2::IfcRepresentation>());
|
||||
alignment_representations->push(footprint_shape_representation); // 2D footprint
|
||||
alignment_representations->push(axis3d_shape_representation); // 3D curve
|
||||
alignment_representations->push(footprint_shape_representation); // 2D curve
|
||||
alignment_representations->push(axis3d_shape_representation); // 3D curve
|
||||
|
||||
// create the alignment product definition
|
||||
product_definition_shape = new Ifc4x3_add2::IfcProductDefinitionShape(std::string("Alignment Product Definition Shape"), boost::none, alignment_representations);
|
||||
@@ -688,13 +685,18 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
||||
new Ifc4x3_add2::IfcCartesianPoint(std::vector<double>({0, 0})),
|
||||
new Ifc4x3_add2::IfcVector(new Ifc4x3_add2::IfcDirection(std::vector<double>{1, 0}), 1.0));
|
||||
|
||||
// IfcCurveSegment.SegmentLength is the length of the curve segment, not the horizontal length.
|
||||
auto dx = cos(atan(start_gradient));
|
||||
auto dy = sin(atan(start_gradient));
|
||||
auto segment_curve_length = horizontal_length / dx;
|
||||
|
||||
auto curve_segment = new Ifc4x3_add2::IfcCurveSegment(
|
||||
Ifc4x3_add2::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT,
|
||||
new Ifc4x3_add2::IfcAxis2Placement2D(
|
||||
new Ifc4x3_add2::IfcCartesianPoint({start_distance_along, start_height}),
|
||||
new Ifc4x3_add2::IfcDirection({sqrt(1.0 - start_gradient * start_gradient), start_gradient})),
|
||||
new Ifc4x3_add2::IfcDirection({dx,dy})),
|
||||
new Ifc4x3_add2::IfcLengthMeasure(0.0), // start
|
||||
new Ifc4x3_add2::IfcLengthMeasure(horizontal_length),
|
||||
new Ifc4x3_add2::IfcLengthMeasure(segment_curve_length),
|
||||
parent_curve);
|
||||
|
||||
result.first = curve_segment;
|
||||
@@ -710,11 +712,22 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
||||
std::vector<double>{A, B, C},
|
||||
boost::none);
|
||||
|
||||
// IfcCurveSegment.SegmentLength is the length of the curve segment, not the horizontal length.
|
||||
// The curve length is calculated by integrating the differential curve length equation sqrt(1 + (dy/dx)^2) from 0 to horizontal_length.
|
||||
// y = A + Bx + Cx^2
|
||||
// dy/dx = B + 2Cx
|
||||
auto dx = cos(atan(start_gradient));
|
||||
auto dy = sin(atan(start_gradient));
|
||||
auto curve_length_fn = [B, C](double x) { return sqrt(1 + pow(B + 2*C * x, 2)); };
|
||||
auto segment_curve_length = boost::math::quadrature::trapezoidal(curve_length_fn, 0.0, horizontal_length);
|
||||
|
||||
auto curve_segment = new Ifc4x3_add2::IfcCurveSegment(
|
||||
Ifc4x3_add2::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT,
|
||||
new Ifc4x3_add2::IfcAxis2Placement2D(new Ifc4x3_add2::IfcCartesianPoint({start_distance_along, start_height}), new Ifc4x3_add2::IfcDirection({sqrt(1.0 - start_gradient * start_gradient), start_gradient})),
|
||||
new Ifc4x3_add2::IfcAxis2Placement2D(
|
||||
new Ifc4x3_add2::IfcCartesianPoint({start_distance_along, start_height}),
|
||||
new Ifc4x3_add2::IfcDirection({dx,dy})),
|
||||
new Ifc4x3_add2::IfcLengthMeasure(0.0),
|
||||
new Ifc4x3_add2::IfcLengthMeasure(horizontal_length),
|
||||
new Ifc4x3_add2::IfcLengthMeasure(segment_curve_length),
|
||||
parent_curve);
|
||||
|
||||
result.first = curve_segment;
|
||||
@@ -735,11 +748,14 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
||||
new Ifc4x3_add2::IfcDirection(std::vector<double>{1, 0})),
|
||||
radius);
|
||||
|
||||
|
||||
auto segment_curve_length = radius * fabs(end_angle - start_angle);
|
||||
|
||||
Ifc4x3_add2::IfcCurveSegment* curve_segment = new Ifc4x3_add2::IfcCurveSegment(
|
||||
Ifc4x3_add2::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT,
|
||||
new Ifc4x3_add2::IfcAxis2Placement2D(new Ifc4x3_add2::IfcCartesianPoint({start_distance_along, start_height}), new Ifc4x3_add2::IfcDirection({1.0, 0.0})),
|
||||
new Ifc4x3_add2::IfcLengthMeasure(0.0),
|
||||
new Ifc4x3_add2::IfcLengthMeasure(horizontal_length),
|
||||
new Ifc4x3_add2::IfcLengthMeasure(segment_curve_length),
|
||||
parent_curve);
|
||||
|
||||
result.first = curve_segment;
|
||||
|
||||
@@ -46,19 +46,14 @@ namespace {
|
||||
template<typename Variant, typename T>
|
||||
constexpr bool is_type_in_variant_v = is_type_in_variant<Variant, T>::value;
|
||||
|
||||
struct InstanceReference {
|
||||
int v;
|
||||
operator int() const {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Fn>
|
||||
void dispatch_token(int instance_id, int attribute_id, IfcParse::Token t, IfcParse::declaration* decl, Fn fn) {
|
||||
if (t.type == IfcParse::Token_BINARY) {
|
||||
fn(IfcParse::TokenFunc::asBinary(t));
|
||||
} else if (t.type == IfcParse::Token_BOOL) {
|
||||
} else if (IfcParse::TokenFunc::isBool(t)) {
|
||||
fn(IfcParse::TokenFunc::asBool(t));
|
||||
} else if (IfcParse::TokenFunc::isLogical(t)) {
|
||||
fn(IfcParse::TokenFunc::asLogical(t));
|
||||
} else if (t.type == IfcParse::Token_ENUMERATION) {
|
||||
auto& s = IfcParse::TokenFunc::asStringRef(t);
|
||||
if (decl && decl->as_enumeration_type()) {
|
||||
@@ -73,7 +68,7 @@ namespace {
|
||||
} else if (t.type == IfcParse::Token_FLOAT) {
|
||||
fn(IfcParse::TokenFunc::asFloat(t));
|
||||
} else if (t.type == IfcParse::Token_IDENTIFIER) {
|
||||
fn(IfcParse::reference_or_simple_type{ InstanceReference{ IfcParse::TokenFunc::asIdentifier(t) } });
|
||||
fn(IfcParse::reference_or_simple_type{ IfcParse::InstanceReference{ IfcParse::TokenFunc::asIdentifier(t), t.startPos } });
|
||||
} else if (t.type == IfcParse::Token_INT) {
|
||||
fn(IfcParse::TokenFunc::asInt(t));
|
||||
} else if (t.type == IfcParse::Token_STRING) {
|
||||
|
||||
@@ -106,7 +106,15 @@ class IFC_PARSE_API file_open_status {
|
||||
}
|
||||
};
|
||||
|
||||
typedef boost::variant<int, IfcUtil::IfcBaseClass*> reference_or_simple_type;
|
||||
struct InstanceReference {
|
||||
int v;
|
||||
size_t file_offset;
|
||||
operator int() const {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
typedef boost::variant<InstanceReference, IfcUtil::IfcBaseClass*> reference_or_simple_type;
|
||||
typedef std::list<std::pair<MutableAttributeValue, boost::variant<reference_or_simple_type, std::vector<reference_or_simple_type>, std::vector<std::vector<reference_or_simple_type>>>>> unresolved_references;
|
||||
|
||||
struct parse_context {
|
||||
|
||||
@@ -404,47 +404,76 @@ class IFC_PARSE_API IfcHierarchyHelper : public IfcParse::IfcFile {
|
||||
template <class T>
|
||||
void addRelatedObject(typename Schema::IfcObjectDefinition* relating_object,
|
||||
typename Schema::IfcObjectDefinition* related_object,
|
||||
typename Schema::IfcOwnerHistory* owner_hist = 0) {
|
||||
typename T::list::ptr li = instances_by_type<T>();
|
||||
bool found = false;
|
||||
for (typename T::list::it i = li->begin(); i != li->end(); ++i) {
|
||||
T* rel = *i;
|
||||
try {
|
||||
if (get_parent_of_relation(rel) == relating_object) {
|
||||
aggregate_of_instance::ptr products = get_children_of_relation(rel);
|
||||
products->push(related_object);
|
||||
set_children_of_relation(rel, products);
|
||||
typename Schema::IfcOwnerHistory* owner_hist = 0)
|
||||
{
|
||||
if constexpr (std::is_same_v<T, typename Schema::IfcRelDefinesByType>) {
|
||||
typename Schema::IfcRelDefinesByType::list::ptr li = instances_by_type<typename Schema::IfcRelDefinesByType>();
|
||||
bool found = false;
|
||||
for (typename Schema::IfcRelDefinesByType::list::it i = li->begin(); i != li->end(); ++i) {
|
||||
typename Schema::IfcRelDefinesByType* rel = *i;
|
||||
if (rel->RelatingType() == relating_object) {
|
||||
typename Schema::IfcObject::list::ptr objects = rel->RelatedObjects();
|
||||
objects->push(addEntity(related_object)->template as<typename Schema::IfcObject>());
|
||||
rel->setRelatedObjects(objects);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
Logger::Error(e);
|
||||
} catch (...) {
|
||||
Logger::Error("Unknown error in addRelatedObject()");
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (!owner_hist) {
|
||||
owner_hist = getSingle<typename Schema::IfcOwnerHistory>();
|
||||
}
|
||||
if (!owner_hist) {
|
||||
owner_hist = addOwnerHistory();
|
||||
}
|
||||
if (!found) {
|
||||
if (!owner_hist) {
|
||||
owner_hist = getSingle<typename Schema::IfcOwnerHistory>();
|
||||
}
|
||||
if (!owner_hist) {
|
||||
owner_hist = addOwnerHistory();
|
||||
}
|
||||
typename Schema::IfcObject::list::ptr related_objects(new aggregate_of<typename Schema::IfcObject>());
|
||||
related_objects->push(related_object->template as<typename Schema::IfcObject>());
|
||||
typename Schema::IfcRelDefinesByType* t = new typename Schema::IfcRelDefinesByType(IfcParse::IfcGlobalId(), owner_hist, boost::none, boost::none, related_objects, relating_object->template as<typename Schema::IfcTypeObject>());
|
||||
|
||||
aggregate_of_instance::ptr related_objects(new aggregate_of_instance);
|
||||
related_objects->push(related_object);
|
||||
|
||||
T* t = create(&T::Class())->as<T>();
|
||||
t->set_attribute_value(0, (std::string)IfcParse::IfcGlobalId());
|
||||
t->set_attribute_value(1, owner_hist);
|
||||
int relating_index = 4;
|
||||
int related_index = 5;
|
||||
if (T::Class().name() == "IfcRelContainedInSpatialStructure" || std::is_base_of<typename Schema::IfcRelDefines, T>::value) {
|
||||
// some classes have attributes reversed.
|
||||
std::swap(relating_index, related_index);
|
||||
addEntity(t);
|
||||
}
|
||||
} else {
|
||||
typename T::list::ptr li = instances_by_type<T>();
|
||||
bool found = false;
|
||||
for (typename T::list::it i = li->begin(); i != li->end(); ++i) {
|
||||
T* rel = *i;
|
||||
try {
|
||||
if (get_parent_of_relation(rel) == relating_object) {
|
||||
aggregate_of_instance::ptr products = get_children_of_relation(rel);
|
||||
products->push(addEntity(related_object));
|
||||
set_children_of_relation(rel, products);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
Logger::Error(e);
|
||||
} catch (...) {
|
||||
Logger::Error("Unknown error in addRelatedObject()");
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (!owner_hist) {
|
||||
owner_hist = getSingle<typename Schema::IfcOwnerHistory>();
|
||||
}
|
||||
if (!owner_hist) {
|
||||
owner_hist = addOwnerHistory();
|
||||
}
|
||||
|
||||
aggregate_of_instance::ptr related_objects(new aggregate_of_instance);
|
||||
related_objects->push(related_object);
|
||||
|
||||
T* t = create(&T::Class())->as<T>();
|
||||
t->set_attribute_value(0, (std::string)IfcParse::IfcGlobalId());
|
||||
t->set_attribute_value(1, owner_hist);
|
||||
int relating_index = 4;
|
||||
int related_index = 5;
|
||||
if (T::Class().name() == "IfcRelContainedInSpatialStructure" || std::is_base_of<typename Schema::IfcRelDefines, T>::value) {
|
||||
// some classes have attributes reversed.
|
||||
std::swap(relating_index, related_index);
|
||||
}
|
||||
t->set_attribute_value(relating_index, relating_object);
|
||||
t->set_attribute_value(related_index, related_objects);
|
||||
}
|
||||
t->set_attribute_value(relating_index, relating_object);
|
||||
t->set_attribute_value(related_index, related_objects);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,70 +615,4 @@ IFC_PARSE_API void setSurfaceColour(IfcHierarchyHelper<Ifc4x3_add1>& file, Ifc4x
|
||||
IFC_PARSE_API void setSurfaceColour(IfcHierarchyHelper<Ifc4x3_add1>& file, Ifc4x3_add1::IfcRepresentation* shape, Ifc4x3_add1::IfcPresentationStyle* style);
|
||||
#endif
|
||||
|
||||
/*
|
||||
template <>
|
||||
inline void IfcHierarchyHelper::addRelatedObject <typename Schema::IfcRelContainedInSpatialStructure> (typename Schema::IfcObjectDefinition* relating_structure,
|
||||
typename Schema::IfcObjectDefinition* related_object, typename Schema::IfcOwnerHistory* owner_hist)
|
||||
{
|
||||
typename Schema::IfcRelContainedInSpatialStructure::list::ptr li = instances_by_type<typename Schema::IfcRelContainedInSpatialStructure>();
|
||||
bool found = false;
|
||||
for (typename Schema::IfcRelContainedInSpatialStructure::list::it i = li->begin(); i != li->end(); ++i) {
|
||||
typename Schema::IfcRelContainedInSpatialStructure* rel = *i;
|
||||
if (rel->RelatingStructure() == relating_structure) {
|
||||
typename Schema::IfcProduct::list::ptr products = rel->RelatedElements();
|
||||
products->push((typename Schema::IfcProduct*)related_object);
|
||||
rel->setRelatedElements(products);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! found) {
|
||||
if (! owner_hist) {
|
||||
owner_hist = getSingle<typename Schema::IfcOwnerHistory>();
|
||||
}
|
||||
if (! owner_hist) {
|
||||
owner_hist = addOwnerHistory();
|
||||
}
|
||||
typename Schema::IfcProduct::list::ptr related_objects (new aggregate_of<typename Schema::IfcProduct>());
|
||||
related_objects->push((typename Schema::IfcProduct*)related_object);
|
||||
typename Schema::IfcRelContainedInSpatialStructure* t = new typename Schema::IfcRelContainedInSpatialStructure(IfcParse::IfcGlobalId(), owner_hist,
|
||||
boost::none, boost::none, related_objects, (typename Schema::IfcSpatialStructureElement*)relating_structure);
|
||||
|
||||
addEntity(t);
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void IfcHierarchyHelper::addRelatedObject <typename Schema::IfcRelDefinesByType> (typename Schema::IfcObjectDefinition* relating_type,
|
||||
typename Schema::IfcObjectDefinition* related_object, typename Schema::IfcOwnerHistory* owner_hist)
|
||||
{
|
||||
typename Schema::IfcRelDefinesByType::list::ptr li = instances_by_type<typename Schema::IfcRelDefinesByType>();
|
||||
bool found = false;
|
||||
for (typename Schema::IfcRelDefinesByType::list::it i = li->begin(); i != li->end(); ++i) {
|
||||
typename Schema::IfcRelDefinesByType* rel = *i;
|
||||
if (rel->RelatingType() == relating_type) {
|
||||
typename Schema::IfcObject::list::ptr objects = rel->RelatedObjects();
|
||||
objects->push((typename Schema::IfcObject*)related_object);
|
||||
rel->setRelatedObjects(objects);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! found) {
|
||||
if (! owner_hist) {
|
||||
owner_hist = getSingle<typename Schema::IfcOwnerHistory>();
|
||||
}
|
||||
if (! owner_hist) {
|
||||
owner_hist = addOwnerHistory();
|
||||
}
|
||||
typename Schema::IfcObject::list::ptr related_objects (new aggregate_of<typename Schema::IfcObject>());
|
||||
related_objects->push((typename Schema::IfcObject*)related_object);
|
||||
typename Schema::IfcRelDefinesByType* t = new typename Schema::IfcRelDefinesByType(IfcParse::IfcGlobalId(), owner_hist,
|
||||
boost::none, boost::none, related_objects, (typename Schema::IfcTypeObject*)relating_type);
|
||||
|
||||
addEntity(t);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1226,6 +1226,23 @@ class apply_individual_instance_visitor {
|
||||
|
||||
template <typename T>
|
||||
void IfcUtil::IfcBaseClass::set_attribute_value(size_t i, const T& t) {
|
||||
if constexpr (std::is_same_v<std::decay_t<T>, double>) {
|
||||
if (!std::isfinite(t)) {
|
||||
throw IfcParse::IfcException("Only finite values are allowed");
|
||||
}
|
||||
}
|
||||
if constexpr (std::is_same_v<std::decay_t<T>, std::vector<double>>) {
|
||||
if (std::any_of(t.begin(), t.end(), [](double d) { return !std::isfinite(d); })) {
|
||||
throw IfcParse::IfcException("Only finite values are allowed");
|
||||
}
|
||||
}
|
||||
if constexpr (std::is_same_v<std::decay_t<T>, std::vector<std::vector<double>>>) {
|
||||
for (auto& tt : t) {
|
||||
if (std::any_of(tt.begin(), tt.end(), [](double d) { return !std::isfinite(d); })) {
|
||||
throw IfcParse::IfcException("Only finite values are allowed");
|
||||
}
|
||||
}
|
||||
}
|
||||
auto current_attribute = get_attribute_value(i);
|
||||
if (file_ != nullptr) {
|
||||
|
||||
@@ -1567,10 +1584,10 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::IfcSpfSt
|
||||
const auto& ref = p.first.name_;
|
||||
const auto& refattr = p.first.index_;
|
||||
if (auto* v = boost::get<reference_or_simple_type>(&p.second)) {
|
||||
if (auto* name = boost::get<int>(v)) {
|
||||
if (auto* name = boost::get<InstanceReference>(v)) {
|
||||
auto it = byid_.find(*name);
|
||||
if (it == byid_.end()) {
|
||||
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found");
|
||||
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
|
||||
} else {
|
||||
byid_[p.first.name_]->data().set_attribute_value(nullptr, nullptr, 0, p.first.index_, it->second);
|
||||
}
|
||||
@@ -1581,10 +1598,10 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::IfcSpfSt
|
||||
aggregate_of_instance::ptr instances(new aggregate_of_instance);
|
||||
instances->reserve(v->size());
|
||||
for (const auto& vi : *v) {
|
||||
if (auto* name = boost::get<int>(&vi)) {
|
||||
if (auto* name = boost::get<InstanceReference>(&vi)) {
|
||||
auto it = byid_.find(*name);
|
||||
if (it == byid_.end()) {
|
||||
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found");
|
||||
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
|
||||
} else {
|
||||
instances->push(it->second);
|
||||
}
|
||||
@@ -1598,10 +1615,10 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::IfcSpfSt
|
||||
for (const auto& vi : *v) {
|
||||
std::vector<IfcUtil::IfcBaseClass*> inner;
|
||||
for (const auto& vii : vi) {
|
||||
if (auto* name = boost::get<int>(&vii)) {
|
||||
if (auto* name = boost::get<InstanceReference>(&vii)) {
|
||||
auto it = byid_.find(*name);
|
||||
if (it == byid_.end()) {
|
||||
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found");
|
||||
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
|
||||
} else {
|
||||
inner.push_back(it->second);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user