Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IfcGradient #550

Draft
wants to merge 15 commits into
base: tunnel
Choose a base branch
from
Draft
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
</DocWhereRule>
</WhereRules>
</DocEntity>

Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
</DocWhereRule>
</WhereRules>
</DocEntity>

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<DocFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="IfcFactorial" UniqueId="4a06ac8f-08a8-4f36-a6bc-a14d9330560f" />

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Factorial implementation "x!".
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(IfcInteger Factor) : IfcInteger;
SergejMuhic marked this conversation as resolved.
Show resolved Hide resolved

LOCAL
Fac : IfcInteger := 1;
END_LOCAL;

IF Factor = 0 THEN
RETURN 1;
END_IF;

REPEAT i := 1 TO Factor
Fac = Fac * i;
END_REPEAT;

RETURN Fac;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation document is missing. Proposal for a first draft:

The IfcGradient function derives the height of any position (Position) along a IfcGradientCurve (GradientCurve). It iterates the gradient segments (GradientCurve.Segments) and retrieves the height from the segment's start height, segment's placement, and segment's ParentCurve instance and type.

Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
(GradientCurve : IfcGradientCurve) : IfcLengthMeasure;
RETURN(1);
(GradientCurve : IfcGradientCurve, Position : IfcCurveMeasureSelect) : IfcLengthMeasure;

REPEAT i := 1 TO SIZEOF(GradientCurve.Segments);//GradientCurve.BaseCurve\IfcCompositeCurve.Segments;
Segment : IfcCurveSegment := GradientCurve.Segments[i];
NextSegment : IfcCurveSegment := GradientCurve.Segments[i + 1];
SergejMuhic marked this conversation as resolved.
Show resolved Hide resolved
Location : IfcCartesianPoint := NextSegment\IfcCurveSegment.Placement\IfcAxis2Placement2D.Location\IfcCartesianPoint;
SergejMuhic marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Propose to call it NextLocation to clearly encode that it is the location of the next segment.

SegmentPlacement : IfcAxis2Placement2D := Segment.Placement\IfcAxis2Placement2D;

IF (Location[1] > Position)
SergejMuhic marked this conversation as resolved.
Show resolved Hide resolved
CASE TRUE OF

'IFCCIRCLE' IN TYPEOF(Segment.BaseCurve) :
BEGIN
RETURN SegmentPlacement.Location\IfcCartesianPoint[2] + Segment.BaseCurve.Radius * (COS(ACOS(SegmentPlacement.RefDirection[1]) / 2 - Segment.SegmentLength) - (Position - SegmentPlacement.Location\IfcCartesianPoint[1]));
SergejMuhic marked this conversation as resolved.
Show resolved Hide resolved
END;

'IFCCLOTHOID' IN TYPEOF(Segment.BaseCurve) :
BEGIN
RETURN SegmentPlacement.Location\IfcCartesianPoint[2] + 1/3 * Segment.SegmentLength ** 3 + 1/(3 * IfcFactorial(7)) * Segment.SegmentLength ** 7 + 1/(5 * IfcFactorial(11)) * Segment.SegmentLength ** 11;
END;

'IFCLINE' IN TYPEOF(Segment.BaseCurve) :
BEGIN
RETURN SegmentPlacement.Location\IfcCartesianPoint[2] + Segment.BaseCurve\IfcLine.Pnt[2] + Segment.BaseCurve\IfcLine.Dir.Orientation[2] * Segment.BaseCurve\IfcLine.Dir.Magnitude * Segment.SegmentLength;
SergejMuhic marked this conversation as resolved.
Show resolved Hide resolved
END;

'IFCPOLYLINE' IN TYPEOF(Segment.BaseCurve) :
BEGIN
RETURN SegmentPlacement.Location\IfcCartesianPoint[2] + (Segment.BaseCurve.Points[2].Coordinates[2] - Segment.BaseCurve.Points[1].Coordinates[2]) * Segment.SegmentLength;
SergejMuhic marked this conversation as resolved.
Show resolved Hide resolved
END;

OTHERWISE : RETURN(?);
END_CASE;
END_IF;
END_REPEAT;
RETURN(?);