diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index bfe8a191ca..1ca2e1b56f 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -448,14 +448,17 @@ class curve_segment_evaluator { // defines the parent_curve_fn_ functor for cant segments. void set_cant_spiral_function(std::function Superelevation, std::function SuperelevationSlope, std::function Cant) { - auto dy = (*curve_segment_placement_)(1, 2); // placement dy - auto dz = (*curve_segment_placement_)(2, 2); // placement dz + // compute start cross slope angle, measured relative to (0,0,1) + auto dy = (*curve_segment_placement_)(1, 2); // Axis.dy + auto dz = (*curve_segment_placement_)(2, 2); // Axis.dz auto start_angle = atan2(dz, dy); + // compute end cross slope angle, measured relative to (0,0,1) dy = (next_segment_placement_.has_value() ? (*next_segment_placement_)(1, 2) : 0.0); dz = (next_segment_placement_.has_value() ? (*next_segment_placement_)(2, 2) : 1.0); auto end_angle = atan2(dz, dy); + // angular change of railhead cross slope over the length of the segment auto delta_angle = end_angle - start_angle; auto start_cant = Cant(0.0 /*start_*/); auto end_cant = Cant(/* start_ + */ length_); @@ -529,7 +532,7 @@ class curve_segment_evaluator { if (segment_type_ == ST_CANT) { boost::optional> super, slope; std::tie(super, slope) = get_superelevation_functions(); - auto cant = [A, L](double t) -> double { return A ? L * A * t / fabs(pow(A, 3)) : 0.0; }; + auto cant = [A, L](double t) -> double { return A ? L * L * A * t / fabs(pow(A, 3)) : 0.0; }; if (!super.has_value()) { super = cant; @@ -579,9 +582,9 @@ class curve_segment_evaluator { std::tie(super, slope) = get_superelevation_functions(); auto cant = [constant_term, cosine_term, L](double t) -> double { - auto a0 = constant_term.has_value() ? L / constant_term.value() : 0.0; - auto a1 = (L / cosine_term) * cos(PI * t / L); - return a0 + a1; + auto a0 = constant_term.has_value() ? 1 / constant_term.value() : 0.0; + auto a1 = (1 / cosine_term) * cos(PI * t / L); + return L*L*(a0 + a1); }; if (!super.has_value()) { @@ -627,7 +630,7 @@ class curve_segment_evaluator { if (segment_type_ == ST_HORIZONTAL) { auto theta = [constant_term, linear_term, sine_term, L](double t) -> double { auto a0 = constant_term.has_value() ? t / constant_term.value() : 0.0; - auto a1 = linear_term.has_value() ? sign(linear_term.value()) * pow(t / linear_term.value(), 2.0) / 2.0 : 0.0; + auto a1 = linear_term.has_value() ? (linear_term.value() / fabs(linear_term.value())) * pow(t / linear_term.value(), 2.0) / 2.0 : 0.0; auto a2 = -1.0 * (L / (2 * PI * sine_term)) * (cos(2 * PI * t / L) - 1.0); return a0 + a1 + a2; }; @@ -635,7 +638,7 @@ class curve_segment_evaluator { auto fn_y = [theta](double t) -> double { return sin(theta(t)); }; auto curvature = [constant_term, linear_term, sine_term, L](double t) -> double { auto a0 = constant_term.has_value() ? L / constant_term.value() : 0.0; - auto a1 = linear_term.has_value() ? sign(linear_term.value()) * pow(L / linear_term.value(), 2.0)*(t/L) : 0.0; + auto a1 = linear_term.has_value() ? (linear_term.value() / fabs(linear_term.value())) * pow(L / linear_term.value(), 2.0) * (t / L) : 0.0; auto a2 = (L / sine_term) * sin(2 * PI * t / L); return a0 + a1 + a2; }; @@ -646,10 +649,10 @@ class curve_segment_evaluator { std::tie(super, slope) = get_superelevation_functions(); auto cant = [constant_term, linear_term, sine_term, L](double t) -> double { - auto a0 = constant_term.has_value() ? L / constant_term.value() : 0.0; - auto a1 = linear_term.has_value() ? sign(linear_term.value()) * pow(L / linear_term.value(), 2.0) * (t / L) : 0.0; - auto a2 = (L / sine_term) * sin(2 * PI * t / L); - return a0 + a1 + a2; + auto a0 = constant_term.has_value() ? 1 / constant_term.value() : 0.0; + auto a1 = linear_term.has_value() ? (linear_term.value()/fabs(linear_term.value())) * pow(1 / linear_term.value(), 2.0) * t : 0.0; + auto a2 = (1 / sine_term) * sin(2 * PI * t / L); + return L*L*(a0 + a1 + a2); }; if (!super.has_value()) { @@ -681,14 +684,14 @@ class curve_segment_evaluator { void polynomial_spiral(boost::optional A0, boost::optional A1, boost::optional A2, boost::optional A3, boost::optional A4, boost::optional A5, boost::optional A6, boost::optional A7) { auto theta = [A0, A1, A2, A3, A4, A5, A6, A7, start = start_ * length_unit_, lu = length_unit_](double t) -> double { - auto a0 = A0.has_value() ? t / (A0.value() * lu) : 0.0; - auto a1 = A1.has_value() ? A1.value() * lu * std::pow(t, 2) / (2 * fabs(std::pow(A1.value() * lu, 3))) : 0.0; - auto a2 = A2.has_value() ? std::pow(t, 3) / (3 * std::pow(A2.value() * lu, 3)) : 0.0; - auto a3 = A3.has_value() ? A3.value() * lu * std::pow(t, 4) / (4 * fabs(std::pow(A3.value() * lu, 5))) : 0.0; - auto a4 = A4.has_value() ? std::pow(t, 5) / (5 * std::pow(A4.value() * lu, 5)) : 0.0; - auto a5 = A5.has_value() ? A5.value() * lu * std::pow(t, 6) / (6 * fabs(std::pow(A5.value() * lu, 7))) : 0.0; - auto a6 = A6.has_value() ? std::pow(t, 7) / (7 * std::pow(A6.value() * lu, 7)) : 0.0; - auto a7 = A7.has_value() ? A7.value() * lu * std::pow(t, 8) / (8 * fabs(std::pow(A7.value() * lu, 9))) : 0.0; + auto a0 = A0.get_value_or(0.0) != 0.0 ? t / (A0.value() * lu) : 0.0; + auto a1 = A1.get_value_or(0.0) != 0.0 ? A1.value() * lu * std::pow(t, 2) / (2 * fabs(std::pow(A1.value() * lu, 3))) : 0.0; + auto a2 = A2.get_value_or(0.0) != 0.0 ? std::pow(t, 3) / (3 * std::pow(A2.value() * lu, 3)) : 0.0; + auto a3 = A3.get_value_or(0.0) != 0.0 ? A3.value() * lu * std::pow(t, 4) / (4 * fabs(std::pow(A3.value() * lu, 5))) : 0.0; + auto a4 = A4.get_value_or(0.0) != 0.0 ? std::pow(t, 5) / (5 * std::pow(A4.value() * lu, 5)) : 0.0; + auto a5 = A5.get_value_or(0.0) != 0.0 ? A5.value() * lu * std::pow(t, 6) / (6 * fabs(std::pow(A5.value() * lu, 7))) : 0.0; + auto a6 = A6.get_value_or(0.0) != 0.0 ? std::pow(t, 7) / (7 * std::pow(A6.value() * lu, 7)) : 0.0; + auto a7 = A7.get_value_or(0.0) != 0.0 ? A7.value() * lu * std::pow(t, 8) / (8 * fabs(std::pow(A7.value() * lu, 9))) : 0.0; return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7; }; @@ -699,14 +702,14 @@ class curve_segment_evaluator { // this is same as cant function in polynomial_cant_spiral auto curvature = [A0, A1, A2, A3, A4, A5, A6, A7, start = start_, L = length_, lu = length_unit_, length = length_](double t) -> double { t += start; - auto a0 = A0.has_value() ? 1 / (A0.value() * lu) : 0.0; - auto a1 = A1.has_value() ? A1.value() * lu * t / fabs(std::pow(A1.value() * lu, 3)) : 0.0; - auto a2 = A2.has_value() ? std::pow(t, 2) / std::pow(A2.value() * lu, 3) : 0.0; - auto a3 = A3.has_value() ? A3.value() * lu * std::pow(t, 3) / fabs(std::pow(A3.value() * lu, 5)) : 0.0; - auto a4 = A4.has_value() ? std::pow(t, 4) / std::pow(A4.value() * lu, 5) : 0.0; - auto a5 = A5.has_value() ? A5.value() * lu * std::pow(t, 5) / fabs(std::pow(A5.value() * lu, 7)) : 0.0; - auto a6 = A6.has_value() ? std::pow(t, 6) / std::pow(A6.value() * lu, 7) : 0.0; - auto a7 = A7.has_value() ? A7.value() * lu * std::pow(t, 7) / fabs(std::pow(A7.value() * lu, 9)) : 0.0; + auto a0 = A0.get_value_or(0.0) != 0.0 ? 1 / (A0.value() * lu) : 0.0; + auto a1 = A1.get_value_or(0.0) != 0.0 ? A1.value() * lu * t / fabs(std::pow(A1.value() * lu, 3)) : 0.0; + auto a2 = A2.get_value_or(0.0) != 0.0 ? std::pow(t, 2) / std::pow(A2.value() * lu, 3) : 0.0; + auto a3 = A3.get_value_or(0.0) != 0.0 ? A3.value() * lu * std::pow(t, 3) / fabs(std::pow(A3.value() * lu, 5)) : 0.0; + auto a4 = A4.get_value_or(0.0) != 0.0 ? std::pow(t, 4) / std::pow(A4.value() * lu, 5) : 0.0; + auto a5 = A5.get_value_or(0.0) != 0.0 ? A5.value() * lu * std::pow(t, 5) / fabs(std::pow(A5.value() * lu, 7)) : 0.0; + auto a6 = A6.get_value_or(0.0) != 0.0 ? std::pow(t, 6) / std::pow(A6.value() * lu, 7) : 0.0; + auto a7 = A7.get_value_or(0.0) != 0.0 ? A7.value() * lu * std::pow(t, 7) / fabs(std::pow(A7.value() * lu, 9)) : 0.0; return L * (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7); }; @@ -721,15 +724,15 @@ class curve_segment_evaluator { auto cant = [A0, A1, A2, A3, A4, A5, A6, A7, start = start_, L = length_, lu = length_unit_, length = length_](double t) -> double { t += start; - auto a0 = A0.has_value() ? 1 / (A0.value() * lu) : 0.0; - auto a1 = A1.has_value() ? A1.value() * lu * t / fabs(std::pow(A1.value() * lu, 3)) : 0.0; - auto a2 = A2.has_value() ? std::pow(t, 2) / std::pow(A2.value() * lu, 3) : 0.0; - auto a3 = A3.has_value() ? A3.value() * lu * std::pow(t, 3) / fabs(std::pow(A3.value() * lu, 5)) : 0.0; - auto a4 = A4.has_value() ? std::pow(t, 4) / std::pow(A4.value() * lu, 5) : 0.0; - auto a5 = A5.has_value() ? A5.value() * lu * std::pow(t, 5) / fabs(std::pow(A5.value() * lu, 7)) : 0.0; - auto a6 = A6.has_value() ? std::pow(t, 6) / std::pow(A6.value() * lu, 7) : 0.0; - auto a7 = A7.has_value() ? A7.value() * lu * std::pow(t, 7) / fabs(std::pow(A7.value() * lu, 9)) : 0.0; - return L * (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7); + auto a0 = A0.get_value_or(0.0) != 0.0 ? 1 / (A0.value() * lu) : 0.0; + auto a1 = A1.get_value_or(0.0) != 0.0 ? A1.value() * lu * t / fabs(std::pow(A1.value() * lu, 3)) : 0.0; + auto a2 = A2.get_value_or(0.0) != 0.0 ? std::pow(t, 2) / std::pow(A2.value() * lu, 3) : 0.0; + auto a3 = A3.get_value_or(0.0) != 0.0 ? A3.value() * lu * std::pow(t, 3) / fabs(std::pow(A3.value() * lu, 5)) : 0.0; + auto a4 = A4.get_value_or(0.0) != 0.0 ? std::pow(t, 4) / std::pow(A4.value() * lu, 5) : 0.0; + auto a5 = A5.get_value_or(0.0) != 0.0 ? A5.value() * lu * std::pow(t, 5) / fabs(std::pow(A5.value() * lu, 7)) : 0.0; + auto a6 = A6.get_value_or(0.0) != 0.0 ? std::pow(t, 6) / std::pow(A6.value() * lu, 7) : 0.0; + auto a7 = A7.get_value_or(0.0) != 0.0 ? A7.value() * lu * std::pow(t, 7) / fabs(std::pow(A7.value() * lu, 9)) : 0.0; + return L * L * (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7); }; if (!super.has_value()) { @@ -739,14 +742,14 @@ class curve_segment_evaluator { if (!slope.has_value()) { slope = [A1, A2, A3, A4, A5, A6, A7, start = start_, L = length_, lu = length_unit_, length = length_](double t) -> double { t += start; - auto a1 = A1.has_value() ? A1.value() * lu / fabs(std::pow(A1.value() * lu, 3)) : 0.0; - auto a2 = A2.has_value() ? 2 * t / std::pow(A2.value() * lu, 3) : 0.0; - auto a3 = A3.has_value() ? 3 * A3.value() * lu * std::pow(t, 2) / fabs(std::pow(A3.value() * lu, 5)) : 0.0; - auto a4 = A4.has_value() ? 4 * std::pow(t, 3) / std::pow(A4.value() * lu, 5) : 0.0; - auto a5 = A5.has_value() ? 5 * A5.value() * lu * std::pow(t, 4) / fabs(std::pow(A5.value() * lu, 7)) : 0.0; - auto a6 = A6.has_value() ? 6 * std::pow(t, 5) / std::pow(A6.value() * lu, 7) : 0.0; - auto a7 = A7.has_value() ? 7 * A7.value() * lu * std::pow(t, 6) / fabs(std::pow(A7.value() * lu, 9)) : 0.0; - return L * (a1 + a2 + a3 + a4 + a5 + a6 + a7); + auto a1 = A1.get_value_or(0.0) != 0.0 ? A1.value() * lu / fabs(std::pow(A1.value() * lu, 3)) : 0.0; + auto a2 = A2.get_value_or(0.0) != 0.0 ? 2 * t / std::pow(A2.value() * lu, 3) : 0.0; + auto a3 = A3.get_value_or(0.0) != 0.0 ? 3 * A3.value() * lu * std::pow(t, 2) / fabs(std::pow(A3.value() * lu, 5)) : 0.0; + auto a4 = A4.get_value_or(0.0) != 0.0 ? 4 * std::pow(t, 3) / std::pow(A4.value() * lu, 5) : 0.0; + auto a5 = A5.get_value_or(0.0) != 0.0 ? 5 * A5.value() * lu * std::pow(t, 4) / fabs(std::pow(A5.value() * lu, 7)) : 0.0; + auto a6 = A6.get_value_or(0.0) != 0.0 ? 6 * std::pow(t, 5) / std::pow(A6.value() * lu, 7) : 0.0; + auto a7 = A7.get_value_or(0.0) != 0.0 ? 7 * A7.value() * lu * std::pow(t, 6) / fabs(std::pow(A7.value() * lu, 9)) : 0.0; + return L * L * (a1 + a2 + a3 + a4 + a5 + a6 + a7); }; } diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/__init__.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/__init__.py index bb127bc568..ee3e6a451d 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/__init__.py @@ -60,7 +60,6 @@ from .get_curve import get_curve from .get_parent_alignment import get_parent_alignment from .has_zero_length_segment import has_zero_length_segment from .map_alignment_segments import map_alignment_segments -from .map_alignment_segment import map_alignment_segment from .map_alignment_horizontal_segment import map_alignment_horizontal_segment from .map_alignment_vertical_segment import map_alignment_vertical_segment from .map_alignment_cant_segment import map_alignment_cant_segment @@ -91,7 +90,6 @@ __all__ = [ "get_parent_alignment", "has_zero_length_segment", "map_alignment_segments", - "map_alignment_segment", "map_alignment_horizontal_segment", "map_alignment_vertical_segment", "map_alignment_cant_segment", diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py index a161757213..968b681ede 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py @@ -45,6 +45,9 @@ def add_zero_length_segment(file: ifcopenshell.file, entity: entity_instance) -> f"Expected entity type to be one of {[_ for _ in expected_types]}, instead received '{entity.is_a()}" ) + if ifcopenshell.api.alignment.has_zero_length_segment(entity): + return # do nothing if the entity already has a zero length segment + if entity.is_a("IfcCompositeCurve"): last_segment = entity.Segments[-1] settings = ifcopenshell.geom.settings() @@ -67,7 +70,7 @@ def add_zero_length_segment(file: ifcopenshell.file, entity: entity_instance) -> curve_segment = file.createIfcCurveSegment( Transition="DISCONTINUOUS", Placement=file.createIfcAxis2Placement2D( - Location=file.createIfcCartesianPoint(Coordinates=((x, y))), + Location=file.createIfcCartesianPoint(((x, y))), RefDirection=file.createIfcDirection((dx, dy)), ), SegmentStart=file.createIfcLengthMeasure(0.0), @@ -80,22 +83,72 @@ def add_zero_length_segment(file: ifcopenshell.file, entity: entity_instance) -> if 0 < len(rel.RelatedObjects): last_segment = rel.RelatedObjects[-1] if last_segment.is_a("IfcAlignmentSegment"): - design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint( - (0.0, 0.0) - ), # this is a little problematic. need to know the end point and tangent - StartDirection=0.0, # of the previous segment, which requires geometry mapping - SegmentLength=0.0, - PredefinedType="LINE", - ) - segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters - ) - ifcopenshell.api.nest.assign_object( - file, - related_objects=[ - segment, - ], - relating_object=entity, - ) - break + if entity.is_a("IfcAlignmentHorizontal"): + design_parameters = file.createIfcAlignmentHorizontalSegment( + StartPoint=file.createIfcCartesianPoint( + (0.0, 0.0) + ), # this is a little problematic. need to know the end point and tangent + StartDirection=0.0, # of the previous segment, which requires geometry mapping + SegmentLength=0.0, + PredefinedType="LINE", + ) + segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + ifcopenshell.api.nest.assign_object( + file, + related_objects=[ + segment, + ], + relating_object=entity, + ) + break + elif entity.is_a("IfcAlignmentVertical"): + design_parameters = file.createIfcAlignmentVerticalSegment( + StartDistAlong=last_segment.DesignParameters.StartDistAlong + + last_segment.DesignParameters.HorizontalLength, + HorizontalLength=0.0, + StartHeight=0.0, + StartGradient=last_segment.DesignParameters.EndGradient, + EndGradient=last_segment.DesignParameters.EndGradient, + PredefinedType="CONSTANTGRADIENT", + ) + segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + ifcopenshell.api.nest.assign_object( + file, + related_objects=[ + segment, + ], + relating_object=entity, + ) + break + elif entity.is_a("IfcAlignmentCant"): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=last_segment.DesignParameters.StartDistAlong + + last_segment.DesignParameters.HorizontalLength, + HorizontalLength=0.0, + StartCantLeft=( + last_segment.DesignParameters.EndCantLeft + if last_segment.DesignParameters.EndCantLeft != None + else last_segment.DesignParameters.StartCantLeft + ), + StartCantRight=( + last_segment.DesignParameters.EndCantRight + if last_segment.DesignParameters.EndCantRight != None + else last_segment.DesignParameters.StartCantRight + ), + PredefinedType="CONSTANTCANT", + ) + segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + ifcopenshell.api.nest.assign_object( + file, + related_objects=[ + segment, + ], + relating_object=entity, + ) + break diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/create_geometric_representation.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/create_geometric_representation.py index c15fac39a4..8f38d7b2b0 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/create_geometric_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/create_geometric_representation.py @@ -60,6 +60,7 @@ def create_geometric_representation(file: ifcopenshell.file, alignment: entity_i if len(layouts) == 1 and len(children) == 0: assert layouts[0].is_a("IfcAlignmentHorizontal") # Horizontal only - IFC CT 4.1.7.1.1.1 + ifcopenshell.api.alignment.add_zero_length_segment(file, layouts[0]) composite_curve = file.createIfcCompositeCurve() ifcopenshell.api.alignment.map_alignment_segments(file, layouts[0], composite_curve) representation = file.create_entity( @@ -74,6 +75,8 @@ def create_geometric_representation(file: ifcopenshell.file, alignment: entity_i # Horizontal and Vertical - IFC CT 4.1.7.1.1.1 assert layouts[0].is_a("IfcAlignmentHorizontal") assert layouts[1].is_a("IfcAlignmentVertical") + ifcopenshell.api.alignment.add_zero_length_segment(file, layouts[0]) + ifcopenshell.api.alignment.add_zero_length_segment(file, layouts[1]) composite_curve = file.createIfcCompositeCurve() ifcopenshell.api.alignment.map_alignment_segments(file, layouts[0], composite_curve) representation = file.create_entity( @@ -100,6 +103,9 @@ def create_geometric_representation(file: ifcopenshell.file, alignment: entity_i assert layouts[0].is_a("IfcAlignmentHorizontal") assert layouts[1].is_a("IfcAlignmentVertical") assert layouts[2].is_a("IfcAlignmentCant") + ifcopenshell.api.alignment.add_zero_length_segment(file, layouts[0]) + ifcopenshell.api.alignment.add_zero_length_segment(file, layouts[1]) + ifcopenshell.api.alignment.add_zero_length_segment(file, layouts[2]) composite_curve = file.createIfcCompositeCurve() ifcopenshell.api.alignment.map_alignment_segments(file, layouts[0], composite_curve) representation = file.create_entity( @@ -126,6 +132,7 @@ def create_geometric_representation(file: ifcopenshell.file, alignment: entity_i else: # Reusing Horizontal - CT 4.1.4.4.1.2 # Create a representation on the parent alignment + ifcopenshell.api.alignment.add_zero_length_segment(file, layouts[0]) composite_curve = file.createIfcCompositeCurve() ifcopenshell.api.alignment.map_alignment_segments(file, layouts[0], composite_curve) representation = file.create_entity( @@ -142,6 +149,7 @@ def create_geometric_representation(file: ifcopenshell.file, alignment: entity_i child_layouts = ifcopenshell.api.alignment.get_alignment_layouts(child_alignment) if len(child_layouts) == 1: assert child_layouts[0].is_a("IfcAlignmentVertical") + ifcopenshell.api.alignment.add_zero_length_segment(file, child_layouts[0]) base_curve = ifcopenshell.api.alignment.get_basis_curve(alignment) gradient_curve = file.createIfcGradientCurve(BaseCurve=base_curve) ifcopenshell.api.alignment.map_alignment_segments(file, child_layouts[0], gradient_curve) @@ -156,6 +164,8 @@ def create_geometric_representation(file: ifcopenshell.file, alignment: entity_i elif len(child_layouts) == 2: assert child_layouts[0].is_a("IfcAlignmentVertical") assert child_layouts[1].is_a("IfcAlignmentCant") + ifcopenshell.api.alignment.add_zero_length_segment(file, child_layouts[0]) + ifcopenshell.api.alignment.add_zero_length_segment(file, child_layouts[1]) base_curve = ifcopenshell.api.alignment.get_basis_curve(alignment) gradient_curve = file.createIfcGradientCurve(BaseCurve=base_curve) ifcopenshell.api.alignment.map_alignment_segments(file, child_layouts[0], gradient_curve) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_cant_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_cant_segment.py index b911fc6b45..cd87c30c69 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_cant_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_cant_segment.py @@ -20,38 +20,367 @@ import ifcopenshell from ifcopenshell import entity_instance from ifcopenshell.api.alignment import get_axis_subcontext from typing import Sequence +import math + +def _get_axis(file: ifcopenshell.file, Ds: float, rail_head_distance: float) -> entity_instance: + Dy = rail_head_distance + Dz = 2 * Ds + D = math.sqrt(Dy * Dy + Dz * Dz) + return file.createIfcDirection((0.0, Dz / D, Dy / D)) -def _map_constant_cant(file: ifcopenshell.file, design_parameters: entity_instance) -> Sequence[entity_instance]: - raise NotImplementedError("CONSTANTCANT not implemented") +def _map_constant_cant( + file: ifcopenshell.file, design_parameters: entity_instance, rail_head_distance: float +) -> Sequence[entity_instance]: + dist_along = design_parameters.StartDistAlong + length = design_parameters.HorizontalLength + Dsl = design_parameters.StartCantLeft + Dsr = design_parameters.StartCantRight + + Ds = 0.5 * (Dsl + Dsr) + + transition = "DISCONTINUOUS" + + parent_curve = file.createIfcLine( + Pnt=file.createIfcCartesianPoint((0.0, 0.0)), + Dir=file.createIfcVector(Orientation=file.createIfcDirection((1.0, 0.0)), Magnitude=1.0), + ) + + start_point = file.createIfcCartesianPoint((dist_along, Ds, 0.0)) + start_direction = 0.0 + + curve_segment = file.createIfcCurveSegment( + Transition=transition, + Placement=file.createIfcAxis2Placement3D( + Location=start_point, + Axis=_get_axis(file, Ds, rail_head_distance), + RefDirection=file.createIfcDirection((math.cos(start_direction), math.sin(start_direction), 0.0)), + ), + SegmentStart=file.createIfcLengthMeasure(0.0), + SegmentLength=file.createIfcLengthMeasure(length), + ParentCurve=parent_curve, + ) + return (curve_segment, None) -def _map_linear_transition(file: ifcopenshell.file, design_parameters: entity_instance) -> Sequence[entity_instance]: - raise NotImplementedError("LINEARTRANSTION not implemented") +def _map_linear_transition( + file: ifcopenshell.file, design_parameters: entity_instance, rail_head_distance: float +) -> Sequence[entity_instance]: + dist_along = design_parameters.StartDistAlong + length = design_parameters.HorizontalLength + Dsl = design_parameters.StartCantLeft + Del = design_parameters.EndCantLeft + Dsr = design_parameters.StartCantRight + Der = design_parameters.EndCantRight + + Ds = 0.5 * (Dsl + Dsr) + De = 0.5 * (Del + Der) + f = De - Ds + + a0 = Ds # constant term + a1 = f # linear term + + transition = "DISCONTINUOUS" + + A0 = math.pow(length, 2.0 / 1.0) * math.pow(math.fabs(a0), -1.0 / 1.0) * (a0 / math.fabs(a0)) if a0 != 0.0 else 0.0 + A1 = math.pow(length, 3.0 / 2.0) * math.pow(math.fabs(a1), -1.0 / 2.0) * (a1 / math.fabs(a1)) if a1 != 0.0 else 0.0 + + parent_curve_location = file.createIfcCartesianPoint((0.0, 0.0)) + parent_curve = file.createIfcClothoid( + Position=file.createIfcAxis2Placement2D( + Location=parent_curve_location, RefDirection=file.createIfcDirection((1.0, 0.0)) + ), + ClothoidConstant=A1, + ) + + start_point = file.createIfcCartesianPoint( + (dist_along, math.pow(length, 2.0 / 1.0) / A0 if A0 != 0.0 else 0.0, 0.0) + ) + start_direction = math.atan(A1 * math.pow(length, 2.0 / 1.0) / math.fabs(math.pow(A1, 3.0 / 1.0))) + + curve_segment = file.createIfcCurveSegment( + Transition=transition, + Placement=file.createIfcAxis2Placement3D( + Location=start_point, + Axis=_get_axis(file, Ds, rail_head_distance), + RefDirection=file.createIfcDirection((math.cos(start_direction), math.sin(start_direction), 0.0)), + ), + SegmentStart=file.createIfcLengthMeasure(0.0), + SegmentLength=file.createIfcLengthMeasure(length), + ParentCurve=parent_curve, + ) + return (curve_segment, None) -def _map_helmert_curve(file: ifcopenshell.file, design_parameters: entity_instance) -> Sequence[entity_instance]: - raise NotImplementedError("HELMERTCURVE not implemented") +def _map_helmert_curve( + file: ifcopenshell.file, design_parameters: entity_instance, rail_head_distance: float +) -> Sequence[entity_instance]: + dist_along = design_parameters.StartDistAlong + length = design_parameters.HorizontalLength + Dsl = design_parameters.StartCantLeft + Del = design_parameters.EndCantLeft + Dsr = design_parameters.StartCantRight + Der = design_parameters.EndCantRight + + Ds = Dsl + Dsr + De = Del + Der + f = De - Ds + + transition = "DISCONTINUOUS" + + # First half + a0_1 = 2.0 * Ds # constant term + a1_1 = 0.0 # linear term + a2_1 = 4.0 * f # quadratic term + + A0_1 = ( + math.pow(length, 2.0 / 1.0) * math.pow(math.fabs(a0_1), -1.0 / 1.0) * (a0_1 / math.fabs(a0_1)) + if a0_1 != 0.0 + else 0.0 + ) + A1_1 = ( + math.pow(length, 3.0 / 2.0) * math.pow(math.fabs(a1_1), -1.0 / 2.0) * (a1_1 / math.fabs(a1_1)) + if a1_1 != 0.0 + else 0.0 + ) + A2_1 = ( + math.pow(length, 4.0 / 3.0) * math.pow(math.fabs(a2_1), -1.0 / 3.0) * (a2_1 / math.fabs(a2_1)) + if a2_1 != 0.0 + else 0.0 + ) + + parent_curve_1 = file.createIfcSecondOrderPolynomialSpiral( + Position=file.createIfcAxis2Placement2D( + Location=file.createIfcCartesianPoint((0.0, 0.0)), RefDirection=file.createIfcDirection((1.0, 0.0)) + ), + QuadraticTerm=A2_1, + LinearTerm=A1_1 if A1_1 != 0.0 else None, + ConstantTerm=A0_1 if A0_1 != 0.0 else None, + ) + + start_point_1 = file.createIfcCartesianPoint((dist_along, Ds / 2.0, 0.0)) + start_direction_1 = 0.0 + + curve_segment_1 = file.createIfcCurveSegment( + Transition=transition, + Placement=file.createIfcAxis2Placement3D( + Location=start_point_1, + Axis=_get_axis(file, Ds / 2.0, rail_head_distance), + RefDirection=file.createIfcDirection((math.cos(start_direction_1), math.sin(start_direction_1), 0.0)), + ), + SegmentStart=file.createIfcLengthMeasure(0.0), + SegmentLength=file.createIfcLengthMeasure(length / 2.0), + ParentCurve=parent_curve_1, + ) + + # Second half + + a0_2 = -2.0 * f + 2.0 * Ds # constant term + a1_2 = 8.0 * f # linear term + a2_2 = -4.0 * f # quadratic term + + A0_2 = ( + math.pow(length, 2.0 / 1.0) * math.pow(math.fabs(a0_2), -1.0 / 1.0) * (a0_2 / math.fabs(a0_2)) + if a0_2 != 0.0 + else 0.0 + ) + A1_2 = ( + math.pow(length, 3.0 / 2.0) * math.pow(math.fabs(a1_2), -1.0 / 2.0) * (a1_2 / math.fabs(a1_2)) + if a1_2 != 0.0 + else 0.0 + ) + A2_2 = ( + math.pow(length, 4.0 / 3.0) * math.pow(math.fabs(a2_2), -1.0 / 3.0) * (a2_2 / math.fabs(a2_2)) + if a2_2 != 0.0 + else 0.0 + ) + + parent_curve_2 = file.createIfcSecondOrderPolynomialSpiral( + Position=file.createIfcAxis2Placement2D( + Location=file.createIfcCartesianPoint((0.0, 0.0)), RefDirection=file.createIfcDirection((1.0, 0.0)) + ), + QuadraticTerm=A2_2, + LinearTerm=A1_2 if A1_2 != 0.0 else None, + ConstantTerm=A0_2 if A0_2 != 0.0 else None, + ) + + start_point_2 = file.createIfcCartesianPoint((dist_along + length / 2.0, Ds / 2.0 + f / 4.0, 0.0)) + slope = math.pow(length / 2.0, 2.0) * (2.0 * (length / 2.0) / pow(A2_1, 3.0)) + start_direction_2 = math.atan(slope) + + curve_segment_2 = file.createIfcCurveSegment( + Transition=transition, + Placement=file.createIfcAxis2Placement3D( + Location=start_point_2, + Axis=_get_axis(file, (Ds + De) / 4.0, rail_head_distance), + RefDirection=file.createIfcDirection((math.cos(start_direction_2), math.sin(start_direction_2), 0.0)), + ), + SegmentStart=file.createIfcLengthMeasure(length / 2.0), + SegmentLength=file.createIfcLengthMeasure(length / 2.0), + ParentCurve=parent_curve_2, + ) + + return (curve_segment_1, curve_segment_2) -def _map_bloss_curve(file: ifcopenshell.file, design_parameters: entity_instance) -> Sequence[entity_instance]: - raise NotImplementedError("BLOSSCURVE not implemented") +def _map_bloss_curve( + file: ifcopenshell.file, design_parameters: entity_instance, rail_head_distance: float +) -> Sequence[entity_instance]: + dist_along = design_parameters.StartDistAlong + length = design_parameters.HorizontalLength + Dsl = design_parameters.StartCantLeft + Del = design_parameters.EndCantLeft + Dsr = design_parameters.StartCantRight + Der = design_parameters.EndCantRight + + Ds = 0.5 * (Dsl + Dsr) + De = 0.5 * (Del + Der) + f = De - Ds + + a0 = Ds # constant term + a1 = 0.0 # linear term + a2 = 3.0 * f # quadratic term + a3 = -2.0 * f # cubic term + + transition = "DISCONTINUOUS" + + A0 = math.pow(length, 2.0 / 1.0) * math.pow(math.fabs(a0), -1.0 / 1.0) * (a0 / math.fabs(a0)) if a0 != 0.0 else 0.0 + A1 = math.pow(length, 3.0 / 2.0) * math.pow(math.fabs(a1), -1.0 / 2.0) * (a1 / math.fabs(a1)) if a1 != 0.0 else 0.0 + A2 = math.pow(length, 4.0 / 3.0) * math.pow(math.fabs(a2), -1.0 / 3.0) * (a2 / math.fabs(a2)) if a2 != 0.0 else 0.0 + A3 = math.pow(length, 5.0 / 4.0) * math.pow(math.fabs(a3), -1.0 / 4.0) * (a3 / math.fabs(a3)) if a3 != 0.0 else 0.0 + + parent_curve = file.createIfcThirdOrderPolynomialSpiral( + Position=file.createIfcAxis2Placement2D( + Location=file.createIfcCartesianPoint((0.0, 0.0)), RefDirection=file.createIfcDirection((1.0, 0.0)) + ), + CubicTerm=A3, + QuadraticTerm=A2 if A2 != 0.0 else None, + LinearTerm=A1 if A1 != 0.0 else None, + ConstantTerm=A0 if A0 != 0.0 else None, + ) + + start_point = file.createIfcCartesianPoint((dist_along, Ds, 0.0)) + start_direction = 0.0 + + curve_segment = file.createIfcCurveSegment( + Transition=transition, + Placement=file.createIfcAxis2Placement3D( + Location=start_point, + Axis=_get_axis(file, Ds, rail_head_distance), + RefDirection=file.createIfcDirection((math.cos(start_direction), math.sin(start_direction), 0.0)), + ), + SegmentStart=file.createIfcLengthMeasure(0.0), + SegmentLength=file.createIfcLengthMeasure(length), + ParentCurve=parent_curve, + ) + return (curve_segment, None) -def _map_cosine_curve(file: ifcopenshell.file, design_parameters: entity_instance) -> Sequence[entity_instance]: - raise NotImplementedError("COSINECURVE not implemented") +def _map_cosine_curve( + file: ifcopenshell.file, design_parameters: entity_instance, rail_head_distance: float +) -> Sequence[entity_instance]: + dist_along = design_parameters.StartDistAlong + length = design_parameters.HorizontalLength + Dsl = design_parameters.StartCantLeft + Del = design_parameters.EndCantLeft + Dsr = design_parameters.StartCantRight + Der = design_parameters.EndCantRight + + Ds = 0.5 * (Dsl + Dsr) + De = 0.5 * (Del + Der) + f = De - Ds + + a0 = Ds + 0.5 * f # constant term + a1 = -0.5 * f # cosine term + + A0 = math.pow(length, 2.0) * math.pow(math.fabs(a0), -1.0 / 1.0) * (a0 / math.fabs(a0)) if a0 != 0.0 else 0.0 + A1 = math.pow(length, 2.0) * math.pow(math.fabs(a1), -1.0 / 1.0) * (a1 / math.fabs(a1)) if a1 != 0.0 else 0.0 + + transition = "DISCONTINUOUS" + + parent_curve = file.createIfcCosineSpiral( + Position=file.createIfcAxis2Placement2D( + Location=file.createIfcCartesianPoint((0.0, 0.0)), RefDirection=file.createIfcDirection((1.0, 0.0)) + ), + CosineTerm=A1, + ConstantTerm=A0 if A0 != 0.0 else None, + ) + + start_point = file.createIfcCartesianPoint((dist_along, Ds, 0.0)) + start_direction = 0.0 + + curve_segment = file.createIfcCurveSegment( + Transition=transition, + Placement=file.createIfcAxis2Placement3D( + Location=start_point, + Axis=_get_axis(file, Ds, rail_head_distance), + RefDirection=file.createIfcDirection((math.cos(start_direction), math.sin(start_direction), 0.0)), + ), + SegmentStart=file.createIfcLengthMeasure(0.0), + SegmentLength=file.createIfcLengthMeasure(length), + ParentCurve=parent_curve, + ) + return (curve_segment, None) -def _map_sine_curve(file: ifcopenshell.file, design_parameters: entity_instance) -> Sequence[entity_instance]: - raise NotImplementedError("SINECURVE not implemented") +def _map_sine_curve( + file: ifcopenshell.file, design_parameters: entity_instance, rail_head_distance: float +) -> Sequence[entity_instance]: + dist_along = design_parameters.StartDistAlong + length = design_parameters.HorizontalLength + Dsl = design_parameters.StartCantLeft + Del = design_parameters.EndCantLeft + Dsr = design_parameters.StartCantRight + Der = design_parameters.EndCantRight + + Ds = 0.5 * (Dsl + Dsr) + De = 0.5 * (Del + Der) + f = De - Ds + + a0 = Ds # constant term + a1 = f # linear term + a2 = -(1.0 / (2.0 * math.pi)) * f # sine term + + A0 = math.pow(length, 2.0) * math.pow(math.fabs(a0), -1.0 / 1.0) * (a0 / math.fabs(a0)) if a0 != 0.0 else 0.0 + A1 = math.pow(length, 1.5) * math.pow(math.fabs(a1), -1.0 / 2.0) * (a1 / math.fabs(a1)) if a1 != 0.0 else 0.0 + A2 = math.pow(length, 2.0) * math.pow(math.fabs(a2), -1.0 / 1.0) * (a2 / math.fabs(a2)) if a2 != 0.0 else 0.0 + + transition = "DISCONTINUOUS" + + parent_curve = file.createIfcSineSpiral( + Position=file.createIfcAxis2Placement2D( + Location=file.createIfcCartesianPoint((0.0, 0.0)), RefDirection=file.createIfcDirection((1.0, 0.0)) + ), + SineTerm=A2, + LinearTerm=A1 if A1 != 0 else None, + ConstantTerm=A0 if A0 != 0.0 else None, + ) + + start_point = file.createIfcCartesianPoint((dist_along, Ds, 0.0)) + start_direction = 0.0 + + curve_segment = file.createIfcCurveSegment( + Transition=transition, + Placement=file.createIfcAxis2Placement3D( + Location=start_point, + Axis=_get_axis(file, Ds, rail_head_distance), + RefDirection=file.createIfcDirection((math.cos(start_direction), math.sin(start_direction), 0.0)), + ), + SegmentStart=file.createIfcLengthMeasure(0.0), + SegmentLength=file.createIfcLengthMeasure(length), + ParentCurve=parent_curve, + ) + return (curve_segment, None) -def _map_viennese_bend(file: ifcopenshell.file, design_parameters: entity_instance) -> Sequence[entity_instance]: +def _map_viennese_bend( + file: ifcopenshell.file, design_parameters: entity_instance, rail_head_distance: float +) -> Sequence[entity_instance]: raise NotImplementedError("VIENNESEBEND not implemented") def map_alignment_cant_segment( - file: ifcopenshell.file, design_parameters: entity_instance + file: ifcopenshell.file, segment: entity_instance, rail_head_distance: float ) -> Sequence[entity_instance]: """ Creates IfcCurveSegment entities for the represention of the supplied IfcAlignmentCantSegment business logic entity instance. @@ -59,25 +388,25 @@ def map_alignment_cant_segment( The IfcCurveSegment.Transition transition code is set to DISCONTINUOUS. """ - expected_type = "IfcAlignmentCantSegment" - if not design_parameters.is_a(expected_type): - raise TypeError(f"Expected to see type '{expected_type}', instead received '{design_parameters.is_a()}'.") + expected_type = "IfcAlignmentSegment" + if not segment.is_a(expected_type): + raise TypeError(f"Expected to see type '{expected_type}', instead received '{segment.is_a()}'.") - match design_parameters.PredefinedType: + match segment.DesignParameters.PredefinedType: case "CONSTANTCANT": - result = _map_constant_cant(file, design_parameters) + result = _map_constant_cant(file, segment.DesignParameters, rail_head_distance) case "LINEARTRANSITION": - result = _map_linear_transition(file, design_parameters) + result = _map_linear_transition(file, segment.DesignParameters, rail_head_distance) case "HELMERTCURVE": - result = _map_helmert_curve(file, design_parameters) + result = _map_helmert_curve(file, segment.DesignParameters, rail_head_distance) case "BLOSSCURVE": - result = _map_bloss_curve(file, design_parameters) + result = _map_bloss_curve(file, segment.DesignParameters, rail_head_distance) case "COSINECURVE": - result = _map_cosine_curve(file, design_parameters) + result = _map_cosine_curve(file, segment.DesignParameters, rail_head_distance) case "SINECURVE": - result = _map_sine_curve(file, design_parameters) + result = _map_sine_curve(file, segment.DesignParameters, rail_head_distance) case "VIENNESEBEND": - result = _map_viennese_bend(file, design_parameters) + result = _map_viennese_bend(file, segment.DesignParameters, rail_head_distance) case _: raise TypeError("Unexpected predefined type") diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_horizontal_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_horizontal_segment.py index bb86ea6bbb..a51fcd6808 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_horizontal_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_horizontal_segment.py @@ -401,38 +401,36 @@ def _map_viennese_bend(file: ifcopenshell.file, design_parameters: entity_instan raise NotImplementedError("VIENNESEBEND not implemented") -def map_alignment_horizontal_segment( - file: ifcopenshell.file, design_parameters: entity_instance -) -> Sequence[entity_instance]: +def map_alignment_horizontal_segment(file: ifcopenshell.file, segment: entity_instance) -> Sequence[entity_instance]: """ Creates IfcCurveSegment entities for the represention of the supplied IfcAlignmentHorizontalSegment business logic entity instance. A pair of entities is returned because a single business logic segment of type HELMERTCURVE maps to two representaiton entities. The IfcCurveSegment.Transition transition code is set to DISCONTINUOUS """ - expected_type = "IfcAlignmentHorizontalSegment" - if not design_parameters.is_a(expected_type): - raise TypeError(f"Expected to see type '{expected_type}', instead received '{design_parameters.is_a()}'.") + expected_type = "IfcAlignmentSegment" + if not segment.is_a(expected_type): + raise TypeError(f"Expected to see type '{expected_type}', instead received '{segment.is_a()}'.") - match design_parameters.PredefinedType: + match segment.DesignParameters.PredefinedType: case "LINE": - result = _map_line(file, design_parameters) + result = _map_line(file, segment.DesignParameters) case "CIRCULARARC": - result = _map_circular_arc(file, design_parameters) + result = _map_circular_arc(file, segment.DesignParameters) case "CLOTHOID": - result = _map_clothoid(file, design_parameters) + result = _map_clothoid(file, segment.DesignParameters) case "CUBIC": - result = _map_cubic(file, design_parameters) + result = _map_cubic(file, segment.DesignParameters) case "HELMERTCURVE": - result = _map_helmert_curve(file, design_parameters) + result = _map_helmert_curve(file, segment.DesignParameters) case "BLOSSCURVE": - result = _map_bloss_curve(file, design_parameters) + result = _map_bloss_curve(file, segment.DesignParameters) case "COSINECURVE": - result = _map_cosine_curve(file, design_parameters) + result = _map_cosine_curve(file, segment.DesignParameters) case "SINECURVE": - result = _map_sine_curve(file, design_parameters) + result = _map_sine_curve(file, segment.DesignParameters) case "VIENNESEBEND": - result = _map_viennese_bend(file, design_parameters) + result = _map_viennese_bend(file, segment.DesignParameters) case _: raise TypeError("Unexpected predefined type") diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_segment.py deleted file mode 100644 index d7b05d5544..0000000000 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_segment.py +++ /dev/null @@ -1,47 +0,0 @@ -# IfcOpenShell - IFC toolkit and geometry engine -# Copyright (C) 2025 Thomas Krijnen -# -# This file is part of IfcOpenShell. -# -# IfcOpenShell is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# IfcOpenShell is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with IfcOpenShell. If not, see . - -import ifcopenshell -import ifcopenshell.api -from ifcopenshell import entity_instance -from typing import Sequence - - -def map_alignment_segment(file: ifcopenshell.file, segment: entity_instance) -> Sequence[entity_instance]: - """ - Creates IfcCurveSegment entities for the represention of the supplied IfcAlignmentSegment business logic entity instance. - A pair of entities is returned because a single business logic segment of type HELMERTCURVE maps to two representaiton entities. - - The IfcCurveSegment.Transition transition code is set to DISCONTINUOUS, except for the transition between helmert curve segments. - - This function will evaluate the IfcAlignmentSegment.DesignParameters type and call the correct lower level mapping function. - """ - expected_type = "IfcAlignmentSegment" - if not segment.is_a(expected_type): - raise TypeError(f"Expected to see type '{expected_type}', instead received '{segment.is_a()}'.") - - if segment.DesignParameters.is_a("IfcAlignmentHorizontalSegment"): - return ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, segment.DesignParameters) - elif segment.DesignParameters.is_a("IfcAlignmentVerticalSegment"): - return ifcopenshell.api.alignment.map_alignment_vertical_segment(file, segment.DesignParameters) - elif segment.DesignParameters.is_a("IfcAlignmentCantSegment"): - return ifcopenshell.api.alignment.map_alignment_cant_segment(file, segment.DesignParameters) - else: - raise TypeError("Unexpected type for segment.DesignParameters") - - return (None, None) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_segments.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_segments.py index d9012d59ef..f4946751c1 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_segments.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_segments.py @@ -56,7 +56,14 @@ def map_alignment_segments( for rel_nests in alignment.IsNestedBy: for layout in rel_nests.RelatedObjects: if layout.is_a("IfcLinearElement"): - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, layout) + if alignment.is_a("IfcAlignmentHorizontal"): + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, layout) + elif alignment.is_a("IfcAlignmentVertical"): + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, layout) + elif alignment.is_a("IfcAlignmentCant"): + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment( + file, layout, alignment.RailHeadDistance + ) for mapped_segment in mapped_segments: if mapped_segment: ifcopenshell.api.alignment.add_segment_to_curve(file, mapped_segment, composite_curve) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_vertical_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_vertical_segment.py index 3e80f3c6f3..d02a389106 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_vertical_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/map_alignment_vertical_segment.py @@ -60,10 +60,7 @@ def _map_constant_gradient(file: ifcopenshell.file, design_parameters: entity_in parent_curve = file.create_entity( type="IfcLine", - Pnt=file.create_entity( - type="IfcCartesianPoint", - Coordinates=(0.0, 0.0), - ), + Pnt=file.createIfcCartesianPoint((0.0, 0.0)), Dir=file.create_entity( type="IfcVector", Orientation=file.create_entity( @@ -78,12 +75,10 @@ def _map_constant_gradient(file: ifcopenshell.file, design_parameters: entity_in dy = math.sin(math.atan(start_gradient)) curve_segment_length = horizontal_length / dx - curve_segment = file.create_entity( - type="IfcCurveSegment", + curve_segment = file.createIfcCurveSegment( Transition=transition, - Placement=file.create_entity( - type="IfcAxis2Placement2D", - Location=file.create_entity(type="IfcCartesianPoint", Coordinates=(start_distance_along, start_height)), + Placement=file.createIfcAxis2Placement2D( + Location=file.createIfcCartesianPoint((start_distance_along, start_height)), RefDirection=file.createIfcDirection((dx, dy)), ), SegmentStart=file.createIfcLengthMeasure(0.0), @@ -110,7 +105,7 @@ def _map_parabolic_arc(file: ifcopenshell.file, design_parameters: entity_instan type="IfcPolynomialCurve", Position=file.create_entity( type="IfcAxis2Placement2D", - Location=file.create_entity(type="IfcCartesianPoint", Coordinates=(0.0, 0.0)), + Location=file.createIfcCartesianPoint((0.0, 0.0)), RefDirection=file.createIfcDirection( (1.0, 0.0), ), @@ -128,7 +123,7 @@ def _map_parabolic_arc(file: ifcopenshell.file, design_parameters: entity_instan Transition=transition, Placement=file.create_entity( type="IfcAxis2Placement2D", - Location=file.create_entity(type="IfcCartesianPoint", Coordinates=(start_distance_along, start_height)), + Location=file.createIfcCartesianPoint((start_distance_along, start_height)), RefDirection=file.createIfcDirection((dx, dy)), ), SegmentStart=file.createIfcLengthMeasure(0.0), @@ -194,32 +189,30 @@ def _map_clothoid(file: ifcopenshell.file, design_parameters: entity_instance) - raise NotImplementedError("mapping for IfcVerticalSegment.CLOTHOID not implemented") -def map_alignment_vertical_segment( - file: ifcopenshell.file, design_parameters: entity_instance -) -> Sequence[entity_instance]: +def map_alignment_vertical_segment(file: ifcopenshell.file, segment: entity_instance) -> Sequence[entity_instance]: """ Creates IfcCurveSegment entities for the represention of the supplied IfcAlignmentVerticalSegment business logic entity instance. A pair of entities is returned for consistency with map_alignment_horizontal_segment and map_alignment_cant_segment. """ - expected_type = "IfcAlignmentVerticalSegment" - if not design_parameters.is_a(expected_type): - raise TypeError(f"Expected to see type '{expected_type}', instead received '{design_parameters.is_a()}'.") + expected_type = "IfcAlignmentSegment" + if not segment.is_a(expected_type): + raise TypeError(f"Expected to see type '{expected_type}', instead received '{segment.is_a()}'.") - match design_parameters.PredefinedType: + match segment.DesignParameters.PredefinedType: case "CONSTANTGRADIENT": - result = _map_constant_gradient(file, design_parameters) + result = _map_constant_gradient(file, segment.DesignParameters) case "PARABOLICARC": - result = _map_parabolic_arc(file, design_parameters) + result = _map_parabolic_arc(file, segment.DesignParameters) case "CIRCULARARC": - result = _map_circular_arc(file, design_parameters) + result = _map_circular_arc(file, segment.DesignParameters) case "CLOTHOID": - result = _map_clothoid(file, design_parameters) + result = _map_clothoid(file, segment.DesignParameters) case _: - raise TypeError("Unexpected predefined type") + raise TypeError(f"Unexpected predefined type - got {segment.DesignParameters.PredefinedType}") return result diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py index 755fe3e13c..3e938df6e5 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py @@ -21,6 +21,1639 @@ import ifcopenshell.api.alignment import ifcopenshell.api.context +def _BlossCurve_100_0_300_1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="BLOSSCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcThirdOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(500.00000000000017) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-746.9007910928623) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(125000.0) + + +def _BlossCurve_100_0__300__1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="BLOSSCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcThirdOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(500.00000000000017) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-746.9007910928623) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(125000.0) + + +def _BlossCurve_100_0_300_inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="BLOSSCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcThirdOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(500.00000000000017) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-746.9007910928623) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(125000.0) + + +def _BlossCurve_100_0__300__inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="BLOSSCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcThirdOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(500.00000000000017) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-746.9007910928623) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(125000.0) + + +def _BlossCurve_100_0_1000_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="BLOSSCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcThirdOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(-500.00000000000017) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(746.9007910928623) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + + +def _BlossCurve_100_0__1000__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="BLOSSCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcThirdOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(-500.00000000000017) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(746.9007910928623) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + + +def _BlossCurve_100_0_inf_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="BLOSSCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcThirdOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(-500.00000000000017) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(746.9007910928623) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + + +def _BlossCurve_100_0__inf__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="BLOSSCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcThirdOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(-500.00000000000017) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(746.9007910928623) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + + +def _ConstantCant_100_0_300_1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="CONSTANTCANT", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcLine") + assert mapped_segment.ParentCurve.Pnt.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Orientation.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Magnitude == pytest.approx(1.0) + + +def _ConstantCant_100_0__300__1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="CONSTANTCANT", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcLine") + assert mapped_segment.ParentCurve.Pnt.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Orientation.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Magnitude == pytest.approx(1.0) + + +def _ConstantCant_100_0_300_inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="CONSTANTCANT", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcLine") + assert mapped_segment.ParentCurve.Pnt.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Orientation.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Magnitude == pytest.approx(1.0) + + +def _ConstantCant_100_0__300__inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="CONSTANTCANT", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcLine") + assert mapped_segment.ParentCurve.Pnt.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Orientation.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Magnitude == pytest.approx(1.0) + + +def _ConstantCant_100_0_1000_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="CONSTANTCANT", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcLine") + assert mapped_segment.ParentCurve.Pnt.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Orientation.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Magnitude == pytest.approx(1.0) + + +def _ConstantCant_100_0__1000__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="CONSTANTCANT", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcLine") + assert mapped_segment.ParentCurve.Pnt.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Orientation.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Magnitude == pytest.approx(1.0) + + +def _ConstantCant_100_0_inf_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="CONSTANTCANT", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcLine") + assert mapped_segment.ParentCurve.Pnt.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Orientation.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Magnitude == pytest.approx(1.0) + + +def _ConstantCant_100_0__inf__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="CONSTANTCANT", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcLine") + assert mapped_segment.ParentCurve.Pnt.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Orientation.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.Dir.Magnitude == pytest.approx(1.0) + + +def _CosineCurve_100_0_300_1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="COSINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcCosineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CosineTerm == pytest.approx(250000.0) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(250000.0) + + +def _CosineCurve_100_0__300__1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="COSINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcCosineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CosineTerm == pytest.approx(250000.0) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(250000.0) + + +def _CosineCurve_100_0_300_inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="COSINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcCosineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CosineTerm == pytest.approx(250000.0) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(250000.0) + + +def _CosineCurve_100_0__300__inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="COSINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcCosineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CosineTerm == pytest.approx(250000.0) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(250000.0) + + +def _CosineCurve_100_0_1000_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="COSINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcCosineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CosineTerm == pytest.approx(-250000.0) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(250000.0) + + +def _CosineCurve_100_0__1000__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="COSINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcCosineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CosineTerm == pytest.approx(-250000.0) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(250000.0) + + +def _CosineCurve_100_0_inf_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="COSINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcCosineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CosineTerm == pytest.approx(-250000.0) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(250000.0) + + +def _CosineCurve_100_0__inf__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="COSINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcCosineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.CosineTerm == pytest.approx(-250000.0) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(250000.0) + + +def _HelmertCurve_100_0_300_1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="HELMERTCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(31250.0) + mapped_segment = mapped_segments[1] + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((50.0, 0.04, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999998720000819, -0.00159999897600066, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(50.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-883.8834764831845) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(15625.0) + + +def _HelmertCurve_100_0__300__1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="HELMERTCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(31250.0) + mapped_segment = mapped_segments[1] + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((50.0, 0.04, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999998720000819, -0.00159999897600066, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(50.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-883.8834764831845) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(15625.0) + + +def _HelmertCurve_100_0_300_inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="HELMERTCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(31250.0) + mapped_segment = mapped_segments[1] + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((50.0, 0.04, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999998720000819, -0.00159999897600066, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(50.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-883.8834764831845) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(15625.0) + + +def _HelmertCurve_100_0__300__inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="HELMERTCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(31250.0) + mapped_segment = mapped_segments[1] + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((50.0, 0.04, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999998720000819, -0.00159999897600066, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(50.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-883.8834764831845) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(15625.0) + + +def _HelmertCurve_100_0_1000_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="HELMERTCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + mapped_segment = mapped_segments[1] + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((50.0, 0.04, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999998720000819, 0.00159999897600066, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(50.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(883.8834764831845) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(-31250.0) + + +def _HelmertCurve_100_0__1000__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="HELMERTCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + mapped_segment = mapped_segments[1] + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((50.0, 0.04, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999998720000819, 0.00159999897600066, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(50.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(883.8834764831845) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(-31250.0) + + +def _HelmertCurve_100_0_inf_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="HELMERTCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + mapped_segment = mapped_segments[1] + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((50.0, 0.04, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999998720000819, 0.00159999897600066, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(50.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(883.8834764831845) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(-31250.0) + + +def _HelmertCurve_100_0__inf__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="HELMERTCURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + mapped_segment = mapped_segments[1] + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((50.0, 0.04, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999998720000819, 0.00159999897600066, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(50.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(50.0) + assert mapped_segment.ParentCurve.is_a("IfcSecondOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(-538.6086725079696) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(883.8834764831845) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(-31250.0) + + +def _LinearTransition_100_0_300_1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="LINEARTRANSITION", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999999680000154, -0.000799999744000123, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcClothoid") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.ClothoidConstant == pytest.approx(-3535.53390593274) + + +def _LinearTransition_100_0__300__1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="LINEARTRANSITION", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999999680000154, -0.000799999744000123, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcClothoid") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.ClothoidConstant == pytest.approx(-3535.53390593274) + + +def _LinearTransition_100_0_300_inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="LINEARTRANSITION", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999999680000154, -0.000799999744000123, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcClothoid") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.ClothoidConstant == pytest.approx(-3535.53390593274) + + +def _LinearTransition_100_0__300__inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="LINEARTRANSITION", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999999680000154, -0.000799999744000123, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcClothoid") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.ClothoidConstant == pytest.approx(-3535.53390593274) + + +def _LinearTransition_100_0_1000_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="LINEARTRANSITION", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999999680000154, 0.000799999744000123, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcClothoid") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.ClothoidConstant == pytest.approx(3535.53390593274) + + +def _LinearTransition_100_0__1000__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="LINEARTRANSITION", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999999680000154, 0.000799999744000123, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcClothoid") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.ClothoidConstant == pytest.approx(3535.53390593274) + + +def _LinearTransition_100_0_inf_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="LINEARTRANSITION", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999999680000154, 0.000799999744000123, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcClothoid") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.ClothoidConstant == pytest.approx(3535.53390593274) + + +def _LinearTransition_100_0__inf__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="LINEARTRANSITION", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx( + (0.999999680000154, 0.000799999744000123, 0.0) + ) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcClothoid") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.ClothoidConstant == pytest.approx(3535.53390593274) + + +def _SineCurve_100_0_300_1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="SINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SineTerm == pytest.approx(785398.163397448) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-3535.53390593274) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(125000.0) + + +def _SineCurve_100_0__300__1000_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="SINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SineTerm == pytest.approx(785398.163397448) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-3535.53390593274) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(125000.0) + + +def _SineCurve_100_0_300_inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.16, + EndCantRight=0.0, + PredefinedType="SINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SineTerm == pytest.approx(785398.163397448) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-3535.53390593274) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(125000.0) + + +def _SineCurve_100_0__300__inf_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.16, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="SINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.08, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SineTerm == pytest.approx(785398.163397448) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-3535.53390593274) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(125000.0) + + +def _SineCurve_100_0_1000_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="SINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SineTerm == pytest.approx(-785398.163397448) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(3535.53390593274) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + + +def _SineCurve_100_0__1000__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="SINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SineTerm == pytest.approx(-785398.163397448) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(3535.53390593274) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + + +def _SineCurve_100_0_inf_300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.16, + PredefinedType="SINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SineTerm == pytest.approx(-785398.163397448) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(3535.53390593274) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + + +def _SineCurve_100_0__inf__300_1_Meter(file): + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.16, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="SINECURVE", + ) + + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = ifcopenshell.api.alignment.map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSineSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SineTerm == pytest.approx(-785398.163397448) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(3535.53390593274) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + + def test_map_alignment_cant_segment(): file = ifcopenshell.file(schema="IFC4X3_ADD2") - # create tests as the mapping functions are implemented + _BlossCurve_100_0_300_1000_1_Meter(file) + _BlossCurve_100_0__300__1000_1_Meter(file) + _BlossCurve_100_0_300_inf_1_Meter(file) + _BlossCurve_100_0__300__inf_1_Meter(file) + _BlossCurve_100_0_1000_300_1_Meter(file) + _BlossCurve_100_0__1000__300_1_Meter(file) + _BlossCurve_100_0_inf_300_1_Meter(file) + _BlossCurve_100_0__inf__300_1_Meter(file) + _ConstantCant_100_0_300_1000_1_Meter(file) + _ConstantCant_100_0__300__1000_1_Meter(file) + _ConstantCant_100_0_300_inf_1_Meter(file) + _ConstantCant_100_0__300__inf_1_Meter(file) + _ConstantCant_100_0_1000_300_1_Meter(file) + _ConstantCant_100_0__1000__300_1_Meter(file) + _ConstantCant_100_0_inf_300_1_Meter(file) + _ConstantCant_100_0__inf__300_1_Meter(file) + _CosineCurve_100_0_300_1000_1_Meter(file) + _CosineCurve_100_0__300__1000_1_Meter(file) + _CosineCurve_100_0_300_inf_1_Meter(file) + _CosineCurve_100_0__300__inf_1_Meter(file) + _CosineCurve_100_0_1000_300_1_Meter(file) + _CosineCurve_100_0__1000__300_1_Meter(file) + _CosineCurve_100_0_inf_300_1_Meter(file) + _CosineCurve_100_0__inf__300_1_Meter(file) + _HelmertCurve_100_0_300_1000_1_Meter(file) + _HelmertCurve_100_0__300__1000_1_Meter(file) + _HelmertCurve_100_0_300_inf_1_Meter(file) + _HelmertCurve_100_0__300__inf_1_Meter(file) + _HelmertCurve_100_0_1000_300_1_Meter(file) + _HelmertCurve_100_0__1000__300_1_Meter(file) + _HelmertCurve_100_0_inf_300_1_Meter(file) + _HelmertCurve_100_0__inf__300_1_Meter(file) + _LinearTransition_100_0_300_1000_1_Meter(file) + _LinearTransition_100_0__300__1000_1_Meter(file) + _LinearTransition_100_0_300_inf_1_Meter(file) + _LinearTransition_100_0__300__inf_1_Meter(file) + _LinearTransition_100_0_1000_300_1_Meter(file) + _LinearTransition_100_0__1000__300_1_Meter(file) + _LinearTransition_100_0_inf_300_1_Meter(file) + _LinearTransition_100_0__inf__300_1_Meter(file) + _SineCurve_100_0_300_1000_1_Meter(file) + _SineCurve_100_0__300__1000_1_Meter(file) + _SineCurve_100_0_300_inf_1_Meter(file) + _SineCurve_100_0__300__inf_1_Meter(file) + _SineCurve_100_0_1000_300_1_Meter(file) + _SineCurve_100_0__1000__300_1_Meter(file) + _SineCurve_100_0_inf_300_1_Meter(file) + _SineCurve_100_0__inf__300_1_Meter(file) + + # VIENESSE BEND NOT IMPLEMENTED diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py index 0d8e55293d..bbe744e537 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py @@ -37,7 +37,7 @@ def _BlossCurve_100_0_300_1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -68,7 +68,7 @@ def _BlossCurve_100_0__300__1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -99,7 +99,7 @@ def _BlossCurve_100_0_300_inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -130,7 +130,7 @@ def _BlossCurve_100_0__300__inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -161,7 +161,7 @@ def _BlossCurve_100_0_1000_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -192,7 +192,7 @@ def _BlossCurve_100_0__1000__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -223,7 +223,7 @@ def _BlossCurve_100_0_inf_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -254,7 +254,7 @@ def _BlossCurve_100_0__inf__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -285,7 +285,7 @@ def _CircularArc_100_0_300_1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -313,7 +313,7 @@ def _CircularArc_100_0__300__1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -341,7 +341,7 @@ def _CircularArc_100_0_300_inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -369,7 +369,7 @@ def _CircularArc_100_0__300__inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -397,7 +397,7 @@ def _CircularArc_100_0_1000_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -425,7 +425,7 @@ def _CircularArc_100_0__1000__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -453,7 +453,7 @@ def _CircularArc_100_0_inf_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -481,7 +481,7 @@ def _CircularArc_100_0__inf__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -509,7 +509,7 @@ def _Clothoid_100_0_300_1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -537,7 +537,7 @@ def _Clothoid_100_0__300__1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -565,7 +565,7 @@ def _Clothoid_100_0_300_inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -593,7 +593,7 @@ def _Clothoid_100_0__300__inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -621,7 +621,7 @@ def _Clothoid_100_0_1000_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -649,7 +649,7 @@ def _Clothoid_100_0__1000__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -677,7 +677,7 @@ def _Clothoid_100_0_inf_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -705,7 +705,7 @@ def _Clothoid_100_0__inf__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -733,7 +733,7 @@ def _CosineCurve_100_0_300_1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -762,7 +762,7 @@ def _CosineCurve_100_0__300__1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -791,7 +791,7 @@ def _CosineCurve_100_0_300_inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -820,7 +820,7 @@ def _CosineCurve_100_0__300__inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -849,7 +849,7 @@ def _CosineCurve_100_0_1000_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -878,7 +878,7 @@ def _CosineCurve_100_0__1000__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -907,7 +907,7 @@ def _CosineCurve_100_0_inf_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -936,7 +936,7 @@ def _CosineCurve_100_0__inf__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -965,7 +965,7 @@ def _Cubic_100_0_300_1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -994,7 +994,7 @@ def _Cubic_100_0__300__1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1023,7 +1023,7 @@ def _Cubic_100_0_300_inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1052,7 +1052,7 @@ def _Cubic_100_0__300__inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1081,7 +1081,7 @@ def _Cubic_100_0_1000_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1110,7 +1110,7 @@ def _Cubic_100_0__1000__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1139,7 +1139,7 @@ def _Cubic_100_0_inf_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1168,7 +1168,7 @@ def _Cubic_100_0__inf__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1197,7 +1197,7 @@ def _HelmertCurve_100_0_300_1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1245,7 +1245,7 @@ def _HelmertCurve_100_0__300__1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1293,7 +1293,7 @@ def _HelmertCurve_100_0_300_inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1341,7 +1341,7 @@ def _HelmertCurve_100_0__300__inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1389,7 +1389,7 @@ def _HelmertCurve_100_0_1000_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1437,7 +1437,7 @@ def _HelmertCurve_100_0__1000__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1485,7 +1485,7 @@ def _HelmertCurve_100_0_inf_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1533,7 +1533,7 @@ def _HelmertCurve_100_0__inf__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1581,7 +1581,7 @@ def _Line_100_0_300_1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1609,7 +1609,7 @@ def _Line_100_0__300__1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1637,7 +1637,7 @@ def _Line_100_0_300_inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1665,7 +1665,7 @@ def _Line_100_0__300__inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1693,7 +1693,7 @@ def _Line_100_0_1000_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1721,7 +1721,7 @@ def _Line_100_0__1000__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1749,7 +1749,7 @@ def _Line_100_0_inf_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1777,7 +1777,7 @@ def _Line_100_0__inf__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1805,7 +1805,7 @@ def _SineCurve_100_0_300_1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1835,7 +1835,7 @@ def _SineCurve_100_0__300__1000_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1865,7 +1865,7 @@ def _SineCurve_100_0_300_inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1895,7 +1895,7 @@ def _SineCurve_100_0__300__inf_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1925,7 +1925,7 @@ def _SineCurve_100_0_1000_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1955,7 +1955,7 @@ def _SineCurve_100_0__1000__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -1985,7 +1985,7 @@ def _SineCurve_100_0_inf_300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2015,7 +2015,7 @@ def _SineCurve_100_0__inf__300_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_segments.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_segments.py deleted file mode 100644 index 1c9d04bc24..0000000000 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_segments.py +++ /dev/null @@ -1,102 +0,0 @@ -# IfcOpenShell - IFC toolkit and geometry engine -# Copyright (C) 2025 Thomas Krijnen -# -# This file is part of IfcOpenShell. -# -# IfcOpenShell is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# IfcOpenShell is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with IfcOpenShell. If not, see . - -import pytest -import ifcopenshell.api.alignment -import ifcopenshell.api.context - - -def test_map_alignment_horizontal_segment(): - file = ifcopenshell.file(schema="IFC4X3_ADD2") - project = file.createIfcProject(Name="Test") - geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") - axis_model_representation_subcontext = ifcopenshell.api.context.add_context( - file, - context_type="Model", - context_identifier="Axis", - target_view="MODEL_VIEW", - parent=geometric_representation_context, - ) - - coordinates = [(500.0, 2500.0), (3340.0, 660.0), (4340.0, 5000.0), (7600.0, 4560.0), (8480.0, 2010.0)] - radii = [(1000.0), (1250.0), (950.0)] - vpoints = [(0.0, 100.0), (2000.0, 135.0), (5000.0, 105.0), (7400.0, 153.0), (9800.0, 105.0), (12800.0, 90.0)] - lengths = [(1600.0), (1200.0), (2000.0), (800.0)] - - alignment = ifcopenshell.api.alignment.create_alignment_by_pi_method( - file, "TestAlignment", coordinates, radii, vpoints, lengths - ) - - horizontal_alignment = alignment.IsNestedBy[0].RelatedObjects[0] - assert horizontal_alignment.is_a("IfcAlignmentHorizontal") - - composite_curve = file.create_entity( - type="IfcCompositeCurve", - Segments=[], - SelfIntersect=False, - ) - - ifcopenshell.api.alignment.map_alignment_segments(file, horizontal_alignment, composite_curve) - assert len(composite_curve.Segments) == 8 - assert composite_curve.Segments[0].ParentCurve.is_a("IfcLine") - assert composite_curve.Segments[0].Transition == "CONTSAMEGRADIENT" - assert composite_curve.Segments[1].ParentCurve.is_a("IfcCircle") - assert composite_curve.Segments[1].Transition == "CONTSAMEGRADIENT" - assert composite_curve.Segments[2].ParentCurve.is_a("IfcLine") - assert composite_curve.Segments[2].Transition == "CONTSAMEGRADIENT" - assert composite_curve.Segments[3].ParentCurve.is_a("IfcCircle") - assert composite_curve.Segments[3].Transition == "CONTSAMEGRADIENT" - assert composite_curve.Segments[4].ParentCurve.is_a("IfcLine") - assert composite_curve.Segments[4].Transition == "CONTSAMEGRADIENT" - assert composite_curve.Segments[5].ParentCurve.is_a("IfcCircle") - assert composite_curve.Segments[5].Transition == "CONTSAMEGRADIENT" - assert composite_curve.Segments[6].ParentCurve.is_a("IfcLine") - assert composite_curve.Segments[6].Transition == "CONTSAMEGRADIENTSAMECURVATURE" - assert composite_curve.Segments[7].ParentCurve.is_a("IfcLine") - assert composite_curve.Segments[7].Transition == "DISCONTINUOUS" - - vertical_alignment = alignment.IsNestedBy[0].RelatedObjects[1] - assert vertical_alignment.is_a("IfcAlignmentVertical") - - gradient_curve = file.create_entity( - type="IfcGradientCurve", Segments=[], SelfIntersect=False, BaseCurve=composite_curve, EndPoint=None - ) - - ifcopenshell.api.alignment.map_alignment_segments(file, vertical_alignment, gradient_curve) - assert len(gradient_curve.Segments) == 10 - - assert gradient_curve.Segments[0].ParentCurve.is_a("IfcLine") - assert gradient_curve.Segments[0].Transition == "CONTSAMEGRADIENT" - assert gradient_curve.Segments[1].ParentCurve.is_a("IfcPolynomialCurve") - assert gradient_curve.Segments[1].Transition == "CONTSAMEGRADIENT" - assert gradient_curve.Segments[2].ParentCurve.is_a("IfcLine") - assert gradient_curve.Segments[2].Transition == "CONTSAMEGRADIENT" - assert gradient_curve.Segments[3].ParentCurve.is_a("IfcPolynomialCurve") - assert gradient_curve.Segments[3].Transition == "CONTSAMEGRADIENT" - assert gradient_curve.Segments[4].ParentCurve.is_a("IfcLine") - assert gradient_curve.Segments[4].Transition == "CONTSAMEGRADIENT" - assert gradient_curve.Segments[5].ParentCurve.is_a("IfcPolynomialCurve") - assert gradient_curve.Segments[5].Transition == "CONTSAMEGRADIENT" - assert gradient_curve.Segments[6].ParentCurve.is_a("IfcLine") - assert gradient_curve.Segments[6].Transition == "CONTSAMEGRADIENT" - assert gradient_curve.Segments[7].ParentCurve.is_a("IfcPolynomialCurve") - assert gradient_curve.Segments[7].Transition == "CONTSAMEGRADIENT" - assert gradient_curve.Segments[8].ParentCurve.is_a("IfcLine") - assert gradient_curve.Segments[8].Transition == "CONTSAMEGRADIENTSAMECURVATURE" - assert gradient_curve.Segments[9].ParentCurve.is_a("IfcLine") - assert gradient_curve.Segments[9].Transition == "DISCONTINUOUS" diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_vertical_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_vertical_segment.py index 867183d369..0d72fe6b83 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_vertical_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_vertical_segment.py @@ -37,7 +37,7 @@ def _CircularArc_100_0_10_0_0_0_0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -66,7 +66,7 @@ def _CircularArc_100_0_10_0_0_0__0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -97,7 +97,7 @@ def _CircularArc_100_0_10_0_0_5_0_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -128,7 +128,7 @@ def _CircularArc_100_0_10_0__0_5_0_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -159,7 +159,7 @@ def _CircularArc_100_0_10_0_0_5_1_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -192,7 +192,7 @@ def _CircularArc_100_0_10_0__0_5__1_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -225,7 +225,7 @@ def _CircularArc_100_0_10_0_1_0_0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -258,7 +258,7 @@ def _CircularArc_100_0_10_0__1_0__0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -291,7 +291,7 @@ def _ConstantGradient_100_0_10_0_0_0_0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -320,7 +320,7 @@ def _ConstantGradient_100_0_10_0_0_0__0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -349,7 +349,7 @@ def _ConstantGradient_100_0_10_0_0_5_0_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -380,7 +380,7 @@ def _ConstantGradient_100_0_10_0__0_5_0_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -411,7 +411,7 @@ def _ConstantGradient_100_0_10_0_0_5_1_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -442,7 +442,7 @@ def _ConstantGradient_100_0_10_0__0_5__1_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -473,7 +473,7 @@ def _ConstantGradient_100_0_10_0_1_0_0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -504,7 +504,7 @@ def _ConstantGradient_100_0_10_0__1_0__0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -535,7 +535,7 @@ def _ParabolicArc_100_0_10_0_0_0_0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -564,7 +564,7 @@ def _ParabolicArc_100_0_10_0_0_0__0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -593,7 +593,7 @@ def _ParabolicArc_100_0_10_0_0_5_0_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -624,7 +624,7 @@ def _ParabolicArc_100_0_10_0__0_5_0_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -655,7 +655,7 @@ def _ParabolicArc_100_0_10_0_0_5_1_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -665,7 +665,7 @@ def _ParabolicArc_100_0_10_0_0_5_1_0_1_Meter(file): (0.894427190999916, 0.447213595499958) ) assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(125.53583325398947) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(125.53583299580873) assert mapped_segment.ParentCurve.is_a("IfcPolynomialCurve") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) assert mapped_segment.ParentCurve.CoefficientsX == pytest.approx((0.0, 1.0)) @@ -686,7 +686,7 @@ def _ParabolicArc_100_0_10_0__0_5__1_0_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -696,7 +696,7 @@ def _ParabolicArc_100_0_10_0__0_5__1_0_1_Meter(file): (0.894427190999916, -0.447213595499958) ) assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(125.53583325398947) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(125.53583299580873) assert mapped_segment.ParentCurve.is_a("IfcPolynomialCurve") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) assert mapped_segment.ParentCurve.CoefficientsX == pytest.approx((0.0, 1.0)) @@ -717,7 +717,7 @@ def _ParabolicArc_100_0_10_0_1_0_0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -727,7 +727,7 @@ def _ParabolicArc_100_0_10_0_1_0_0_5_1_Meter(file): (0.707106781186547, 0.707106781186547) ) assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(125.53583325398947) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(125.53583299580873) assert mapped_segment.ParentCurve.is_a("IfcPolynomialCurve") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) assert mapped_segment.ParentCurve.CoefficientsX == pytest.approx((0.0, 1.0)) @@ -748,7 +748,7 @@ def _ParabolicArc_100_0_10_0__1_0__0_5_1_Meter(file): GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters ) - mapped_segments = ifcopenshell.api.alignment.map_alignment_segment(file, alignment_segment) + mapped_segments = ifcopenshell.api.alignment.map_alignment_vertical_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert mapped_segments[1] == None @@ -758,7 +758,7 @@ def _ParabolicArc_100_0_10_0__1_0__0_5_1_Meter(file): (0.707106781186547, -0.707106781186547) ) assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(125.53583325398947) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(125.53583299580873) assert mapped_segment.ParentCurve.is_a("IfcPolynomialCurve") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) assert mapped_segment.ParentCurve.CoefficientsX == pytest.approx((0.0, 1.0))