def get_polydata_centroid(poly_data):
    """ Calculate the centroid of polydata.
    """
    x_list = []
    y_list = []
    z_list = []
    cx = 0.0;
    cy = 0.0;
    cz = 0.0;
    num_pts = poly_data.GetNumberOfPoints()

    for i in range(num_pts): 
        point = poly_data.GetPoints().GetPoint(i)
        cx += point[0]
        cy += point[1]
        cz += point[2]

    return [cx/num_pts, cy/num_pts, cz/num_pts]