- fixed some bugs in Geometry Editor in regards of Buffer Tool
- fixed some issues in the Cutout Plugin by adding more checks - fixed issues when loading files by dragging in the UI (caused by recent code refactoring)
This commit is contained in:
@@ -11,7 +11,11 @@ from shapely.affinity import rotate
|
||||
from ezdxf.math import Vec3 as ezdxf_vector
|
||||
|
||||
from appParsers.ParseFont import *
|
||||
from appParsers.ParseDXF_Spline import *
|
||||
from appParsers.ParseDXF_Spline import spline2Polyline, normalize_2
|
||||
from appParsers.ParseDXF_Spline import Vector as DxfVector
|
||||
|
||||
import math
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger('base2')
|
||||
@@ -176,7 +180,7 @@ def dxfellipse2shapely(ellipse, ellipse_segments=100):
|
||||
ratio = ellipse.dxf.ratio
|
||||
|
||||
points_list = []
|
||||
major_axis = Vector(list(major_axis))
|
||||
major_axis = DxfVector(list(major_axis))
|
||||
|
||||
major_x = major_axis[0]
|
||||
major_y = major_axis[1]
|
||||
@@ -191,7 +195,7 @@ def dxfellipse2shapely(ellipse, ellipse_segments=100):
|
||||
for step in range(line_seg + 1):
|
||||
if direction == 'CW':
|
||||
major_dim = normalize_2(major_axis)
|
||||
minor_dim = normalize_2(Vector([ratio * k for k in major_axis]))
|
||||
minor_dim = normalize_2(DxfVector([ratio * k for k in major_axis]))
|
||||
vx = (major_dim[0] + major_dim[1]) * math.cos(angle)
|
||||
vy = (minor_dim[0] - minor_dim[1]) * math.sin(angle)
|
||||
x = center[0] + major_x * vx - major_y * vy
|
||||
@@ -199,7 +203,7 @@ def dxfellipse2shapely(ellipse, ellipse_segments=100):
|
||||
angle += step_angle
|
||||
else:
|
||||
major_dim = normalize_2(major_axis)
|
||||
minor_dim = (Vector([ratio * k for k in major_dim]))
|
||||
minor_dim = (DxfVector([ratio * k for k in major_dim]))
|
||||
vx = (major_dim[0] + major_dim[1]) * math.cos(angle)
|
||||
vy = (minor_dim[0] + minor_dim[1]) * math.sin(angle)
|
||||
x = center[0] + major_x * vx + major_y * vy
|
||||
|
||||
@@ -102,7 +102,7 @@ def spline2Polyline(xyz, degree, closed, segments, knots):
|
||||
# equal to the order at the ends.
|
||||
# c = order of the basis function
|
||||
# n = the number of defining polygon vertices
|
||||
# n+2 = index of x[] for the first occurence of the maximum knot vector value
|
||||
# n+2 = index of x[] for the first occurrence of the maximum knot vector value
|
||||
# n+order = maximum value of the knot vector -- $n + c$
|
||||
# x[] = array containing the knot vector
|
||||
# ------------------------------------------------------------------------------
|
||||
@@ -659,167 +659,3 @@ class Vector(list):
|
||||
"""@return the transverse component
|
||||
(R in cylindrical coordinate system)."""
|
||||
return math.sqrt(self.perp2())
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Return a random 3D vector
|
||||
# ----------------------------------------------------------------------
|
||||
# @staticmethod
|
||||
# def random():
|
||||
# cosTheta = 2.0 * random.random() - 1.0
|
||||
# sinTheta = math.sqrt(1.0 - cosTheta ** 2)
|
||||
# phi = 2.0 * math.pi * random.random()
|
||||
# return Vector(math.cos(phi) * sinTheta, math.sin(phi) * sinTheta, cosTheta)
|
||||
|
||||
# #===============================================================================
|
||||
# # Cardinal cubic spline class
|
||||
# #===============================================================================
|
||||
# class CardinalSpline:
|
||||
# def __init__(self, A=0.5):
|
||||
# # The default matrix is the Catmull-Rom spline
|
||||
# # which is equal to Cardinal matrix
|
||||
# # for A = 0.5
|
||||
# #
|
||||
# # Note: Vasilis
|
||||
# # The A parameter should be the fraction in t where
|
||||
# # the second derivative is zero
|
||||
# self.setMatrix(A)
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# # Set the matrix according to Cardinal
|
||||
# #-----------------------------------------------------------------------
|
||||
# def setMatrix(self, A=0.5):
|
||||
# self.M = []
|
||||
# self.M.append([ -A, 2.-A, A-2., A ])
|
||||
# self.M.append([2.*A, A-3., 3.-2.*A, -A ])
|
||||
# self.M.append([ -A, 0., A, 0.])
|
||||
# self.M.append([ 0., 1., 0, 0.])
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# # Evaluate Cardinal spline at position t
|
||||
# # @param P list or tuple with 4 points y positions
|
||||
# # @param t [0..1] fraction of interval from points 1..2
|
||||
# # @param k index of starting 4 elements in P
|
||||
# # @return spline evaluation
|
||||
# #-----------------------------------------------------------------------
|
||||
# def __call__(self, P, t, k=1):
|
||||
# T = [t*t*t, t*t, t, 1.0]
|
||||
# R = [0.0]*4
|
||||
# for i in range(4):
|
||||
# for j in range(4):
|
||||
# R[i] += T[j] * self.M[j][i]
|
||||
# y = 0.0
|
||||
# for i in range(4):
|
||||
# y += R[i]*P[k+i-1]
|
||||
#
|
||||
# return y
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# # Return the coefficients of a 3rd degree polynomial
|
||||
# # f(x) = a t^3 + b t^2 + c t + d
|
||||
# # @return [a, b, c, d]
|
||||
# #-----------------------------------------------------------------------
|
||||
# def coefficients(self, P, k=1):
|
||||
# C = [0.0]*4
|
||||
# for i in range(4):
|
||||
# for j in range(4):
|
||||
# C[i] += self.M[i][j] * P[k+j-1]
|
||||
# return C
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# # Evaluate the value of the spline using the coefficients
|
||||
# #-----------------------------------------------------------------------
|
||||
# def evaluate(self, C, t):
|
||||
# return ((C[0]*t + C[1])*t + C[2])*t + C[3]
|
||||
#
|
||||
# #===============================================================================
|
||||
# # Cubic spline ensuring that the first and second derivative are continuous
|
||||
# # adapted from Penelope Manual Appending B.1
|
||||
# # It requires all the points (xi,yi) and the assumption on how to deal
|
||||
# # with the second derivative on the extremities
|
||||
# # Option 1: assume zero as second derivative on both ends
|
||||
# # Option 2: assume the same as the next or previous one
|
||||
# #===============================================================================
|
||||
# class CubicSpline:
|
||||
# def __init__(self, X, Y):
|
||||
# self.X = X
|
||||
# self.Y = Y
|
||||
# self.n = len(X)
|
||||
#
|
||||
# # Option #1
|
||||
# s1 = 0.0 # zero based = s0
|
||||
# sN = 0.0 # zero based = sN-1
|
||||
#
|
||||
# # Construct the tri-diagonal matrix
|
||||
# A = []
|
||||
# B = [0.0] * (self.n-2)
|
||||
# for i in range(self.n-2):
|
||||
# A.append([0.0] * (self.n-2))
|
||||
#
|
||||
# for i in range(1,self.n-1):
|
||||
# hi = self.h(i)
|
||||
# Hi = 2.0*(self.h(i-1) + hi)
|
||||
# j = i-1
|
||||
# A[j][j] = Hi
|
||||
# if i+1<self.n-1:
|
||||
# A[j][j+1] = A[j+1][j] = hi
|
||||
#
|
||||
# if i==1:
|
||||
# B[j] = 6.*(self.d(i) - self.d(j)) - hi*s1
|
||||
# elif i<self.n-2:
|
||||
# B[j] = 6.*(self.d(i) - self.d(j))
|
||||
# else:
|
||||
# B[j] = 6.*(self.d(i) - self.d(j)) - hi*sN
|
||||
#
|
||||
#
|
||||
# self.s = gauss(A,B)
|
||||
# self.s.insert(0,s1)
|
||||
# self.s.append(sN)
|
||||
# # print ">> s <<"
|
||||
# # pprint(self.s)
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# def h(self, i):
|
||||
# return self.X[i+1] - self.X[i]
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# def d(self, i):
|
||||
# return (self.Y[i+1] - self.Y[i]) / (self.X[i+1] - self.X[i])
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# def coefficients(self, i):
|
||||
# """return coefficients of cubic spline for interval i a*x**3+b*x**2+c*x+d"""
|
||||
# hi = self.h(i)
|
||||
# si = self.s[i]
|
||||
# si1 = self.s[i+1]
|
||||
# xi = self.X[i]
|
||||
# xi1 = self.X[i+1]
|
||||
# fi = self.Y[i]
|
||||
# fi1 = self.Y[i+1]
|
||||
#
|
||||
# a = 1./(6.*hi)*(si*xi1**3 - si1*xi**3 + 6.*(fi*xi1 - fi1*xi)) + hi/6.*(si1*xi - si*xi1)
|
||||
# b = 1./(2.*hi)*(si1*xi**2 - si*xi1**2 + 2*(fi1 - fi)) + hi/6.*(si - si1)
|
||||
# c = 1./(2.*hi)*(si*xi1 - si1*xi)
|
||||
# d = 1./(6.*hi)*(si1-si)
|
||||
#
|
||||
# return [d,c,b,a]
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# def __call__(self, i, x):
|
||||
# C = self.coefficients(i)
|
||||
# return ((C[0]*x + C[1])*x + C[2])*x + C[3]
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# # @return evaluation of cubic spline at x using coefficients C
|
||||
# #-----------------------------------------------------------------------
|
||||
# def evaluate(self, C, x):
|
||||
# return ((C[0]*x + C[1])*x + C[2])*x + C[3]
|
||||
#
|
||||
# #-----------------------------------------------------------------------
|
||||
# # Return evaluated derivative at x using coefficients C
|
||||
# #-----------------------------------------------------------------------
|
||||
# def derivative(self, C, x):
|
||||
# a = 3.0*C[0] # derivative coefficients
|
||||
# b = 2.0*C[1] # ... for sampling with rejection
|
||||
# c = C[2]
|
||||
# return (3.0*C[0]*x + 2.0*C[1])*x + C[2]
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user