Commit 6a287f7b authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Added deprecated TriangleMesh class.

parent 6ca03276
......@@ -40,8 +40,7 @@ import fsl.utils.meta as meta
import fsl.utils.notifier as notifier
import fsl.utils.memoize as memoize
import fsl.utils.transform as transform
from . import image as fslimage
import as fslimage
log = logging.getLogger(__name__)
......@@ -186,6 +185,19 @@ class Mesh(notifier.Notifier, meta.Meta):
self.__trimesh = collections.OrderedDict()
def __repr__(self):
"""Returns a string representation of this ``Mesh`` instance. """
return '{}({}, {})'.format(type(self).__name__,,
def __str__(self):
"""Returns a string representation of this ``Mesh`` instance.
return self.__repr__()
def name(self):
"""Returns the name of this ``Mesh``. """
......@@ -204,7 +216,7 @@ class Mesh(notifier.Notifier, meta.Meta):
return self.__vertices[self.__selected]
def vertices(self, key):
"""Select the current vertex set - a ``KeyError`` is raised
if no vertex set with the specified ``key`` has been added.
......@@ -215,11 +227,13 @@ class Mesh(notifier.Notifier, meta.Meta):
self.__selected = key
def indices(self):
"""The ``(M, 3)`` triangles of this mesh. """
return self.__indices[self.__selected]
return self.__indices
......@@ -258,6 +272,14 @@ class Mesh(notifier.Notifier, meta.Meta):
return vnormals
details='Use bounds instead')
def getBounds(self):
"""Deprecated - use :meth:`bounds` instead. """
return self.bounds
def bounds(self):
"""Returns a tuple of values which define a minimal bounding box that
......@@ -595,3 +617,91 @@ def needsFixing(vertices, indices, fnormals, loBounds, hiBounds):
# If it isn't, we need to flip the
# triangle winding order.
return, transform.normalise(camera - vert)) < 0
class TriangleMesh(Mesh):
"""Deprecated - use :class:``, or one 'of its sub-classes
details='Use, or one '
'of its sub-classes instead')
def __init__(self, data, indices=None, fixWinding=False):
import as fslvtk
if isinstance(data, six.string_types):
name = op.basename(data)
dataSource = data
mesh = fslvtk.VTKMesh(data, fixWinding=False)
vertices = mesh.vertices
indices = mesh.indices
name = 'TriangleMesh'
dataSource = None
vertices = data
Mesh.__init__(self, indices, name=name, dataSource=dataSource)
self.addVertices(vertices, 'default', fixWinding=fixWinding)
details='Use the Mesh class instead')
def loadVertexData(self, dataSource, vertexData=None):
nvertices = self.vertices.shape[0]
# Currently only white-space delimited
# text files are supported
if vertexData is None:
vertexData = np.loadtxt(dataSource)
vertexData.reshape(nvertices, -1)
if vertexData.shape[0] != nvertices:
raise ValueError('Incompatible size: {}'.format(dataSource))
self.addVertexData(dataSource, vertexData)
return vertexData
details='Use the Mesh class instead')
def getVertexData(self, dataSource):
return Mesh.getVertexData(self, dataSource)
except KeyError:
return self.loadVertexData(dataSource)
details='Use instead')
def loadVTKPolydataFile(*args, **kwargs):
"""Deprecated - use :func:`` instead. """
import as fslvtk
return fslvtk.loadVTKPolydataFile(*args, **kwargs)
details='Use instead')
def getFIRSTPrefix(*args, **kwargs):
"""Deprecated - use :func:`` instead. """
import as fslvtk
return fslvtk.getFIRSTPrefix(*args, **kwargs)
details='Use instead')
def findReferenceImage(*args, **kwargs):
"""Deprecated - use :func:`` instead. """
import as fslvtk
return fslvtk.findReferenceImage(*args, **kwargs)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment