mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
Fixes domain of vertical and cant pwf (Issue #5072)
This commit is contained in:
@@ -92,7 +92,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
|
||||
return loop;
|
||||
}
|
||||
else {
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(pwfs,&settings_,inst);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(0.0,pwfs,&settings_,inst);
|
||||
return pwf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,7 +890,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCurveSegment* inst) {
|
||||
|
||||
taxonomy::piecewise_function::spans spans;
|
||||
spans.emplace_back(fabs(length), fn);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(spans,&settings_,inst);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(0.0, spans,&settings_,inst);
|
||||
return pwf;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,9 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
|
||||
if (!inst->BaseCurve()->as<IfcSchema::IfcCompositeCurve>())
|
||||
Logger::Warning("Expected IfcGradientCurve.BaseCurve to be IfcCompositeCurve", inst); // CT 4.1.7.1.1.2
|
||||
|
||||
auto horizontal = taxonomy::cast<taxonomy::piecewise_function>(map(inst->BaseCurve()));
|
||||
|
||||
auto segments = inst->Segments();
|
||||
|
||||
std::vector<taxonomy::piecewise_function::ptr> pwfs;
|
||||
std::vector<taxonomy::piecewise_function::ptr> pwfs;
|
||||
|
||||
for (auto& segment : *segments) {
|
||||
if (segment->as<IfcSchema::IfcCurveSegment>()) {
|
||||
@@ -48,11 +46,33 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
auto vertical = taxonomy::make<taxonomy::piecewise_function>(pwfs,&settings_);
|
||||
|
||||
// Get starting position of gradient curve, which is relative to the base curve
|
||||
// The gradient curve can start before or after the start of the base curve
|
||||
auto first_segment = *(segments->begin());
|
||||
auto p = taxonomy::cast<taxonomy::matrix4>(map(first_segment->as<IfcSchema::IfcCurveSegment>()->Placement()));
|
||||
const Eigen::Matrix4d& m = p->ccomponents();
|
||||
double gradient_start = m(0, 3); // start of vertical (row 0, col 3) - "Distance Along" horizontal curve
|
||||
|
||||
// create the vertical pwf
|
||||
auto vertical = taxonomy::make<taxonomy::piecewise_function>(gradient_start, pwfs, &settings_);
|
||||
|
||||
// Determine the valid domain of the PWF... the valid domain is where both
|
||||
// the base curve and gradient curves are defined
|
||||
auto horizontal = taxonomy::cast<taxonomy::piecewise_function>(map(inst->BaseCurve()));
|
||||
double start = std::max(horizontal->start(),vertical->start());
|
||||
double end = std::min(horizontal->end(), vertical->end());
|
||||
double length = end - start;
|
||||
|
||||
if (!(0 < length)) {
|
||||
Logger::Error("IfcGradientCurve does not have a common domain with BaseCurve");
|
||||
}
|
||||
|
||||
// define the callback function for the gradient curve
|
||||
auto composition = [horizontal, vertical](double u)->Eigen::Matrix4d {
|
||||
auto xy = horizontal->evaluate(u);
|
||||
// u is distance from start of gradient curve (vertical)
|
||||
// add vertical->start() to u to get distance from start of horizontal
|
||||
auto xy = horizontal->evaluate(u + vertical->start());
|
||||
auto uz = vertical->evaluate(u);
|
||||
|
||||
uz.col(3)(0) = 0.0; // x is distance along. zero it out so it doesn't add to the x from horizontal
|
||||
@@ -64,11 +84,9 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
|
||||
return m;
|
||||
};
|
||||
|
||||
double min_length = std::min(horizontal->length(), vertical->length());
|
||||
|
||||
taxonomy::piecewise_function::spans spans;
|
||||
spans.emplace_back(min_length, composition);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(spans, &settings_, inst);
|
||||
spans.emplace_back(length, composition);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(start, spans, &settings_, inst);
|
||||
return pwf;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,9 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
|
||||
auto first_offset_value = *(offset_values->begin());
|
||||
|
||||
auto basis_curve = inst->BasisCurve();
|
||||
//auto pw_curve = ifcopenshell::geometry::piecewise_from_item(map(basis_curve));
|
||||
auto pw_curve = taxonomy::dcast<taxonomy::piecewise_function>(map(basis_curve));
|
||||
|
||||
double start = pw_curve->start();
|
||||
double basis_curve_length = pw_curve->length();
|
||||
|
||||
taxonomy::piecewise_function::spans offset_spans;
|
||||
@@ -143,7 +144,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
|
||||
offset_spans.emplace_back(l, fn);
|
||||
}
|
||||
|
||||
auto offsets = taxonomy::make<taxonomy::piecewise_function>(offset_spans,&settings_);
|
||||
auto offsets = taxonomy::make<taxonomy::piecewise_function>(start,offset_spans,&settings_);
|
||||
|
||||
auto composition = [pw_curve, offsets](double u) -> Eigen::Matrix4d {
|
||||
auto p = pw_curve->evaluate(u);
|
||||
@@ -156,7 +157,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
|
||||
// this may change depending on decisions in the bSI-IF
|
||||
taxonomy::piecewise_function::spans spans;
|
||||
spans.emplace_back(basis_curve_length, composition);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(spans,&settings_,inst);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(start,spans,&settings_,inst);
|
||||
return pwf;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* ins
|
||||
if (!inst->BaseCurve()->as<IfcSchema::IfcGradientCurve>())
|
||||
Logger::Warning("Expected IfcSegmentedReferenceCurve.BaseCurve to be IfcGradient", inst); // CT 4.1.7.1.1.3
|
||||
|
||||
auto gradient = taxonomy::cast<taxonomy::piecewise_function>(map(inst->BaseCurve()));
|
||||
|
||||
auto segments = inst->Segments();
|
||||
|
||||
std::vector<taxonomy::piecewise_function::ptr> pwfs;
|
||||
@@ -46,11 +44,34 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* ins
|
||||
Logger::Error("Unsupported");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
auto cant = taxonomy::make<taxonomy::piecewise_function>(pwfs,&settings_);
|
||||
}
|
||||
|
||||
// Get starting position of cant curve, relative to the gradient curve.
|
||||
// The cant curve can start before or after the start of the gradient curve
|
||||
auto first_segment = *(segments->begin());
|
||||
auto p = taxonomy::cast<taxonomy::matrix4>(map(first_segment->as<IfcSchema::IfcCurveSegment>()->Placement()));
|
||||
const Eigen::Matrix4d& m = p->ccomponents();
|
||||
double cant_start = m(0, 3); // start of cant curve
|
||||
|
||||
auto cant = taxonomy::make<taxonomy::piecewise_function>(cant_start,pwfs,&settings_);
|
||||
|
||||
// Determine the valid domain of the PWF... the valid domain is where
|
||||
// horizontal, gradient and cant curves are defined
|
||||
auto gradient = taxonomy::cast<taxonomy::piecewise_function>(map(inst->BaseCurve()));
|
||||
auto horizontal = taxonomy::cast<taxonomy::piecewise_function>(map(inst->BaseCurve()->as<IfcSchema::IfcGradientCurve>()->BaseCurve()));
|
||||
double start = std::max(std::max(cant->start(), gradient->start()), horizontal->start());
|
||||
double end = std::min(std::min(cant->end(), gradient->end()), horizontal->end());
|
||||
double length = end - start;
|
||||
|
||||
if (!(0 < length)) {
|
||||
Logger::Error("IfcSegmentedReferenceCurve does not have a common domain with BaseCurve");
|
||||
}
|
||||
|
||||
// define the callback function for the segmented reference curve
|
||||
auto composition = [gradient, cant](double u)->Eigen::Matrix4d {
|
||||
auto g = gradient->evaluate(u);
|
||||
// u is distance from start of cant curve
|
||||
// add cant->start() to u to get the distance from start of gradient curve
|
||||
auto g = gradient->evaluate(u+cant->start());
|
||||
auto c = cant->evaluate(u);
|
||||
|
||||
c.col(3)(0) = 0.0; // x is distance along. zero it out so it doesn't add to the x from gradient curve
|
||||
@@ -62,11 +83,9 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* ins
|
||||
return m;
|
||||
};
|
||||
|
||||
double min_length = std::min(gradient->length(), cant->length());
|
||||
|
||||
taxonomy::piecewise_function::spans spans;
|
||||
spans.emplace_back(min_length, composition);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(spans, &settings_, inst);
|
||||
spans.emplace_back(length, composition);
|
||||
auto pwf = taxonomy::make<taxonomy::piecewise_function>(start, spans, &settings_, inst);
|
||||
return pwf;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user