def test_join_segments_multiple_pline(): """Test the join_segments method with multiple polylines.""" pts = (Point3D(0, 0), Point3D(2, 0), Point3D(2, 2), Point3D(0, 2)) extra_pts = (Point3D(3, 3), Point3D(4, 3), Point3D(4, 4), Point3D(3, 4)) l_segs = (LineSegment3D.from_end_points(extra_pts[0], extra_pts[1]), LineSegment3D.from_end_points(pts[0], pts[1]), LineSegment3D.from_end_points(pts[1], pts[2]), LineSegment3D.from_end_points(pts[0], pts[3]), LineSegment3D.from_end_points(pts[3], pts[2])) p_lines = Polyline3D.join_segments(l_segs, 0.01) assert len(p_lines) == 2 l_segs = (LineSegment3D.from_end_points(extra_pts[0], extra_pts[1]), LineSegment3D.from_end_points(pts[0], pts[1]), LineSegment3D.from_end_points(pts[1], pts[2]), LineSegment3D.from_end_points(pts[0], pts[3]), LineSegment3D.from_end_points(pts[3], pts[2]), LineSegment3D.from_end_points(extra_pts[2], extra_pts[3]), LineSegment3D.from_end_points(extra_pts[1], extra_pts[2]), LineSegment3D.from_end_points(extra_pts[0], extra_pts[3])) p_lines = Polyline3D.join_segments(l_segs, 0.01) assert len(p_lines) == 2 for p_line in p_lines: assert isinstance(p_line, Polyline3D) assert len(p_line) == 5 assert p_line.is_closed(0.01)
def test_join_segments(): """Test the join_segments method.""" pts = (Point3D(0, 0), Point3D(2, 0), Point3D(2, 2), Point3D(0, 2)) l_segs = (LineSegment3D.from_end_points(pts[0], pts[1]), LineSegment3D.from_end_points(pts[1], pts[2]), LineSegment3D.from_end_points(pts[2], pts[3]), LineSegment3D.from_end_points(pts[3], pts[0])) p_lines = Polyline3D.join_segments(l_segs, 0.01) assert len(p_lines) == 1 assert isinstance(p_lines[0], Polyline3D) assert len(p_lines[0]) == 5 assert p_lines[0].is_closed(0.01) l_segs = (LineSegment3D.from_end_points(pts[0], pts[1]), LineSegment3D.from_end_points(pts[2], pts[3]), LineSegment3D.from_end_points(pts[1], pts[2]), LineSegment3D.from_end_points(pts[3], pts[0])) p_lines = Polyline3D.join_segments(l_segs, 0.01) assert len(p_lines) == 1 assert isinstance(p_lines[0], Polyline3D) assert len(p_lines[0]) == 5 assert p_lines[0].is_closed(0.01) l_segs = (LineSegment3D.from_end_points(pts[0], pts[1]), LineSegment3D.from_end_points(pts[1], pts[2]), LineSegment3D.from_end_points(pts[0], pts[3]), LineSegment3D.from_end_points(pts[3], pts[2])) p_lines = Polyline3D.join_segments(l_segs, 0.01) assert len(p_lines) == 1 assert isinstance(p_lines[0], Polyline3D) assert len(p_lines[0]) == 5 assert p_lines[0].is_closed(0.01)
def test_join_segments_disconnected(): """Test the join_segments method with diconnected polylines.""" pts = (Point3D(0, 0), Point3D(2, 0), Point3D(2, 2), Point3D(0, 2)) extra_pts = (Point3D(3, 3), Point3D(4, 3), Point3D(4, 4), Point3D(3, 4)) l_segs = (LineSegment3D.from_end_points(extra_pts[0], extra_pts[1]), LineSegment3D.from_end_points(pts[0], pts[1]), LineSegment3D.from_end_points(pts[2], pts[3]), LineSegment3D.from_end_points(extra_pts[3], extra_pts[2])) p_lines = Polyline3D.join_segments(l_segs, 0.01) assert len(p_lines) == 4
def outline_polylines(self, tolerance=0.01): """Get a list of Polyline3D objects for the outline of the floor plate. Note that these segments include both the boundary surrounding the floor and any holes for courtyards that exist within the floor. Args: tolerance: The minimum distance between points at which they are not considered touching. Default: 0.01, suitable for objects in meters. """ return Polyline3D.join_segments(self.outline_segments(tolerance), tolerance)