Skip to content
Snippets Groups Projects
Commit 25fa90e3 authored by ojs1g14's avatar ojs1g14
Browse files

Update trim.py

parent 9aa00b51
No related branches found
No related tags found
No related merge requests found
Pipeline #344 passed
......@@ -30,22 +30,25 @@ class trimMixin(object):
>>> amp.planarTrim(100, 2)
"""
# planar values for each vert on face
fv = self.vert[self.faces, plane]
# Number points on each face are above cut plane
fvlogic = (fv > height).sum(axis=1)
# Faces with points both above and below cut plane
adjf = self.faces[np.logical_or(fvlogic == 2, fvlogic == 1)]
# Get adjacent vertices
adjv = np.unique(adjf)
# Get vert above height and set to height
abvInd = adjv[self.vert[adjv, plane] > height]
self.vert[abvInd, plane] = height
# Find all verts above plane
delv = self.vert[:, plane] > height
# Reorder verts to account for deleted one
vInd = np.cumsum(~delv) - 1
self.faces = self.faces[fvlogic != 3, :]
self.faces = vInd[self.faces]
self.vert = self.vert[~delv, :]
self.calcStruct()
\ No newline at end of file
if isinstance(height, float) and isinstance(plane, int):
# planar values for each vert on face
fv = self.vert[self.faces, plane]
# Number points on each face are above cut plane
fvlogic = (fv > height).sum(axis=1)
# Faces with points both above and below cut plane
adjf = self.faces[np.logical_or(fvlogic == 2, fvlogic == 1)]
# Get adjacent vertices
adjv = np.unique(adjf)
# Get vert above height and set to height
abvInd = adjv[self.vert[adjv, plane] > height]
self.vert[abvInd, plane] = height
# Find all verts above plane
delv = self.vert[:, plane] > height
# Reorder verts to account for deleted one
vInd = np.cumsum(~delv) - 1
self.faces = self.faces[fvlogic != 3, :]
self.faces = vInd[self.faces]
self.vert = self.vert[~delv, :]
self.calcStruct()
else:
raise TypeError("height arg must be a float and plane arg must be an int")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment