diff --git a/src/build123d/topology/one_d.py b/src/build123d/topology/one_d.py index 0964721..27f9b11 100644 --- a/src/build123d/topology/one_d.py +++ b/src/build123d/topology/one_d.py @@ -305,7 +305,9 @@ class Mixin1D(Shape[TOPODS]): @property def length(self) -> float: """Edge or Wire length""" - return GCPnts_AbscissaPoint.Length_s(self.geom_adaptor()) + props = GProp_GProps() + BRepGProp.LinearProperties_s(self.wrapped, props) + return props.Mass() @property def radius(self) -> float: @@ -796,19 +798,20 @@ class Mixin1D(Shape[TOPODS]): for obj in common_set: match (obj, target): case (_, Plane()): + assert isinstance(other.wrapped, gp_Pln) target = Shape(BRepBuilderAPI_MakeFace(other.wrapped).Face()) - operation = BRepAlgoAPI_Section() - result = bool_op((obj,), (target,), operation) - operation = BRepAlgoAPI_Common() - result.extend(bool_op((obj,), (target,), operation)) + operation1 = BRepAlgoAPI_Section() + result = bool_op((obj,), (target,), operation1) + operation2 = BRepAlgoAPI_Common() + result.extend(bool_op((obj,), (target,), operation2)) case (_, Vertex() | Edge() | Wire()): - operation = BRepAlgoAPI_Section() - section = bool_op((obj,), (target,), operation) + operation1 = BRepAlgoAPI_Section() + section = bool_op((obj,), (target,), operation1) result = section if not section: - operation = BRepAlgoAPI_Common() - result.extend(bool_op((obj,), (target,), operation)) + operation2 = BRepAlgoAPI_Common() + result.extend(bool_op((obj,), (target,), operation2)) case _ if issubclass(type(target), Shape): result = target.intersect(obj) @@ -2940,7 +2943,7 @@ class Edge(Mixin1D[TopoDS_Edge]): topods_edge = BRepBuilderAPI_MakeEdge(curve.Reversed(), last, first).Edge() reversed_edge.wrapped = topods_edge else: - reversed_edge.wrapped = downcast(self.wrapped.Reversed()) + reversed_edge.wrapped = TopoDS.Edge_s(self.wrapped.Reversed()) return reversed_edge def to_axis(self) -> Axis: diff --git a/tests/test_build_line.py b/tests/test_build_line.py index be4cd8d..ae7364a 100644 --- a/tests/test_build_line.py +++ b/tests/test_build_line.py @@ -98,14 +98,14 @@ class BuildLineTests(unittest.TestCase): powerup @ 0, tangents=(screw % 1, powerup % 0), ) - self.assertAlmostEqual(roller_coaster.wires()[0].length, 678.983628932414, 5) + self.assertAlmostEqual(roller_coaster.wires()[0].length, 678.9785865257071, 5) def test_bezier(self): pts = [(0, 0), (20, 20), (40, 0), (0, -40), (-60, 0), (0, 100), (100, 0)] wts = [1.0, 1.0, 2.0, 3.0, 4.0, 2.0, 1.0] with BuildLine() as bz: b1 = Bezier(*pts, weights=wts) - self.assertAlmostEqual(bz.wires()[0].length, 225.86389406824566, 5) + self.assertAlmostEqual(bz.wires()[0].length, 225.98661946375782, 5) self.assertTrue(isinstance(b1, Edge)) def test_double_tangent_arc(self):