mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 20:22:09 +00:00
Fixes problems mapping vertical alignment segments business logic to geometry
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
// @todo use std::numbers::pi when upgrading to C++ 20
|
// @todo use std::numbers::pi when upgrading to C++ 20
|
||||||
static const double PI = boost::math::constants::pi<double>();
|
static const double PI = boost::math::constants::pi<double>();
|
||||||
|
|
||||||
|
#include <boost/math/quadrature/trapezoidal.hpp>
|
||||||
|
|
||||||
#ifdef HAS_SCHEMA_4x3_add2
|
#ifdef HAS_SCHEMA_4x3_add2
|
||||||
|
|
||||||
@@ -243,14 +244,14 @@ std::tuple<typename aggregate_of<Ifc4x3_add2::IfcObjectDefinition>::ptr, typenam
|
|||||||
// back gradient
|
// back gradient
|
||||||
auto dxBG = xPVI - xPBG;
|
auto dxBG = xPVI - xPBG;
|
||||||
auto dyBG = yPVI - yPBG;
|
auto dyBG = yPVI - yPBG;
|
||||||
auto start_slope = atan2(dyBG, dxBG);
|
auto start_slope = tan(atan2(dyBG,dxBG));
|
||||||
|
|
||||||
// forward gradient
|
// forward gradient
|
||||||
point_iter++;
|
point_iter++;
|
||||||
std::tie(xPFG, yPFG) = *point_iter;
|
std::tie(xPFG, yPFG) = *point_iter;
|
||||||
auto dxFG = xPFG - xPVI;
|
auto dxFG = xPFG - xPVI;
|
||||||
auto dyFG = yPFG - yPVI;
|
auto dyFG = yPFG - yPVI;
|
||||||
auto end_slope = atan2(dyFG, dxFG);
|
auto end_slope = tan(atan2(dyFG,dxFG));
|
||||||
|
|
||||||
double xEVC = xPVI + length / 2;
|
double xEVC = xPVI + length / 2;
|
||||||
double yEVC = yPVI + end_slope * length / 2;
|
double yEVC = yPVI + end_slope * length / 2;
|
||||||
@@ -292,8 +293,9 @@ std::tuple<typename aggregate_of<Ifc4x3_add2::IfcObjectDefinition>::ptr, typenam
|
|||||||
// create last tangent run
|
// create last tangent run
|
||||||
auto dx = xPVI - xPBG;
|
auto dx = xPVI - xPBG;
|
||||||
auto dy = yPVI - yPBG;
|
auto dy = yPVI - yPBG;
|
||||||
auto slope = atan2(dy, dx);
|
auto slope = tan(atan2(dy,dx));
|
||||||
auto gradient_length = sqrt(dx * dx + dy * dy);
|
auto gradient_length = dx;
|
||||||
|
|
||||||
file.addDoublet<Ifc4x3_add2::IfcCartesianPoint>(xPBG, yPBG);
|
file.addDoublet<Ifc4x3_add2::IfcCartesianPoint>(xPBG, yPBG);
|
||||||
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 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);
|
auto alignment_segment = new Ifc4x3_add2::IfcAlignmentSegment(IfcParse::IfcGlobalId(), nullptr, boost::none, boost::none, boost::none, nullptr, nullptr, design_parameters);
|
||||||
@@ -688,13 +690,18 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
|||||||
new Ifc4x3_add2::IfcCartesianPoint(std::vector<double>({0, 0})),
|
new Ifc4x3_add2::IfcCartesianPoint(std::vector<double>({0, 0})),
|
||||||
new Ifc4x3_add2::IfcVector(new Ifc4x3_add2::IfcDirection(std::vector<double>{1, 0}), 1.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(
|
auto curve_segment = new Ifc4x3_add2::IfcCurveSegment(
|
||||||
Ifc4x3_add2::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT,
|
Ifc4x3_add2::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT,
|
||||||
new Ifc4x3_add2::IfcAxis2Placement2D(
|
new Ifc4x3_add2::IfcAxis2Placement2D(
|
||||||
new Ifc4x3_add2::IfcCartesianPoint({start_distance_along, start_height}),
|
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(0.0), // start
|
||||||
new Ifc4x3_add2::IfcLengthMeasure(horizontal_length),
|
new Ifc4x3_add2::IfcLengthMeasure(segment_curve_length),
|
||||||
parent_curve);
|
parent_curve);
|
||||||
|
|
||||||
result.first = curve_segment;
|
result.first = curve_segment;
|
||||||
@@ -710,11 +717,22 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
|||||||
std::vector<double>{A, B, C},
|
std::vector<double>{A, B, C},
|
||||||
boost::none);
|
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 + 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(
|
auto curve_segment = new Ifc4x3_add2::IfcCurveSegment(
|
||||||
Ifc4x3_add2::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT,
|
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(0.0),
|
||||||
new Ifc4x3_add2::IfcLengthMeasure(horizontal_length),
|
new Ifc4x3_add2::IfcLengthMeasure(segment_curve_length),
|
||||||
parent_curve);
|
parent_curve);
|
||||||
|
|
||||||
result.first = curve_segment;
|
result.first = curve_segment;
|
||||||
@@ -735,11 +753,14 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
|||||||
new Ifc4x3_add2::IfcDirection(std::vector<double>{1, 0})),
|
new Ifc4x3_add2::IfcDirection(std::vector<double>{1, 0})),
|
||||||
radius);
|
radius);
|
||||||
|
|
||||||
|
|
||||||
|
auto segment_curve_length = radius * fabs(end_angle - start_angle);
|
||||||
|
|
||||||
Ifc4x3_add2::IfcCurveSegment* curve_segment = new Ifc4x3_add2::IfcCurveSegment(
|
Ifc4x3_add2::IfcCurveSegment* curve_segment = new Ifc4x3_add2::IfcCurveSegment(
|
||||||
Ifc4x3_add2::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT,
|
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::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(0.0),
|
||||||
new Ifc4x3_add2::IfcLengthMeasure(horizontal_length),
|
new Ifc4x3_add2::IfcLengthMeasure(segment_curve_length),
|
||||||
parent_curve);
|
parent_curve);
|
||||||
|
|
||||||
result.first = curve_segment;
|
result.first = curve_segment;
|
||||||
|
|||||||
Reference in New Issue
Block a user