How to create a cylinder that can be deformed in a gaussian way?

I have tried recreating a cylinder that is deformed in a gaussian way. Here’s my code for that:

import pyvista as pv
import numpy as np

# Set higher resolution for a finer mesh
height = 2.0
radius = 1.0
resolution_height = 50  # Number of subdivisions along the height
resolution_circumference = 200  # Number of subdivisions along the circumference

# Create a structured cylinder with finer mesh
cylinder = pv.CylinderStructured(radius=radius, height=height,
                                 theta_resolution=resolution_circumference,
                                 z_resolution=resolution_height)

# Convert the structured grid to PolyData for normal computation
cylinder_polydata = cylinder.extract_surface()

# Compute normals for the surface
cylinder_polydata = cylinder_polydata.compute_normals(cell_normals=False)

# Extract the computed point normals
normals = cylinder_polydata['Normals']

# Define different standard deviations for radial and vertical directions
num_parameters = 5  # Adjust as needed

deformed_points = np.copy(cylinder_polydata.points)

# Generate random sigmas for radial direction
sigmas = np.random.uniform(0.1, 0.5, size=num_parameters)  # Example range for sigmas
sgns_scale = np.random.uniform(-3, -2, size=num_parameters)
centers = np.random.uniform(-height, height, size=num_parameters)

for sgn, sigma, center in zip(sgns_scale, sigmas, centers):
    for i, point in enumerate(deformed_points):
        distance = np.linalg.norm(point - np.array([ center, 0, 0]))  # Distance from the center
        gaussian_factor = np.exp(-0.5 * (distance / sigma) ** 2)  # Gaussian weight
        displacement = sgn * gaussian_factor * normals[i]  # Displacement vector
        deformed_points[i] += displacement

# Update the cylinder's points with the deformed points
deformed_cylinder = pv.PolyData(deformed_points, faces=cylinder_polydata.faces)

# Create a plotter object
plotter = pv.Plotter()

# Add original and merged cylinders to the plotter
plotter.add_mesh(deformed_cylinder, color='blue', label='Deformed Cylinder', show_edges=True)

# Add points (nodes) to visualize the mesh structure
plotter.add_points(deformed_cylinder.points, color='red', point_size=5, render_points_as_spheres=True, label='Deformed Nodes')

# Add a legend to the plotter
plotter.add_legend()

# Show the plot with the mesh
plotter.show()

In doing so, I get a cylinder that is deformed, see image

However, the cylinder isn’t capped, and it only contains the surface.

I would like to create a closed mesh instead, so I tried using the pv.Cylinder() instead of pv.CylinderStructured. But the issue here is that the mesh lines only go vertically, and I need mesh lines that go along the polar direction.

So the result looks a bit off:

I tried creating a triangular mesh but then these gaussian deformations sometimes happen to deform the caps of the cylinder and creates all sorts of weird shapes.

Is it any way to seal off the CylinderStructured mesh by capping the top and bottom? Or is there any other efficient way to do this? I’m relatively new to PyVista and have tried finding some examples on line, but haven’t succeeded in doing so.

Thanks for all the help in advance!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật