Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Boeckenhoff
tfields
Commits
5385017b
Commit
5385017b
authored
Oct 15, 2019
by
Daniel Boeckenhoff
Browse files
doc string corrections
parent
e479f081
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
make
@
acb8a624
Compare
ba4eae32
...
acb8a624
Subproject commit
ba4eae32e9ba1ed07090b70476a09a8a30781684
Subproject commit
acb8a624b9fd639569c0e8a8d52abd54aa8ded0b
tfields/bounding_box.py
View file @
5385017b
...
...
@@ -138,6 +138,7 @@ class Node(object):
def
leaves
(
self
):
"""
Recursive function to create a list of all leaves
Returns:
list: of all leaves descending from this node
"""
...
...
@@ -282,9 +283,11 @@ class Node(object):
def
_convert_field_index
(
self
,
index
):
"""
Recursively getting the fields index from root
Args:
index (int): field index on leaf
(index with respect to parent node, not to root)
Returns:
int: field index
"""
...
...
@@ -301,6 +304,7 @@ class Node(object):
"""
Get the global template for a leaf. This can be applied to the root mesh
with the cut method to retrieve exactly this leaf mesh again.
Returns:
tfields.Mesh3D: mesh with first scalars as an instruction on how to build
this cut (scalars point to faceIndices on mother mesh). Can be
...
...
@@ -394,6 +398,7 @@ class Searcher(Node):
"""
TODO:
* check rare case of point+-delta outside box
Examples:
>>> import tfields
>>> import numpy as np
...
...
tfields/core.py
View file @
5385017b
This diff is collapsed.
Click to expand it.
tfields/triangles3D.py
View file @
5385017b
...
...
@@ -15,13 +15,24 @@ from tfields.lib.decorators import cached_property
class
Triangles3D
(
tfields
.
TensorFields
):
# pylint: disable=R0904
"""
Points3D child restricted to n * 3 Points. 3 Points always group together to one triangle.
Points3D child restricted to n * 3 Points.
Three Points always group together to one triangle.
Args:
tensors (Iterable | tfields.TensorFields)
*fields (Iterable | tfields.Tensors): Fields with the same length as tensors
**kwargs: passed to base class
Attributes:
see :class:`~tfields.TensorFields`
Examples:
>>> import tfields
>>> import numpy as np
>>> t = tfields.Triangles3D([[1,2,3], [3,3,3], [0,0,0]])
You can add fields to each triangle
>>> t = tfields.Triangles3D(t, tfields.Tensors([42]))
>>> assert t.fields[0].equal([42])
...
...
@@ -54,6 +65,7 @@ class Triangles3D(tfields.TensorFields):
def
__getitem__
(
self
,
index
):
"""
In addition to the usual, also slice fields
Examples:
>>> import tfields
>>> import numpy as np
...
...
@@ -127,6 +139,7 @@ class Triangles3D(tfields.TensorFields):
def
evalf
(
self
,
expression
=
None
,
coord_sys
=
None
):
"""
Triangle3D implementation
Examples:
>>> from sympy.abc import x
>>> t = tfields.Triangles3D([[1., 2., 3.], [-4., 5., 6.], [1, 2, -6],
...
...
@@ -149,6 +162,7 @@ class Triangles3D(tfields.TensorFields):
def
cut
(
self
,
expression
,
coord_sys
=
None
):
"""
Default cut method for Triangles3D
Examples:
>>> import sympy
>>> import tfields
...
...
@@ -185,10 +199,12 @@ class Triangles3D(tfields.TensorFields):
def
areas
(
self
,
transform
=
None
):
"""
Calculate area with "heron's formula"
Args:
transform (np.ndarray): optional transformation matrix
The triangle points are transformed with transform if given
before calclulating the area
Examples:
>>> m = tfields.Mesh3D([[1,0,0], [0,0,1], [0,0,0]],
... faces=[[0, 1, 2]])
...
...
@@ -306,6 +322,9 @@ class Triangles3D(tfields.TensorFields):
def
centroids
(
self
):
"""
Returns:
:func:`~tfields.Triangles3D._centroids`
Examples:
>>> m = tfields.Mesh3D([[0,0,0], [1,0,0], [-1,0,0], [0,1,0], [0,0,1]],
... faces=[[0, 1, 3],[0, 2, 3],[1,2,4], [1, 3, 4]]);
...
...
@@ -321,6 +340,7 @@ class Triangles3D(tfields.TensorFields):
def
edges
(
self
):
"""
Retrieve two of the three edge vectors
Returns:
two np.ndarrays: vectors ab and ac, where a, b, c are corners (see
self.corners)
...
...
@@ -457,13 +477,16 @@ class Triangles3D(tfields.TensorFields):
def
_in_triangles
(
self
,
point
,
delta
=
0.
):
"""
Barycentric method to optain, wheter a point is in any of the triangles
Args:
point (list of len 3)
delta (float / None):
float: acceptance in +- norm vector direction
None: accept the face with the minimum distance to the point
Returns:
np.array: boolean mask, True where point in a triangle within delta
Examples:
>>> m = tfields.Mesh3D([[1,0,0], [0,1,0], [0,0,0]], faces=[[0, 1, 2]]);
>>> assert np.array_equal(
...
...
@@ -471,6 +494,7 @@ class Triangles3D(tfields.TensorFields):
... np.array([True], dtype=bool))
All Triangles are tested
>>> m2 = tfields.Mesh3D([[1,0,0], [0,1,0], [0,0,0], [4,0,0], [4, 4, 0], [8, 0, 0]],
... faces=[[0, 1, 2], [3, 4, 5]]);
...
...
@@ -482,6 +506,7 @@ class Triangles3D(tfields.TensorFields):
... np.array([False, True], dtype=bool))
delta allows to accept points that lie within delta orthogonal to the tringle plain
>>> assert np.array_equal(
... m2.triangles()._in_triangles(np.array([0.2, 0.2, 9000]), 0.0),
... np.array([False, False], dtype=bool))
...
...
@@ -490,12 +515,14 @@ class Triangles3D(tfields.TensorFields):
... np.array([ True, False], dtype=bool))
if you set delta to None, the minimal distance point(s) are accepted
>>> assert np.array_equal(
... m2.triangles()._in_triangles(np.array([0.2, 0.2, 0.1]), None),
... np.array([ True, False], dtype=bool))
If you define triangles that have colinear side vectors or in general lead to
not invertable matrices the you will always get False
>>> m3 = tfields.Mesh3D([[0,0,0], [2,0,0], [4,0,0], [0,1,0]],
... faces=[[0, 1, 2], [0, 1, 3]]);
>>> mask = m3.triangles()._in_triangles(np.array([0.2, 0.2, 0]), delta=0.3)
...
...
@@ -555,14 +582,15 @@ class Triangles3D(tfields.TensorFields):
def
in_triangles
(
self
,
tensors
,
delta
=
0.
,
assign_multiple
=
False
):
"""
Barycentric method to obtain, which tensors are containes in any of the triangles
Args:
tensors (Points3D instance)
optional:
delta (
float / None
):
float: normal distance to a triangle, that the points are
concidered to be contained
in the
triangle.
None: find the minimum distance
delta (
:obj:`float` | :obj:`None`, optional
):
:obj:`
float
`
: normal distance to a triangle, that the points are
concidered to be contained in the triangle.
:obj:`None`: f
in
d
the
minimum distance
default is 0.
assign_multiple (bool): if True, one point may belong to multiple
triangles at the same time. In the other case the first
occurence will be True the other False
...
...
@@ -622,21 +650,27 @@ class Triangles3D(tfields.TensorFields):
def
_on_edges
(
self
,
point
):
"""
TODO: on_edges like in_triangles
Determine whether a point is on the edge / side ray of a triangle
TODO:
on_edges like in_triangles
Returns:
np.array: boolean mask which is true, if point is on one side ray
of a triangle
Examples:
>>> m = tfields.Mesh3D([[0,0,0], [1,0,0], [-1,0,0], [0,1,0], [0,0,1]],
... faces=[[0, 1, 3],[0, 2, 3],[1,2,4]]);
Corner points are found
>>> assert np.array_equal(
... m.triangles()._on_edges(tfields.Points3D([[0,1,0]])),
... np.array([ True, True, False], dtype=bool))
Side points are found, too
>>> assert np.array_equal(
... m.triangles()._on_edges(tfields.Points3D([[0.5,0,0.5]])),
... np.array([False, False, True], dtype=bool))
...
...
@@ -653,14 +687,17 @@ class Triangles3D(tfields.TensorFields):
def
_weights
(
self
,
weights
,
rigid
=
False
):
"""
transformer method for weights inputs.
Args:
weights (np.ndarray | int | None):
If weights is integer it will be used as index for fields and fields are
used as weights.
If weights is None it will
Otherwise just pass the weights.
Returns:
Returns:
TODO: Better docs
"""
# set weights to 1.0 if weights is None
if
weights
is
None
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment