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
1f783253
Commit
1f783253
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
One mesh vertex set can be set on __init__. Vertex set keys are optional. New
method to query current vertex set.
parent
be364a4b
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
+23
-5
23 additions, 5 deletions
fsl/data/mesh.py
with
23 additions
and
5 deletions
fsl/data/mesh.py
+
23
−
5
View file @
1f783253
...
@@ -136,7 +136,7 @@ class Mesh(notifier.Notifier, meta.Meta):
...
@@ -136,7 +136,7 @@ class Mesh(notifier.Notifier, meta.Meta):
"""
"""
def
__init__
(
self
,
indices
,
name
=
'
mesh
'
,
dataSource
=
None
):
def
__init__
(
self
,
indices
,
name
=
'
mesh
'
,
dataSource
=
None
,
vertices
=
None
):
"""
Create a ``Mesh`` instance.
"""
Create a ``Mesh`` instance.
Before a ``Mesh`` can be used, some vertices must be added via the
Before a ``Mesh`` can be used, some vertices must be added via the
...
@@ -147,7 +147,10 @@ class Mesh(notifier.Notifier, meta.Meta):
...
@@ -147,7 +147,10 @@ class Mesh(notifier.Notifier, meta.Meta):
:arg name: A name for this ``Mesh``.
:arg name: A name for this ``Mesh``.
:arg dataSource: the data source for this ``Mesh``.
:arg dataSource: The data source for this ``Mesh``.
:arg vertices: Initial vertex set to add - given the key
``
'
default
'
``.
"""
"""
self
.
__name
=
name
self
.
__name
=
name
...
@@ -184,6 +187,11 @@ class Mesh(notifier.Notifier, meta.Meta):
...
@@ -184,6 +187,11 @@ class Mesh(notifier.Notifier, meta.Meta):
# in the trimesh method
# in the trimesh method
self
.
__trimesh
=
collections
.
OrderedDict
()
self
.
__trimesh
=
collections
.
OrderedDict
()
# Add initial vertex
# set if provided
if
vertices
is
not
None
:
self
.
addVertices
(
vertices
)
def
__repr__
(
self
):
def
__repr__
(
self
):
"""
Returns a string representation of this ``Mesh`` instance.
"""
"""
Returns a string representation of this ``Mesh`` instance.
"""
...
@@ -295,13 +303,14 @@ class Mesh(notifier.Notifier, meta.Meta):
...
@@ -295,13 +303,14 @@ class Mesh(notifier.Notifier, meta.Meta):
return
lo
,
hi
return
lo
,
hi
def
addVertices
(
self
,
vertices
,
key
,
select
=
True
,
fixWinding
=
False
):
def
addVertices
(
self
,
vertices
,
key
=
None
,
select
=
True
,
fixWinding
=
False
):
"""
Adds a set of vertices to this ``Mesh``.
"""
Adds a set of vertices to this ``Mesh``.
:arg vertices: A `(n, 3)` array containing ``n`` vertices, compatible
:arg vertices: A `(n, 3)` array containing ``n`` vertices, compatible
with the indices specified in :meth:`__init__`.
with the indices specified in :meth:`__init__`.
:arg key: A key for this vertex set.
:arg key: A key for this vertex set. If ``None`` defaults to
``
'
default
'
``.
:arg select: If ``True`` (the default), this vertex set is
:arg select: If ``True`` (the default), this vertex set is
made the currently selected vertex set.
made the currently selected vertex set.
...
@@ -311,6 +320,9 @@ class Mesh(notifier.Notifier, meta.Meta):
...
@@ -311,6 +320,9 @@ class Mesh(notifier.Notifier, meta.Meta):
all have outward-facing normal vectors.
all have outward-facing normal vectors.
"""
"""
if
key
is
None
:
key
=
'
default
'
vertices
=
np
.
asarray
(
vertices
)
vertices
=
np
.
asarray
(
vertices
)
lo
=
vertices
.
min
(
axis
=
0
)
lo
=
vertices
.
min
(
axis
=
0
)
hi
=
vertices
.
max
(
axis
=
0
)
hi
=
vertices
.
max
(
axis
=
0
)
...
@@ -338,11 +350,17 @@ class Mesh(notifier.Notifier, meta.Meta):
...
@@ -338,11 +350,17 @@ class Mesh(notifier.Notifier, meta.Meta):
self
.
__faceNormals
[
k
]
=
fn
*
-
1
self
.
__faceNormals
[
k
]
=
fn
*
-
1
def
selectedVertices
(
self
):
"""
Returns the key of the currently selected vertex set.
"""
return
self
.
__selected
def
addVertexData
(
self
,
key
,
vdata
):
def
addVertexData
(
self
,
key
,
vdata
):
"""
Adds a vertex-wise data set to the ``Mesh``. It can be retrieved
"""
Adds a vertex-wise data set to the ``Mesh``. It can be retrieved
by passing the specified ``key`` to the :meth:`getVertexData` method.
by passing the specified ``key`` to the :meth:`getVertexData` method.
"""
"""
self
.
__vertexData
[
key
]
=
vdata
self
.
__vertexData
[
key
]
=
vdata
.
reshape
(
vdata
.
shape
[
0
],
-
1
)
def
getVertexData
(
self
,
key
):
def
getVertexData
(
self
,
key
):
...
...
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