def build_from_hull(self):
"""
Test oriented bounding box algorithm using convex hull points.
Raises:
None
Returns:
EigenVectors(OpenMaya.MVector)
CenterPoint(OpenMaya.MVector)
BoundingExtents(OpenMaya.MVector)
"""
npPointList = [[self.points[i].x, self.points[i].y, self.points[i].z]
for i in xrange(self.points.length())]
try:
hull = ConvexHull(npPointList)
except NameError:
raise RuntimeError(
"From hull method unavailable because"
" scipy cannot be imported."
"Please install it if you need it.")
indices = hull.simplices
vertices = npPointList[indices]
hullPoints = list(vertices.flatten())
hullTriPoints = list(indices.flatten())
hullArray = OpenMaya.MVectorArray()
for ind in xrange(0, len(hullPoints), 3):
hullArray.append(
OpenMaya.MVector(
hullPoints[ind], hullPoints[ind+1], hullPoints[ind+2]))
triPoints = OpenMaya.MIntArray()
for tri in xrange(len(hullTriPoints)):
triPoints.append(tri)
return self.build_from_triangles(points=hullArray, triangles=triPoints)
评论列表
文章目录