Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
52d7a125
Commit
52d7a125
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
cosmetic re-ordering of mesh methods
parent
8567643a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/mesh.py
+60
-59
60 additions, 59 deletions
fsl/data/mesh.py
with
60 additions
and
59 deletions
fsl/data/mesh.py
+
60
−
59
View file @
52d7a125
...
@@ -231,6 +231,66 @@ class TriangleMesh(object):
...
@@ -231,6 +231,66 @@ class TriangleMesh(object):
return
self
.
__vertNormals
return
self
.
__vertNormals
def
getBounds
(
self
):
"""
Returns a tuple of values which define a minimal bounding box that
will contain all vertices in this ``TriangleMesh`` instance. The
bounding box is arranged like so:
``((xlow, ylow, zlow), (xhigh, yhigh, zhigh))``
"""
return
(
self
.
__loBounds
,
self
.
__hiBounds
)
def
loadVertexData
(
self
,
dataSource
,
vertexData
=
None
):
"""
Attempts to load scalar data associated with each vertex of this
``TriangleMesh`` from the given ``dataSource``. The data is returned,
and also stored in an internal cache so it can be retrieved later
via the :meth:`getVertexData` method.
This method may be overridden by sub-classes.
:arg dataSource: Path to the vertex data to load
:arg vertexData: The vertex data itself, if it has already been
loaded.
:returns: A ``(M, N)``) array, which contains ``N`` data points
for ``M`` vertices.
"""
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
.
__vertexData
[
dataSource
]
=
vertexData
return
vertexData
def
getVertexData
(
self
,
dataSource
):
"""
Returns the vertex data for the given ``dataSource`` from the
internal vertex data cache. If the given ``dataSource`` is not
in the cache, it is loaded via :meth:`loadVertexData`.
"""
try
:
return
self
.
__vertexData
[
dataSource
]
except
KeyError
:
return
self
.
loadVertexData
(
dataSource
)
def
clearVertexData
(
self
):
"""
Clears the internal vertex data cache - see the
:meth:`loadVertexData` and :meth:`getVertexData` methods.
"""
self
.
__vertexData
=
{}
@memoize.Instanceify
(
memoize
.
memoize
)
@memoize.Instanceify
(
memoize
.
memoize
)
def
trimesh
(
self
):
def
trimesh
(
self
):
"""
Reference to a ``trimesh.Trimesh`` object which can be used for
"""
Reference to a ``trimesh.Trimesh`` object which can be used for
...
@@ -392,65 +452,6 @@ class TriangleMesh(object):
...
@@ -392,65 +452,6 @@ class TriangleMesh(object):
return
lines
,
faces
,
dists
return
lines
,
faces
,
dists
def
getBounds
(
self
):
"""
Returns a tuple of values which define a minimal bounding box that
will contain all vertices in this ``TriangleMesh`` instance. The
bounding box is arranged like so:
``((xlow, ylow, zlow), (xhigh, yhigh, zhigh))``
"""
return
(
self
.
__loBounds
,
self
.
__hiBounds
)
def
loadVertexData
(
self
,
dataSource
,
vertexData
=
None
):
"""
Attempts to load scalar data associated with each vertex of this
``TriangleMesh`` from the given ``dataSource``. The data is returned,
and also stored in an internal cache so it can be retrieved later
via the :meth:`getVertexData` method.
This method may be overridden by sub-classes.
:arg dataSource: Path to the vertex data to load
:arg vertexData: The vertex data itself, if it has already been
loaded.
:returns: A ``(M, N)``) array, which contains ``N`` data points
for ``M`` vertices.
"""
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
.
__vertexData
[
dataSource
]
=
vertexData
return
vertexData
def
getVertexData
(
self
,
dataSource
):
"""
Returns the vertex data for the given ``dataSource`` from the
internal vertex data cache. If the given ``dataSource`` is not
in the cache, it is loaded via :meth:`loadVertexData`.
"""
try
:
return
self
.
__vertexData
[
dataSource
]
except
KeyError
:
return
self
.
loadVertexData
(
dataSource
)
def
clearVertexData
(
self
):
"""
Clears the internal vertex data cache - see the
:meth:`loadVertexData` and :meth:`getVertexData` methods.
"""
self
.
__vertexData
=
{}
ALLOWED_EXTENSIONS
=
[
'
.vtk
'
]
ALLOWED_EXTENSIONS
=
[
'
.vtk
'
]
"""
A list of file extensions which could contain :class:`TriangleMesh` data.
"""
A list of file extensions which could contain :class:`TriangleMesh` data.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment