mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
black .
This commit is contained in:
@@ -22,11 +22,12 @@ import ifcopenshell.api.context
|
||||
|
||||
from ifcopenshell.api.alignment._add_segment_to_layout import _add_segment_to_layout
|
||||
|
||||
|
||||
def test_add_segment_to_layout():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,7 +37,7 @@ def test_add_segment_to_layout():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"")
|
||||
alignment = ifcopenshell.api.alignment.create(file, "")
|
||||
horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
|
||||
design_parameters = file.create_entity(
|
||||
@@ -66,6 +67,10 @@ def test_add_segment_to_layout():
|
||||
_add_segment_to_layout(file, horizontal_alignment, alignment_segment)
|
||||
|
||||
assert len(horizontal_alignment.IsNestedBy) == 1
|
||||
assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2 # The the segment we added and the automatically created zero length segment
|
||||
assert (
|
||||
len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2
|
||||
) # The the segment we added and the automatically created zero length segment
|
||||
assert horizontal_alignment.IsNestedBy[0].RelatedObjects[0] == alignment_segment
|
||||
assert alignment_segment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent") # a referent is automatically added at the start of the segment
|
||||
assert (
|
||||
alignment_segment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
) # a referent is automatically added at the start of the segment
|
||||
|
||||
@@ -21,11 +21,12 @@ import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def test_add_stationing_to_alignment():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -35,9 +36,7 @@ def test_add_stationing_to_alignment():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(
|
||||
file, "TestAlignment", start_station=2000.
|
||||
)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", start_station=2000.0)
|
||||
|
||||
for rel in alignment.IsNestedBy:
|
||||
for referent in rel.RelatedObjects:
|
||||
|
||||
@@ -23,9 +23,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_add_vertical_alignment():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -35,7 +35,7 @@ def test_add_vertical_alignment():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"A1",include_vertical=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "A1", include_vertical=False)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 1 # one nest
|
||||
@@ -45,11 +45,13 @@ def test_add_vertical_alignment():
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file,alignment)
|
||||
vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file, alignment)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 1 # one nest
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical")
|
||||
@@ -57,7 +59,7 @@ def test_add_vertical_alignment():
|
||||
assert curve.is_a("IfcGradientCurve")
|
||||
|
||||
# add a second vertical alignment
|
||||
vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file,alignment)
|
||||
vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file, alignment)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 1 # 1 IfcRelAggreates relationship for the child algiments
|
||||
assert (
|
||||
@@ -75,4 +77,5 @@ def test_add_vertical_alignment():
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal")
|
||||
|
||||
test_add_vertical_alignment()
|
||||
|
||||
test_add_vertical_alignment()
|
||||
|
||||
@@ -24,9 +24,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_create_alignment():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,34 +36,36 @@ def test_create_alignment():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
include_vertical = [False,True,True]
|
||||
include_vertical = [False, True, True]
|
||||
include_cant = [False, False, True]
|
||||
expected_curve_type = ["IfcCompositeCurve","IfcGradientCurve","IfcSegmentedReferenceCurve"]
|
||||
expected_curve_type = ["IfcCompositeCurve", "IfcGradientCurve", "IfcSegmentedReferenceCurve"]
|
||||
|
||||
for i in range(0,3) :
|
||||
ali = ifcopenshell.api.alignment.create(file,"A1",include_vertical[i],include_cant[i])
|
||||
for i in range(0, 3):
|
||||
ali = ifcopenshell.api.alignment.create(file, "A1", include_vertical[i], include_cant[i])
|
||||
assert ali != None
|
||||
|
||||
# verify the geometric representation was created
|
||||
curve = ifcopenshell.api.alignment.get_curve(ali)
|
||||
assert(curve.is_a() == expected_curve_type[i])
|
||||
assert curve.is_a() == expected_curve_type[i]
|
||||
assert len(curve.Segments) == 1
|
||||
|
||||
horiz = ifcopenshell.api.alignment.get_horizontal_layout(ali)
|
||||
vert = ifcopenshell.api.alignment.get_vertical_layout(ali)
|
||||
cant = ifcopenshell.api.alignment.get_cant_layout(ali)
|
||||
|
||||
|
||||
assert horiz != None
|
||||
if include_vertical[i]:
|
||||
assert vert != None
|
||||
|
||||
|
||||
if include_cant[i]:
|
||||
assert cant != None
|
||||
|
||||
# verify each layout has a zero length segment (which also tests if the geometry curve has a zero length segment)
|
||||
alignments = [horiz,vert,cant]
|
||||
alignments = [horiz, vert, cant]
|
||||
for a in alignments:
|
||||
if a != None:
|
||||
segments = ifcopenshell.api.alignment.get_layout_segments(a)
|
||||
assert len(segments) == 1
|
||||
assert ifcopenshell.api.alignment.has_zero_length_segment(a) # there is a check in this function for the geometry curve
|
||||
assert ifcopenshell.api.alignment.has_zero_length_segment(
|
||||
a
|
||||
) # there is a check in this function for the geometry curve
|
||||
|
||||
@@ -23,9 +23,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_create_alignment_pi_method():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -40,18 +40,27 @@ def test_create_alignment_pi_method():
|
||||
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_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints, lengths)
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths
|
||||
)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 1 # one nest
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical")
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1
|
||||
) # nesting of segments beneath IfcAlignmentHorizontal
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 8 # segments in horizontal layout
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 10 # segments in vertical layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 8
|
||||
) # segments in horizontal layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 10
|
||||
) # segments in vertical layout
|
||||
|
||||
test_create_alignment_pi_method()
|
||||
|
||||
test_create_alignment_pi_method()
|
||||
|
||||
@@ -22,11 +22,12 @@ import ifcopenshell.api.context
|
||||
from ifcopenshell import entity_instance
|
||||
import math
|
||||
|
||||
|
||||
def _test_horizontal() -> ifcopenshell.file:
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -37,13 +38,13 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
)
|
||||
|
||||
# creates an IfcAlignment with an IfcAlignmentHorizontal layout containing only the zero length segment
|
||||
ali = ifcopenshell.api.alignment.create(file,"A1")
|
||||
ali = ifcopenshell.api.alignment.create(file, "A1")
|
||||
|
||||
# append a segment to the horizontal layout
|
||||
horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(ali)
|
||||
|
||||
curve = ifcopenshell.api.alignment.get_curve(horizontal_alignment)
|
||||
assert curve == None # for single horizontal, geometric representation is on IfcAlignment
|
||||
assert curve == None # for single horizontal, geometric representation is on IfcAlignment
|
||||
curve = ifcopenshell.api.alignment.get_curve(ali)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
assert len(curve.Segments) == 1
|
||||
@@ -60,14 +61,14 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
GravityCenterLineHeight=None,
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters)
|
||||
|
||||
assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 100.0
|
||||
assert y == 0.0
|
||||
assert z == 0.0
|
||||
@@ -76,13 +77,12 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
assert len(curve.Segments) == 2
|
||||
|
||||
|
||||
design_parameters = file.create_entity(
|
||||
type="IfcAlignmentHorizontalSegment",
|
||||
StartTag=None,
|
||||
EndTag=None,
|
||||
StartPoint=file.createIfcCartesianPoint(Coordinates=((x.item(), y.item()))),
|
||||
StartDirection=math.pi/6,
|
||||
StartDirection=math.pi / 6,
|
||||
StartRadiusOfCurvature=0.0,
|
||||
EndRadiusOfCurvature=0.0,
|
||||
SegmentLength=50.0,
|
||||
@@ -90,15 +90,15 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters)
|
||||
assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 100.0 + 50.0*math.cos(math.pi/6)
|
||||
assert y == 50.0*math.sin(math.pi/6)
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 100.0 + 50.0 * math.cos(math.pi / 6)
|
||||
assert y == 50.0 * math.sin(math.pi / 6)
|
||||
assert z == 0.0
|
||||
|
||||
curve = ifcopenshell.api.alignment.get_curve(ali)
|
||||
@@ -110,9 +110,9 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
|
||||
def _test_horizontal_vertical():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -123,7 +123,7 @@ def _test_horizontal_vertical():
|
||||
)
|
||||
|
||||
# creates an IfcAlignment with an IfcAlignmentHorizontal layout containing only the zero length segment
|
||||
ali = ifcopenshell.api.alignment.create(file,"A1",True)
|
||||
ali = ifcopenshell.api.alignment.create(file, "A1", True)
|
||||
|
||||
# append a segment to the horizontal layout
|
||||
horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(ali)
|
||||
@@ -154,53 +154,53 @@ def _test_horizontal_vertical():
|
||||
GravityCenterLineHeight=None,
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters)
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(ali)
|
||||
assert basis_curve.is_a("IfcCompositeCurve")
|
||||
assert len(basis_curve.Segments) == 2
|
||||
|
||||
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=0.0,
|
||||
HorizontalLength=50.0,
|
||||
StartHeight=20.0,
|
||||
StartGradient = 1./100.,
|
||||
EndGradient = 1./100.,
|
||||
PredefinedType="CONSTANTGRADIENT"
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters)
|
||||
StartGradient=1.0 / 100.0,
|
||||
EndGradient=1.0 / 100.0,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters)
|
||||
|
||||
assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 2
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 50.
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 50.0
|
||||
assert y == 20.5
|
||||
assert z == 0.0
|
||||
|
||||
dx = end[0,0]
|
||||
dy = end[1,0]
|
||||
gradient = dy/dx
|
||||
dx = end[0, 0]
|
||||
dy = end[1, 0]
|
||||
gradient = dy / dx
|
||||
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=50.0,
|
||||
HorizontalLength=50.0,
|
||||
StartHeight=y.item(),
|
||||
StartGradient = -gradient,
|
||||
EndGradient = -gradient,
|
||||
PredefinedType="CONSTANTGRADIENT"
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters)
|
||||
StartGradient=-gradient,
|
||||
EndGradient=-gradient,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters)
|
||||
|
||||
assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 100.
|
||||
assert y == 20.
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 100.0
|
||||
assert y == 20.0
|
||||
assert z == 0.0
|
||||
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(ali)
|
||||
@@ -216,60 +216,62 @@ def _test_horizontal_vertical2(file: ifcopenshell.file):
|
||||
|
||||
vertical_alignment = ifcopenshell.api.alignment.get_vertical_layout(ali)
|
||||
assert vertical_alignment == None
|
||||
|
||||
vertical_alignment = ifcopenshell.api.alignment.add_vertical_layout(file,ali)
|
||||
|
||||
vertical_alignment = ifcopenshell.api.alignment.add_vertical_layout(file, ali)
|
||||
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=0.0,
|
||||
HorizontalLength=50.0,
|
||||
StartHeight=20.0,
|
||||
StartGradient = 1./100.,
|
||||
EndGradient = 1./100.,
|
||||
PredefinedType="CONSTANTGRADIENT"
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters)
|
||||
StartGradient=1.0 / 100.0,
|
||||
EndGradient=1.0 / 100.0,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters)
|
||||
|
||||
assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 2
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 50.
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 50.0
|
||||
assert y == 20.5
|
||||
assert z == 0.0
|
||||
|
||||
dx = end[0,0]
|
||||
dy = end[1,0]
|
||||
gradient = dy/dx
|
||||
dx = end[0, 0]
|
||||
dy = end[1, 0]
|
||||
gradient = dy / dx
|
||||
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=50.0,
|
||||
HorizontalLength=50.0,
|
||||
StartHeight=y.item(),
|
||||
StartGradient = -gradient,
|
||||
EndGradient = -gradient,
|
||||
PredefinedType="CONSTANTGRADIENT"
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters)
|
||||
StartGradient=-gradient,
|
||||
EndGradient=-gradient,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters)
|
||||
|
||||
assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 100.
|
||||
assert y == 20.
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 100.0
|
||||
assert y == 20.0
|
||||
assert z == 0.0
|
||||
|
||||
curve = ifcopenshell.api.alignment.get_curve(ali)
|
||||
assert curve.is_a("IfcGradientCurve")
|
||||
assert len(curve.Segments) == 3
|
||||
|
||||
|
||||
def test_append_segment():
|
||||
file = _test_horizontal()
|
||||
_test_horizontal_vertical()
|
||||
_test_horizontal_vertical2(file)
|
||||
|
||||
test_append_segment()
|
||||
|
||||
test_append_segment()
|
||||
|
||||
@@ -20,11 +20,12 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
def test_distance_along_from_station():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -40,7 +41,7 @@ def test_distance_along_from_station():
|
||||
lengths = [(1600.0), (1200.0), (2000.0), (800.0)]
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths,start_station=10000.0
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths, start_station=10000.0
|
||||
)
|
||||
|
||||
# Station 138+83.96
|
||||
@@ -50,4 +51,4 @@ def test_distance_along_from_station():
|
||||
assert ifcopenshell.api.alignment.distance_along_from_station(file, alignment, 17525.36) == pytest.approx(7525.36)
|
||||
|
||||
|
||||
test_distance_along_from_station()
|
||||
test_distance_along_from_station()
|
||||
|
||||
@@ -23,9 +23,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_get_alignment():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -35,11 +35,11 @@ def test_get_alignment():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
include_vertical = [False,True,True]
|
||||
include_vertical = [False, True, True]
|
||||
include_cant = [False, False, True]
|
||||
|
||||
for i in range(0,3) :
|
||||
ali = ifcopenshell.api.alignment.create(file,"A1",include_vertical[i],include_cant[i])
|
||||
for i in range(0, 3):
|
||||
ali = ifcopenshell.api.alignment.create(file, "A1", include_vertical[i], include_cant[i])
|
||||
assert ali != None
|
||||
|
||||
horiz = ifcopenshell.api.alignment.get_horizontal_layout(ali)
|
||||
@@ -49,6 +49,6 @@ def test_get_alignment():
|
||||
assert ali == ifcopenshell.api.alignment.get_alignment(horiz)
|
||||
if include_vertical[i]:
|
||||
assert ali == ifcopenshell.api.alignment.get_alignment(vert)
|
||||
|
||||
|
||||
if include_cant[i]:
|
||||
assert ali == ifcopenshell.api.alignment.get_alignment(cant)
|
||||
|
||||
@@ -24,9 +24,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def _test_horizontal():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -43,9 +43,9 @@ def _test_horizontal():
|
||||
|
||||
def _test_horizontal_and_vertical():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -55,17 +55,16 @@ def _test_horizontal_and_vertical():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(
|
||||
file, "TestAlignment", include_vertical=True
|
||||
)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True)
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment)
|
||||
assert basis_curve.is_a("IfcCompositeCurve")
|
||||
|
||||
|
||||
def _test_horizontal_and_vertical_and_cant():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -75,12 +74,11 @@ def _test_horizontal_and_vertical_and_cant():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(
|
||||
file, "TestAlignment", include_vertical=True,include_cant=True
|
||||
)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment)
|
||||
assert basis_curve.is_a("IfcCompositeCurve")
|
||||
|
||||
|
||||
def test_get_basis_curve():
|
||||
_test_horizontal()
|
||||
_test_horizontal_and_vertical()
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
import ifcopenshell.api.alignment
|
||||
|
||||
|
||||
def test_get_curve():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -32,14 +33,14 @@ def test_get_curve():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=False,include_cant=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=False, include_cant=False)
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=False)
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcGradientCurve")
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=True)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcSegmentedReferenceCurve")
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
import ifcopenshell.api.alignment
|
||||
|
||||
|
||||
def test_get_layout_curve():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -32,12 +33,12 @@ def test_get_layout_curve():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=False,include_cant=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=False, include_cant=False)
|
||||
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=False)
|
||||
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
@@ -45,7 +46,7 @@ def test_get_layout_curve():
|
||||
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
||||
assert curve.is_a("IfcGradientCurve")
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=True)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
||||
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
@@ -20,11 +20,12 @@ import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.alignment.has_zero_length_segment
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
def _test_horizontal():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -34,15 +35,16 @@ def _test_horizontal():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"TestAlignment")
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment")
|
||||
horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal)
|
||||
|
||||
|
||||
def _test_horizontal_vertical():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -52,17 +54,18 @@ def _test_horizontal_vertical():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"TestAlignment",include_vertical=True)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True)
|
||||
horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal)
|
||||
vertical = ifcopenshell.api.alignment.get_vertical_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(vertical)
|
||||
|
||||
|
||||
def _test_horizontal_vertical_cant():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -72,7 +75,7 @@ def _test_horizontal_vertical_cant():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"TestAlignment",include_vertical=True,include_cant=True)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
||||
horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal)
|
||||
vertical = ifcopenshell.api.alignment.get_vertical_layout(alignment)
|
||||
@@ -80,10 +83,11 @@ def _test_horizontal_vertical_cant():
|
||||
cant = ifcopenshell.api.alignment.get_cant_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(cant)
|
||||
|
||||
|
||||
def test_has_zero_length_segment():
|
||||
_test_horizontal()
|
||||
_test_horizontal_vertical()
|
||||
_test_horizontal_vertical_cant()
|
||||
|
||||
|
||||
test_has_zero_length_segment()
|
||||
test_has_zero_length_segment()
|
||||
|
||||
@@ -20,14 +20,15 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
# other test cases cover the typical vertical by PI method (test_create_alignment_by_pi_method)
|
||||
# this test will focus on the edge cases of no initial tangent run, no final tangent run, and
|
||||
# compound curve (no tangent between curves)
|
||||
def test_horizontal_layout_by_pi_method():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -50,6 +51,9 @@ def test_horizontal_layout_by_pi_method():
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1
|
||||
) # nesting of segments beneath IfcAlignmentHorizontal
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 3 # segments in horizontal layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 3
|
||||
) # segments in horizontal layout
|
||||
|
||||
test_horizontal_layout_by_pi_method()
|
||||
|
||||
test_horizontal_layout_by_pi_method()
|
||||
|
||||
@@ -21,6 +21,7 @@ import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
from ifcopenshell.api.alignment._map_alignment_cant_segment import _map_alignment_cant_segment
|
||||
|
||||
|
||||
def _BlossCurve_100_0_300_1000_1_Meter(file):
|
||||
design_parameters = file.createIfcAlignmentCantSegment(
|
||||
StartDistAlong=0.0,
|
||||
|
||||
@@ -23,6 +23,7 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
from ifcopenshell.api.alignment._map_alignment_horizontal_segment import __map_alignment_horizontal_segment
|
||||
|
||||
|
||||
def _BlossCurve_100_0_300_1000_1_Meter(file):
|
||||
design_parameters = file.createIfcAlignmentHorizontalSegment(
|
||||
StartPoint=file.createIfcCartesianPoint((0.0, 0.0)),
|
||||
|
||||
@@ -23,6 +23,7 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
from ifcopenshell.api.alignment._map_alignment_vertical_segment import _map_alignment_vertical_segment
|
||||
|
||||
|
||||
def _CircularArc_100_0_10_0_0_0_0_5_1_Meter(file):
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=0.0,
|
||||
|
||||
@@ -23,9 +23,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_name_segments():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
|
||||
@@ -42,8 +42,9 @@ def default_names_alignment():
|
||||
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_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints,
|
||||
lengths)
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths
|
||||
)
|
||||
yield alignment
|
||||
|
||||
|
||||
@@ -88,8 +89,9 @@ def callback_alignment():
|
||||
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_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints,
|
||||
lengths)
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths
|
||||
)
|
||||
yield alignment
|
||||
|
||||
|
||||
@@ -108,6 +110,7 @@ def test_with_default_names(default_names_alignment):
|
||||
assert "P.V.T." in vlayout.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects[0].Name
|
||||
assert "V.P.O.E." in vlayout.IsNestedBy[0].RelatedObjects[-1].IsNestedBy[0].RelatedObjects[0].Name
|
||||
|
||||
|
||||
def test_with_callbacks(callback_alignment):
|
||||
hlayout = ifcopenshell.api.alignment.get_horizontal_layout(callback_alignment)
|
||||
|
||||
|
||||
+13
-10
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
from ifcopenshell.api.alignment._update_curve_segment_transition_code import _update_curve_segment_transition_code
|
||||
from ifcopenshell.api.alignment._update_curve_segment_transition_code import _update_curve_segment_transition_code
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
def _test1():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -223,18 +223,20 @@ def _test2():
|
||||
),
|
||||
)
|
||||
|
||||
composite_curve = file.createIfcCompositeCurve(Segments=[line1,clothoid1,circular_arc,clothoid2,line2], SelfIntersect=False)
|
||||
composite_curve = file.createIfcCompositeCurve(
|
||||
Segments=[line1, clothoid1, circular_arc, clothoid2, line2], SelfIntersect=False
|
||||
)
|
||||
|
||||
_update_curve_segment_transition_code(line1,clothoid1)
|
||||
_update_curve_segment_transition_code(line1, clothoid1)
|
||||
assert line1.Transition == "CONTSAMEGRADIENTSAMECURVATURE"
|
||||
|
||||
_update_curve_segment_transition_code(clothoid1,circular_arc)
|
||||
_update_curve_segment_transition_code(clothoid1, circular_arc)
|
||||
assert clothoid1.Transition == "CONTSAMEGRADIENTSAMECURVATURE"
|
||||
|
||||
_update_curve_segment_transition_code(circular_arc,clothoid2)
|
||||
_update_curve_segment_transition_code(circular_arc, clothoid2)
|
||||
assert circular_arc.Transition == "CONTSAMEGRADIENTSAMECURVATURE"
|
||||
|
||||
_update_curve_segment_transition_code(clothoid2,line2)
|
||||
_update_curve_segment_transition_code(clothoid2, line2)
|
||||
assert clothoid2.Transition == "CONTSAMEGRADIENTSAMECURVATURE"
|
||||
|
||||
|
||||
@@ -242,4 +244,5 @@ def test_update_curve_segment_transition_code():
|
||||
_test1()
|
||||
_test2()
|
||||
|
||||
test_update_curve_segment_transition_code()
|
||||
|
||||
test_update_curve_segment_transition_code()
|
||||
|
||||
@@ -20,14 +20,15 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
# other test cases cover the typical vertical by PI method (test_create_alignment_by_pi_method)
|
||||
# this test will focus on the edge cases of no initial gradient, no final gradient, and
|
||||
# compound vertical curve (no gradient between curves)
|
||||
def test_vertical_layout_by_pi_method():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -37,35 +38,41 @@ def test_vertical_layout_by_pi_method():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True)
|
||||
hlayout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
segment1 = file.createIfcAlignmentHorizontalSegment(
|
||||
StartPoint=file.createIfcCartesianPoint(Coordinates=((0.,0.))), # Actual coordinate unknown
|
||||
StartPoint=file.createIfcCartesianPoint(Coordinates=((0.0, 0.0))), # Actual coordinate unknown
|
||||
StartDirection=0.0,
|
||||
StartRadiusOfCurvature=0.0,
|
||||
EndRadiusOfCurvature=0.0,
|
||||
SegmentLength=10000.0,
|
||||
PredefinedType = "LINE"
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
|
||||
ifcopenshell.api.alignment.create_layout_segment(file,hlayout,segment1)
|
||||
ifcopenshell.api.alignment.create_layout_segment(file, hlayout, segment1)
|
||||
|
||||
vpoints = [(0.0, 110.0), (400.0, 100.0), (800.0, 115.0), (1300.0, 125.0), (1800.0, 105.0)]
|
||||
lengths = [(800.0), (0.0), (1000.0)]
|
||||
vlayout = ifcopenshell.api.alignment.get_vertical_layout(alignment)
|
||||
ifcopenshell.api.alignment.layout_vertical_alignment_by_pi_method(file,vlayout,vpoints,lengths)
|
||||
ifcopenshell.api.alignment.layout_vertical_alignment_by_pi_method(file, vlayout, vpoints, lengths)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 1 # one nest
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical")
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1
|
||||
) # nesting of segments beneath IfcAlignmentHorizontal
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 2 # segments in horizontal layout
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 3 # segments in vertical layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 2
|
||||
) # segments in horizontal layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 3
|
||||
) # segments in vertical layout
|
||||
|
||||
test_vertical_layout_by_pi_method()
|
||||
|
||||
test_vertical_layout_by_pi_method()
|
||||
|
||||
@@ -25,8 +25,8 @@ import ifcopenshell.api.cogo
|
||||
def test_add_survey_point():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(Name="Test")
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site])
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,10 +36,9 @@ def test_add_survey_point():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0)))
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0)))
|
||||
assert annotation
|
||||
assert annotation.PredefinedType == "SURVEY"
|
||||
assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation"
|
||||
assert annotation.Representation.Representations[0].RepresentationType == "Point"
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0))
|
||||
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0))
|
||||
|
||||
@@ -25,8 +25,8 @@ import ifcopenshell.api.cogo
|
||||
def test_assign_survey_point():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(Name="Test")
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site])
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,13 +36,12 @@ def test_assign_survey_point():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0)))
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0)))
|
||||
assert annotation
|
||||
assert annotation.PredefinedType == "SURVEY"
|
||||
assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation"
|
||||
assert annotation.Representation.Representations[0].RepresentationType == "Point"
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0))
|
||||
|
||||
ifcopenshell.api.cogo.assign_survey_point(annotation,file.createIfcCartesianPoint((20.0,30.0,40.0)))
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0,30.0,40.0))
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0))
|
||||
|
||||
ifcopenshell.api.cogo.assign_survey_point(annotation, file.createIfcCartesianPoint((20.0, 30.0, 40.0)))
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0, 30.0, 40.0))
|
||||
|
||||
@@ -35,39 +35,39 @@ def test_bearing2dd():
|
||||
assert 0.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 E"))
|
||||
assert 0.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 E"))
|
||||
|
||||
assert 180. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 W"))
|
||||
assert 180. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 W"))
|
||||
|
||||
assert 120. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 W"))
|
||||
assert 180.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 W"))
|
||||
assert 180.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 W"))
|
||||
|
||||
assert 120.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 W"))
|
||||
assert 120.16666666666667 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 10 W"))
|
||||
|
||||
assert 89.999722222222228 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 00 00 1 E"))
|
||||
assert 89.99972222222222 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 0 0 1 E"))
|
||||
assert 89.99972222222222 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 00 00 1.0 E"))
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("Bad String")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("Very Bad String")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 100 15 22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N -45 15 22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 45 -15 22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 45 88 22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 45 15 -22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 45 15 99.5 E")
|
||||
|
||||
test_bearing2dd()
|
||||
|
||||
test_bearing2dd()
|
||||
|
||||
@@ -25,8 +25,8 @@ import ifcopenshell.api.cogo
|
||||
def test_edit_survey_point():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(Name="Test")
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site])
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,13 +36,12 @@ def test_edit_survey_point():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0)))
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0)))
|
||||
assert annotation
|
||||
assert annotation.PredefinedType == "SURVEY"
|
||||
assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation"
|
||||
assert annotation.Representation.Representations[0].RepresentationType == "Point"
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0))
|
||||
|
||||
ifcopenshell.api.cogo.edit_survey_point(annotation,20.0,30.0)
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0,30.0))
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0))
|
||||
|
||||
ifcopenshell.api.cogo.edit_survey_point(annotation, 20.0, 30.0)
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0, 30.0))
|
||||
|
||||
Reference in New Issue
Block a user