39 lines
790 B
Python
39 lines
790 B
Python
|
from baker import get_phis
|
||
|
|
||
|
class face(object):
|
||
|
def __init__(self, name):
|
||
|
self.name = name
|
||
|
self.verts = []
|
||
|
self.neighbors = []
|
||
|
|
||
|
def add_vert(self, v):
|
||
|
"""
|
||
|
v should be an index into grid.points
|
||
|
"""
|
||
|
self.verts.append(v)
|
||
|
|
||
|
def add_neighbor(self, n):
|
||
|
"""
|
||
|
reference to another face object
|
||
|
"""
|
||
|
self.neighbors.append(n)
|
||
|
|
||
|
def contains(self, X, grid):
|
||
|
R = [grid.points[i] for i in self.verts]
|
||
|
|
||
|
phis = get_phis(X, R)
|
||
|
|
||
|
r = True
|
||
|
if [i for i in phis if i < 0.0]:
|
||
|
r = False
|
||
|
return r
|
||
|
|
||
|
def __str__(self):
|
||
|
neighbors = [i.name for i in self.neighbors]
|
||
|
return '%s: verts: %s neighbors: [%s]' %\
|
||
|
(
|
||
|
self.name,
|
||
|
self.verts,
|
||
|
", ".join(neighbors)
|
||
|
)
|