Skip to content

Commit 74e5370

Browse files
committed
fix for b- splines as lines
1 parent 33c54db commit 74e5370

4 files changed

Lines changed: 30 additions & 14 deletions

File tree

tests/test_transformations.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
class TransformTest(g.unittest.TestCase):
88

99
def test_doctest(self):
10-
'''
11-
Run doctests on transformations, which checks docstrings for
12-
interactive sessions and then verifies they execute correctly.
10+
"""
11+
Run doctests on transformations, which checks docstrings
12+
for interactive sessions and then verifies they execute
13+
correctly.
1314
14-
This is how the upstream transformations unit tests.
15-
'''
15+
This is how the upstream transformations unit tests,
16+
but it depends on numpy string formatting and is very
17+
flaky.
18+
"""
1619
import trimesh
1720
import random
1821
import doctest
@@ -31,10 +34,10 @@ def test_doctest(self):
3134
g.log.info('transformations {}'.format(str(results)))
3235

3336
def test_downstream(self):
34-
'''
35-
Run tests on functions that were added downstream of the original
36-
transformations.py
37-
'''
37+
"""
38+
Run tests on functions that were added by us to the
39+
original transformations.py
40+
"""
3841
tr = g.trimesh.transformations
3942

4043
assert not tr.is_rigid(g.np.ones((4, 4)))

trimesh/path/curve.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ def compute(t):
4848
return result
4949

5050

51-
def discretize_bspline(control, knots, count=None, scale=1.0):
51+
def discretize_bspline(control,
52+
knots,
53+
count=None,
54+
scale=1.0):
5255
"""
5356
Given a B-Splines control points and knot vector, return
5457
a sampled version of the curve.

trimesh/path/io/dxf.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,16 @@ def convert_bspline(e):
328328
e['20'])).astype(np.float64)
329329
knots = np.array(e['40']).astype(np.float64)
330330

331+
# if there are only two points, save it as a line
332+
if len(points) == 2:
333+
# create a single Line entity
334+
entities.append(Line(points=len(vertices) +
335+
np.arange(2),
336+
**info(e)))
337+
# add the vertices to our collection
338+
vertices.extend(points)
339+
return
340+
331341
# check bit coded flag for closed
332342
# closed = bool(int(e['70'][0]) & 1)
333343
# check euclidean distance to see if closed
@@ -525,9 +535,9 @@ def format_points(points,
525535
points = np.asanyarray(points, dtype=np.float64)
526536
three = util.three_dimensionalize(points, return_2D=False)
527537
if increment:
528-
group = np.tile(np.arange(len(three),
529-
dtype=np.int).reshape((-1, 1)),
530-
(1, 3))
538+
group = np.tile(
539+
np.arange(len(three), dtype=np.int).reshape((-1, 1)),
540+
(1, 3))
531541
else:
532542
group = np.zeros((len(three), 3), dtype=np.int)
533543
group += [10, 20, 30]

trimesh/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.33.36'
1+
__version__ = '2.33.37'

0 commit comments

Comments
 (0)