ProjectProposals: boolean_operations.py

File boolean_operations.py, 1.0 KB (added by tati.alchueyr@…, 3 years ago)

Base class for Task 1

Line 
1import vtk
2
3def MergePolyData(polydata1, polydata2):
4    """
5    Create a new vtkPolyData consisting on two polydatas' merge.
6    """
7    append = vtk.vtkAppendPolyData()
8    append.AddInput(polydata1)
9    append.AddInput(polydata2)
10    append.Update()
11
12    result = vtk.vtkPolyData()
13    result.DeepCopy(append.GetOutput())
14
15    return result
16
17def IntersectPolyData(polydata1, polydata2):
18    """
19    Create a new vtkPolyData containing two polydatas' intersection.
20    """
21    # TODO:
22    # develop something here to compute intersection
23
24    result = vtk.vtkPolyData()
25    result.DeepCopy(intersection.GetOutput())
26
27    return result
28
29def SubtractPolyData(polydata1, polydata2):
30    """
31    Create a new vtkPolyData, based on polydata1, removing intersections with polydata2.
32    """
33    # TODO:
34    # develop something here to compute the difference between polydata1 and its
35    # intersection with polydata2
36
37    result = vtk.vtkPolyData()
38    result.DeepCopy(difference.GetOutput())
39
40    return result