Skip to content

Commit

Permalink
fix test_segments
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Dec 18, 2019
1 parent 7da65da commit 2341469
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
30 changes: 12 additions & 18 deletions trimesh/path/exchange/dxf.py
Expand Up @@ -239,36 +239,30 @@ def convert_text(e):
"""
Convert a DXF TEXT entity into a native text entity.
"""
if '50' in e:
# rotation angle converted to radians
angle = np.radians(float(e['50']))
else:
# otherwise no rotation
angle = 0.0

# text with leading and trailing whitespace removed
text = e['1'].strip()

# height of text
if '40' in e:
# try getting optional height of text
try:
height = float(e['40'])
else:
except BaseException:
height = None

try:
# rotation angle converted to radians
angle = np.radians(float(e['50']))
except BaseException:
# otherwise no rotation
angle = 0.0
# origin point
origin = np.array([e['10'],
e['20']]).astype(np.float64)

# an origin- relative point (so transforms work)
origin = np.array(
[e['10'], e['20']], dtype=np.float64)
# an origin-relative point (so transforms work)
vector = origin + [np.cos(angle), np.sin(angle)]

# try to extract a (horizontal, vertical) text alignment
align = ['center', 'center']
try:
align[0] = ['left', 'center', 'right'][int(e['72'])]
except BaseException:
pass

# append the entity
entities.append(Text(origin=len(vertices),
vector=len(vertices) + 1,
Expand Down
14 changes: 6 additions & 8 deletions trimesh/path/segments.py
Expand Up @@ -475,30 +475,28 @@ def resample(segments,
assert np.allclose(original[-1], recon[-1])

# stack into (n, 2, 3) segments
result = np.concatenate(result)
result = [np.concatenate(result)]

if tol.strict:
# make sure resampled segments have the same length as input
assert np.isclose(length(segments),
length(result),
length(result[0]),
atol=1e-3)

if not return_index and not return_count:
return result

result = [result]

# stack additional return options
if return_index:
# stack original indexes
index = np.concatenate(index)
if tol.strict:
# index should correspond to result
assert len(index) == len(result)
assert len(index) == len(result[0])
# every segment should be represented
assert set(index) == set(range(len(segments)))
result.append(index)

if return_count:
result.append(splits)

if len(result) == 1:
return result[0]
return result

0 comments on commit 2341469

Please sign in to comment.