transfer_blend_shape.transfer module¶
-
class
transfer_blend_shape.transfer.Transfer(source_mesh=None, target_mesh=None, virtual_mesh=None, iterations=3, threshold=0.001, create_colour_sets=False)¶ Bases:
objectDeformation transfer applies the deformation exhibited by a source mesh onto a different target mesh. The transfer can be aided by a virtual mesh that creates additional triangles.
-
calculate_area(points)¶ Parameters: points (numpy.Array) – Returns: Triangle areas Return type: numpy.Array
-
calculate_deformation_gradient(points)¶ Parameters: points (numpy.Array) – Returns: Deformation gradient Return type: numpy.Array
-
static
calculate_edge_matrix(point1, point2, point3)¶ Parameters: - point1 (numpy.Array) –
- point2 (numpy.Array) –
- point3 (numpy.Array) –
Returns: Edge matrix
Return type: numpy.Array
-
calculate_laplacian_matrix(weights, ignore)¶ Create a laplacian smoothing matrix based on the weights, for the smoothing the number of vertices and vertex connectivity is used together with the provided weights, the weights are clamped to a maximum of 1. Any ignore indices will have their weights set to 0.
Parameters: - weights (numpy.Array) –
- ignore (numpy.Array) –
Returns: Laplacian smoothing matrix
Return type: scipy.sparse.csr.csr_matrix
-
calculate_laplacian_weights(points, ignore)¶ Calculate the laplacian weights depending on the change in per vertex area between the source and target points. The calculated weights are smoothed a number of times defined by the iterations, this will even out the smooth.
Parameters: - points (numpy.Array) –
- ignore (numpy.Array) –
Returns: Laplacian weights
Return type: numpy.Array
-
calculate_target_matrix()¶ Returns: Target matrix Return type: numpy.Array
-
create_colour_sets¶ Returns: Create colour sets state Return type: bool
-
execute(points, name)¶ Parameters: - points (numpy.Array) –
- name (str) –
Returns: Target
Return type: str
Raises: - RuntimeError – When transfer is invalid.
- RuntimeError – When vertex count doesn’t match between source and target.
- RuntimeError – When no static vertices are found.
-
execute_from_blend_shape()¶ Returns: Targets
Return type: list[str]
Raises: - RuntimeError – When transfer is invalid.
- RuntimeError – When vertex count doesn’t match between source and target.
- RuntimeError – When no blend shape is connected to the source.
- RuntimeError – When no static vertices are found.
-
execute_from_mesh(mesh, name=None)¶ Parameters: - mesh (str) –
- name (str/None) –
Returns: Target
Return type: str
Raises: - RuntimeError – When transfer is invalid.
- RuntimeError – When vertex count doesn’t match between source and target.
- RuntimeError – When provided mesh is not a mesh.
- RuntimeError – When mesh vertex count doesn’t match source.
- RuntimeError – When no static vertices are found.
-
filter_vertices(points)¶ Parameters: points (numpy.Array) – Returns: Static/Dynamic vertices Return type: numpy.Array, numpy.Array
-
get_source_area(*args, **kwargs)¶ Returns: Source triangle area Return type: numpy.Array Raises: RuntimeError – When source is not defined.
-
get_source_points(*args, **kwargs)¶ Returns: Source points Return type: numpy.Array Raises: RuntimeError – When source is not defined.
-
get_source_triangles(*args, **kwargs)¶ Returns: Source triangles Return type: list[int] Raises: RuntimeError – When source is not defined.
-
get_target_connectivity(*args, **kwargs)¶ Returns: Target connectivity Return type: list[list[int]] Raises: RuntimeError – When target is not defined.
-
get_target_matrix(*args, **kwargs)¶ Returns: Target matrix Return type: numpy.Array Raises: RuntimeError – When target is not defined.
-
get_target_points(*args, **kwargs)¶ Returns: Target points Return type: numpy.Array Raises: RuntimeError – When target is not defined.
-
get_virtual_triangles(*args, **kwargs)¶ Parameters: threshold (float) – Returns: Virtual triangles Return type: list[int] Raises: RuntimeError – When minimum length surpasses threshold.
-
is_valid()¶ Returns: Valid state Return type: bool
-
is_valid_with_blend_shape()¶ Returns: Valid state + blend shape Return type: bool
-
iterations¶ Returns: Iterations Return type: int
-
set_create_colour_sets(state)¶ Parameters: state (bool) –
-
set_iterations(iterations)¶ Parameters: iterations (int) –
Raises: - TypeError – When iterations is not a int.
- ValueError – When iterations is lower than 0.
-
set_source_mesh(source_mesh)¶ Parameters: source_mesh (str) –
-
set_target_mesh(target_mesh)¶ Parameters: target_mesh (str) –
-
set_threshold(threshold)¶ Parameters: threshold (float) –
Raises: - TypeError – When threshold is not a float or int.
- ValueError – When threshold is lower or equal to 0.
-
set_virtual_mesh(virtual_mesh)¶ Parameters: virtual_mesh (str) –
-
source_mesh¶ Returns: Source mesh Return type: str
-
target_mesh¶ Returns: Target mesh Return type: str
-
threshold¶ Returns: Threshold Return type: float
-
virtual_mesh¶ Returns: Virtual Return type: str
-