forked from 541435721/myVTKPythonLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddMappingFromPointsToCells.py
More file actions
65 lines (54 loc) · 1.99 KB
/
addMappingFromPointsToCells.py
File metadata and controls
65 lines (54 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#coding=utf8
########################################################################
### ###
### Created by Martin Genet, 2012-2016 ###
### ###
### University of California at San Francisco (UCSF), USA ###
### Swiss Federal Institute of Technology (ETH), Zurich, Switzerland ###
### École Polytechnique, Palaiseau, France ###
### ###
########################################################################
import myVTKPythonLibrary as myVTK
########################################################################
def addMappingFromPointsToCells(
ugrid_points,
ugrid_cells,
verbose=1):
myVTK.myPrint(verbose, "*** addMappingFromPointsToCells ***")
n_points = ugrid_points.GetNumberOfPoints()
n_cells = ugrid_cells.GetNumberOfCells()
#print "n_points = "+str(n_points)
#print "n_cells = "+str(n_cells)
(cell_locator,
closest_point,
generic_cell,
k_cell,
subId,
dist) = getCellLocator(
mesh=ugrid_cells,
verbose=verbose-1)
iarray_k_cell = createIntArray(
name="k_cell",
n_components=1,
n_tuples=n_points,
verbose=verbose-1)
ugrid_points.GetPointData().AddArray(iarray_k_cell)
ugrid_points.GetCellData().AddArray(iarray_k_cell)
point = numpy.empty(3)
for k_point in xrange(n_points):
ugrid_points.GetPoint(
k_point,
point)
cell_locator.FindClosestPoint(
point,
closest_point,
generic_cell,
k_cell,
subId,
dist)
#k_cell = cell_locator.FindCell(point)
#print "k_point = "+str(k_point)
#print "k_cell = "+str(k_cell)
iarray_k_cell.SetTuple1(
k_point,
k_cell)