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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/freestyle/modules/freestyle/functions.py')
-rw-r--r--release/scripts/freestyle/modules/freestyle/functions.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/release/scripts/freestyle/modules/freestyle/functions.py b/release/scripts/freestyle/modules/freestyle/functions.py
index 686dce6615f..379e933862c 100644
--- a/release/scripts/freestyle/modules/freestyle/functions.py
+++ b/release/scripts/freestyle/modules/freestyle/functions.py
@@ -94,6 +94,7 @@ from mathutils import Vector
## Functions for 0D elements (vertices)
#######################################
+
class CurveMaterialF0D(UnaryFunction0DMaterial):
"""
A replacement of the built-in MaterialF0D for stroke creation.
@@ -106,18 +107,21 @@ class CurveMaterialF0D(UnaryFunction0DMaterial):
assert(fe is not None)
return fe.material if fe.is_smooth else fe.material_left
+
class pyInverseCurvature2DAngleF0D(UnaryFunction0DDouble):
def __call__(self, inter):
func = Curvature2DAngleF0D()
c = func(inter)
return (3.1415 - c)
+
class pyCurvilinearLengthF0D(UnaryFunction0DDouble):
def __call__(self, inter):
cp = inter.object
assert(isinstance(cp, CurvePoint))
return cp.t2d
+
class pyDensityAnisotropyF0D(UnaryFunction0DDouble):
"""Estimates the anisotropy of density"""
def __init__(self,level):
@@ -127,6 +131,7 @@ class pyDensityAnisotropyF0D(UnaryFunction0DDouble):
self.d1Density = ReadSteerableViewMapPixelF0D(1, level)
self.d2Density = ReadSteerableViewMapPixelF0D(2, level)
self.d3Density = ReadSteerableViewMapPixelF0D(3, level)
+
def __call__(self, inter):
c_iso = self.IsoDensity(inter)
c_0 = self.d0Density(inter)
@@ -141,6 +146,7 @@ class pyDensityAnisotropyF0D(UnaryFunction0DDouble):
v = (cMax-cMin)/c_iso
return v
+
class pyViewMapGradientVectorF0D(UnaryFunction0DVec2f):
"""Returns the gradient vector for a pixel
@@ -151,6 +157,7 @@ class pyViewMapGradientVectorF0D(UnaryFunction0DVec2f):
UnaryFunction0DVec2f.__init__(self)
self._l = level
self._step = pow(2, self._l)
+
def __call__(self, iter):
p = iter.object.point_2d
gx = CF.read_complete_view_map_pixel(self._l, int(p.x+self._step), int(p.y)) - \
@@ -159,11 +166,13 @@ class pyViewMapGradientVectorF0D(UnaryFunction0DVec2f):
CF.read_complete_view_map_pixel(self._l, int(p.x), int(p.y))
return Vector((gx, gy))
+
class pyViewMapGradientNormF0D(UnaryFunction0DDouble):
def __init__(self, l):
UnaryFunction0DDouble.__init__(self)
self._l = l
self._step = pow(2,self._l)
+
def __call__(self, iter):
p = iter.object.point_2d
gx = CF.read_complete_view_map_pixel(self._l, int(p.x+self._step), int(p.y)) - \
@@ -176,34 +185,40 @@ class pyViewMapGradientNormF0D(UnaryFunction0DDouble):
## Functions for 1D elements (curves)
#####################################
+
class pyGetInverseProjectedZF1D(UnaryFunction1DDouble):
def __call__(self, inter):
func = GetProjectedZF1D()
z = func(inter)
return (1.0 - z)
+
class pyGetSquareInverseProjectedZF1D(UnaryFunction1DDouble):
def __call__(self, inter):
func = GetProjectedZF1D()
z = func(inter)
return (1.0 - z*z)
+
class pyDensityAnisotropyF1D(UnaryFunction1DDouble):
def __init__(self,level, integrationType=IntegrationType.MEAN, sampling=2.0):
UnaryFunction1DDouble.__init__(self, integrationType)
self._func = pyDensityAnisotropyF0D(level)
self._integration = integrationType
self._sampling = sampling
+
def __call__(self, inter):
v = integrate(self._func, inter.points_begin(self._sampling), inter.points_end(self._sampling), self._integration)
return v
+
class pyViewMapGradientNormF1D(UnaryFunction1DDouble):
def __init__(self,l, integrationType, sampling=2.0):
UnaryFunction1DDouble.__init__(self, integrationType)
self._func = pyViewMapGradientNormF0D(l)
self._integration = integrationType
self._sampling = sampling
+
def __call__(self, inter):
v = integrate(self._func, inter.points_begin(self._sampling), inter.points_end(self._sampling), self._integration)
return v