Commit 39099fc0 authored by sumpfralle's avatar sumpfralle

fixed log output of STLImporter

reduced epsilon


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@571 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 60bb820e
...@@ -23,8 +23,8 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -23,8 +23,8 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import decimal import decimal
import math import math
INFINITE = 10000 INFINITE = 100000
epsilon = 0.0001 epsilon = 0.00001
# use the "decimal" module for fixed precision numbers (only for debugging) # use the "decimal" module for fixed precision numbers (only for debugging)
_use_precision = False _use_precision = False
......
...@@ -26,6 +26,7 @@ from pycam.Geometry.Line import Line ...@@ -26,6 +26,7 @@ from pycam.Geometry.Line import Line
from pycam.Geometry.Triangle import Triangle from pycam.Geometry.Triangle import Triangle
from pycam.Geometry.PointKdtree import PointKdtree from pycam.Geometry.PointKdtree import PointKdtree
from pycam.Geometry.TriangleKdtree import TriangleKdtree from pycam.Geometry.TriangleKdtree import TriangleKdtree
from pycam.Geometry.utils import epsilon
from pycam.Geometry.Model import Model from pycam.Geometry.Model import Model
import pycam.Utils.log import pycam.Utils.log
...@@ -38,7 +39,6 @@ log = pycam.Utils.log.get_logger() ...@@ -38,7 +39,6 @@ log = pycam.Utils.log.get_logger()
vertices = 0 vertices = 0
edges = 0 edges = 0
epsilon = 0.0001
kdtree = None kdtree = None
def UniqueVertex(x, y, z): def UniqueVertex(x, y, z):
...@@ -167,9 +167,9 @@ def ImportModel(filename, use_kdtree=True, program_locations=None): ...@@ -167,9 +167,9 @@ def ImportModel(filename, use_kdtree=True, program_locations=None):
# the three points are in a line - or two points are identical # the three points are in a line - or two points are identical
# usually this is caused by points, that are too close together # usually this is caused by points, that are too close together
# check the tolerance value in pycam/Geometry/PointKdtree.py # check the tolerance value in pycam/Geometry/PointKdtree.py
log.warn("Skipping invalid triangle: %s / %s / %s" \ log.warn("Skipping invalid triangle: %s / %s / %s " \
% (p1, p2, p3) + " (maybe the resolution of the model" \ % (p1, p2, p3) + "(maybe the resolution of the model " \
+ " is too high?)") + "is too high?)")
continue continue
if n: if n:
t._normal = n t._normal = n
...@@ -223,8 +223,8 @@ def ImportModel(filename, use_kdtree=True, program_locations=None): ...@@ -223,8 +223,8 @@ def ImportModel(filename, use_kdtree=True, program_locations=None):
elif p3 is None: elif p3 is None:
p3 = p p3 = p
else: else:
log.error("STLImporter: ERROR: more then 3 points in " \ log.error("STLImporter: more then 3 points in facet " \
+ "facet (line %d)" % current_line) + "(line %d)" % current_line)
continue continue
m = endloop.match(line) m = endloop.match(line)
if m: if m:
...@@ -234,6 +234,10 @@ def ImportModel(filename, use_kdtree=True, program_locations=None): ...@@ -234,6 +234,10 @@ def ImportModel(filename, use_kdtree=True, program_locations=None):
if not n: if not n:
n = p3.sub(p1).cross(p2.sub(p1)).normalized() n = p3.sub(p1).cross(p2.sub(p1)).normalized()
if n is None:
# invalid triangle (zero-length vector)
dotcross = 0
else:
# make sure the points are in ClockWise order # make sure the points are in ClockWise order
dotcross = n.dot(p3.sub(p1).cross(p2.sub(p1))) dotcross = n.dot(p3.sub(p1).cross(p2.sub(p1)))
if dotcross > 0: if dotcross > 0:
...@@ -247,8 +251,9 @@ def ImportModel(filename, use_kdtree=True, program_locations=None): ...@@ -247,8 +251,9 @@ def ImportModel(filename, use_kdtree=True, program_locations=None):
# identical. Usually this is caused by points, that are too # identical. Usually this is caused by points, that are too
# close together. Check the tolerance value in # close together. Check the tolerance value in
# pycam/Geometry/PointKdtree.py. # pycam/Geometry/PointKdtree.py.
print "ERROR: skipping invalid triangle: %s / %s / %s" \ log.warn("Skipping invalid triangle: %s / %s / %s " \
% (p1, p2, p3) % (p1, p2, p3) + "(maybe the resolution of the " \
+ "model is too high?)")
n, p1, p2, p3 = (None, None, None, None) n, p1, p2, p3 = (None, None, None, None)
continue continue
n, p1, p2, p3 = (None, None, None, None) n, p1, p2, p3 = (None, None, None, None)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment