From b50f4a22402b6deb08473d066c7e59f2c021dc83 Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Wed, 1 Nov 2023 08:35:29 -0700 Subject: [PATCH] Adds a virtual init_adjustments function to precompute common values for segment geometry adjustments --- src/ifcgeom/mapping/IfcCurveSegment.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index e52fd26cab..cec4f36beb 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -102,6 +102,7 @@ class segment_geometry_adjuster { // and provided to the curve_segment_adjustor through this method void set_segment_end_point(const Eigen::Matrix4d& end_of_inst) { end_of_inst_ = end_of_inst; + init_adjustments(); } // Transforms the ParentCurve geometry with the IfcCurveSegment.Placement and @@ -116,6 +117,10 @@ class segment_geometry_adjuster { } protected: + // precompute any values that are constant when applying geometry adjustments + //( subclasses to override. + virtual void init_adjustments() { /*do nothing*/ + } // Applies geometric adjustment to the segment curve point evaluated at u // This default implementation does nothing virtual void apply_adjustments(double u, Eigen::Matrix4d& p) const { /* do nothing - override in subclass if needed */ } @@ -141,6 +146,13 @@ class linear_segment_geometry_adjuster : public segment_geometry_adjuster { public: using segment_geometry_adjuster::segment_geometry_adjuster; + protected: + virtual void init_adjustments() override { + // @todo: rb - implement to improve efficiency + // cache delta = (start_next - end_this)/length + // adjustment is then adj = u*delta + } + virtual void apply_adjustments(double u, Eigen::Matrix4d& p) const override { // make the adjustments based on the transition code // all segments must connect end to end except for last segment IfcTransitionCode_DISCONTINUOUS for open curve @@ -173,6 +185,7 @@ class linear_segment_geometry_adjuster : public segment_geometry_adjuster { auto dy = compute_adjustment(u,dye,dys,length); p.col(i)(0) += dx; p.col(i)(1) += dy; + p.col(i).normalize(); } } }