D3.2 2D data

Cutting Data

We can connect the points in sequence to create the polygon.

# join two polylines
points_T = polyline_i_T.points + polyline_o_T.points[::-1]
polygon_T = Polygon(points_T)
polygonartist = PolygonArtist(polygon_T, layer="DF2021:: Beam:: Seam:: XY")
polygonartist.clear_layer()
polygonartist.draw(show_points=False, show_edges=True, show_face=False)

points = polyline.points + polyline_o.points[::-1]
polygon = Polygon(points)
polygonartist = PolygonArtist(polygon, layer="DF2021:: Beam:: Seam:: local")
polygonartist.clear_layer()
polygonartist.draw(show_points=False, show_edges=True, show_face=False)

2D Mesh

Since we have the points along the curve in sequece, we can easily find four points in the segment of the polyline and its offset polyline to create faces: start point of the segment, end point of the segment, end point of the offset segment, start point of the offset segment.

# generate 2d mesh
vertices_T = polyline_i_T.points + polyline_o_T.points
faces = []
length = len(polyline.points)
for i in range(length - 1):
    faces.append([i, i + 1, length + i + 1, length + i])
beam_2d_T = Mesh.from_vertices_and_faces(vertices_T, faces)

meshartist = MeshArtist(beam_2d_T, layer="DF2021:: Beam:: Seam:: XY_mesh")
meshartist.clear_layer()
meshartist.draw_faces(join_faces=True)
meshartist.draw_edges()

vertices = polyline.points + polyline_o.points
beam_2d = Mesh.from_vertices_and_faces(vertices, faces)

meshartist = MeshArtist(beam_2d, layer="DF2021:: Beam:: Seam:: local_mesh")
meshartist.clear_layer()
meshartist.draw_faces(join_faces=True)
meshartist.draw_edges()

Last updated