Коммит fe6f6f76 создал по автору Ilya Portnov's avatar Ilya Portnov
Просмотр файлов

precision fix.

владелец b4b0740b
......@@ -58,6 +58,12 @@ class SvCurveLengthNode(bpy.types.Node, SverchCustomTreeNode):
min = 0,
update = updateNode)
use_nurbs : BoolProperty(
name = "NURBS",
description = "Use special algorithm for NURBS curves",
default = False,
update = updateNode)
def sv_init(self, context):
self.inputs.new('SvCurveSocket', "Curve")
self.inputs.new('SvStringsSocket', "TMin").prop_name = 't_min'
......@@ -71,6 +77,7 @@ class SvCurveLengthNode(bpy.types.Node, SverchCustomTreeNode):
layout.prop(self, 'specify_accuracy')
if self.specify_accuracy:
layout.prop(self, 'accuracy')
#layout.prop(self, 'use_nurbs')
def draw_buttons_ext(self, context, layout):
self.draw_buttons(context, layout)
......@@ -111,7 +118,10 @@ class SvCurveLengthNode(bpy.types.Node, SverchCustomTreeNode):
resolution = int(resolution * (t_max - t_min) / (curve_t_max - curve_t_min))
if resolution < 1:
resolution = 1
solver = SvCurveLengthSolver(curve)
if self.use_nurbs:
solver = SvNurbsCurveLengthSolver(curve)
else:
solver = SvCurveLengthSolver(curve)
solver.prepare('SPL', resolution, tolerance=tolerance)
length = solver.calc_length(t_min, t_max)
......
......@@ -486,15 +486,16 @@ class SvNurbsCurve(SvCurve):
# angle with `direction`. If not, this is
# clearly not a straight line.
dv = cpt2 - cpt1
dv /= np.linalg.norm(dv)
dv_len = np.linalg.norm(dv)
dv /= dv_len
cos_angle = np.dot(dv, direction)
if use_length_tolerance:
vector2_len = vector_len / cos_angle
if abs(vector2_len - vector_len) > tolerance/10:
dv2_len = dv_len / cos_angle
if abs(dv2_len - dv_len) > tolerance/len(cpts):
return False
else:
tan_angle = sqrt(1.0 - cos_angle**2) / cos_angle
if vector_len * tan_angle > tolerance:
if dv_len * tan_angle > tolerance:
return False
return True
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать