Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-04-22 09:17:50 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-22 09:17:50 +0400
commit3b18f026d0918ecd51a0c79343b8221769806e9e (patch)
treec2042240e3f80db7192afa7faf2c70de37f4ca5a /io_mesh_stl
parent5da29460fb6f0c311a27267306499db5412ad098 (diff)
STL now always exports normals.
Normals are not optional for STL so remove the option from the UI.
Diffstat (limited to 'io_mesh_stl')
-rw-r--r--io_mesh_stl/__init__.py6
-rw-r--r--io_mesh_stl/stl_utils.py54
2 files changed, 16 insertions, 44 deletions
diff --git a/io_mesh_stl/__init__.py b/io_mesh_stl/__init__.py
index 6994fcef..9de8c02d 100644
--- a/io_mesh_stl/__init__.py
+++ b/io_mesh_stl/__init__.py
@@ -44,7 +44,6 @@ Import-Export STL files (binary or ascii)
Issues:
Import:
- - Does not handle the normal of the triangles
- Does not handle endien
"""
@@ -128,11 +127,6 @@ class ExportSTL(Operator, ExportHelper):
description="Save the file in ASCII file format",
default=False,
)
- use_normals = BoolProperty(
- name="Write Normals",
- description="Export one normal per face, to represent flat faces and sharp edges",
- default=False,
- )
use_mesh_modifiers = BoolProperty(
name="Apply Modifiers",
description="Apply the modifiers before saving",
diff --git a/io_mesh_stl/stl_utils.py b/io_mesh_stl/stl_utils.py
index 1145ab41..67478ba8 100644
--- a/io_mesh_stl/stl_utils.py
+++ b/io_mesh_stl/stl_utils.py
@@ -157,7 +157,7 @@ def _ascii_read(data):
for l_item in (l, data.readline(), data.readline())]
-def _binary_write(filepath, faces, use_normals):
+def _binary_write(filepath, faces):
with open(filepath, 'wb') as data:
fw = data.write
# header
@@ -171,49 +171,31 @@ def _binary_write(filepath, faces, use_normals):
# number of vertices written
nb = 0
- if use_normals:
- for face in faces:
- # calculate face normal
- # write normal + vertexes + pad as attributes
- fw(struct.pack('<3f', *normal(*face)) + pack(*itertools.chain.from_iterable(face)))
- # attribute byte count (unused)
- fw(b'\0\0')
- nb += 1
- else:
- # pad is to remove normal, we do use them
- pad = b'\0' * struct.calcsize('<3f')
-
- for face in faces:
- # write pad as normal + vertexes + pad as attributes
- fw(pad + pack(*itertools.chain.from_iterable(face)))
- # attribute byte count (unused)
- fw(b'\0\0')
- nb += 1
+ for face in faces:
+ # calculate face normal
+ # write normal + vertexes + pad as attributes
+ fw(struct.pack('<3f', *normal(*face)) + pack(*itertools.chain.from_iterable(face)))
+ # attribute byte count (unused)
+ fw(b'\0\0')
+ nb += 1
# header, with correct value now
data.seek(0)
fw(struct.pack('<80sI', _header_version().encode('ascii'), nb))
-def _ascii_write(filepath, faces, use_normals):
+def _ascii_write(filepath, faces):
with open(filepath, 'w') as data:
fw = data.write
header = _header_version()
fw('solid %s\n' % header)
- if use_normals:
- for face in faces:
- # calculate face normal
- fw('facet normal %f %f %f\nouter loop\n' % normal(*face)[:])
- for vert in face:
- fw('vertex %f %f %f\n' % vert[:])
- fw('endloop\nendfacet\n')
- else:
- for face in faces:
- fw('outer loop\n')
- for vert in face:
- fw('vertex %f %f %f\n' % vert[:])
- fw('endloop\nendfacet\n')
+ for face in faces:
+ # calculate face normal
+ fw('facet normal %f %f %f\nouter loop\n' % normal(*face)[:])
+ for vert in face:
+ fw('vertex %f %f %f\n' % vert[:])
+ fw('endloop\nendfacet\n')
fw('endsolid %s\n' % header)
@@ -221,7 +203,6 @@ def _ascii_write(filepath, faces, use_normals):
def write_stl(filepath="",
faces=(),
ascii=False,
- use_normals=False,
):
"""
Write a stl file from faces,
@@ -234,11 +215,8 @@ def write_stl(filepath="",
ascii
save the file in ascii format (very huge)
-
- use_normals
- calculate face normals and write them
"""
- (_ascii_write if ascii else _binary_write)(filepath, faces, use_normals)
+ (_ascii_write if ascii else _binary_write)(filepath, faces)
def read_stl(filepath):