Code cleanup: pep8
This commit is contained in:
@@ -54,8 +54,10 @@ class pyChainSilhouetteIterator(ChainingIterator):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, stayInSelection=True):
|
def __init__(self, stayInSelection=True):
|
||||||
ChainingIterator.__init__(self, stayInSelection, True, None, True)
|
ChainingIterator.__init__(self, stayInSelection, True, None, True)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
it = AdjacencyIterator(iter)
|
it = AdjacencyIterator(iter)
|
||||||
@@ -110,8 +112,10 @@ class pyChainSilhouetteGenericIterator(ChainingIterator):
|
|||||||
|
|
||||||
def __init__(self, stayInSelection=True, stayInUnvisited=True):
|
def __init__(self, stayInSelection=True, stayInUnvisited=True):
|
||||||
ChainingIterator.__init__(self, stayInSelection, stayInUnvisited, None, True)
|
ChainingIterator.__init__(self, stayInSelection, stayInUnvisited, None, True)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
it = AdjacencyIterator(iter)
|
it = AdjacencyIterator(iter)
|
||||||
@@ -161,9 +165,11 @@ class pyExternalContourChainingIterator(ChainingIterator):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
ChainingIterator.__init__(self, False, True, None, True)
|
ChainingIterator.__init__(self, False, True, None, True)
|
||||||
self._isExternalContour = ExternalContourUP1D()
|
self._isExternalContour = ExternalContourUP1D()
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self._nEdges = 0
|
self._nEdges = 0
|
||||||
self._isInSelection = 1
|
self._isInSelection = 1
|
||||||
|
|
||||||
def checkViewEdge(self, ve, orientation):
|
def checkViewEdge(self, ve, orientation):
|
||||||
if orientation != 0:
|
if orientation != 0:
|
||||||
vertex = ve.second_svertex()
|
vertex = ve.second_svertex()
|
||||||
@@ -178,6 +184,7 @@ class pyExternalContourChainingIterator(ChainingIterator):
|
|||||||
if bpy.app.debug_freestyle:
|
if bpy.app.debug_freestyle:
|
||||||
print("pyExternalContourChainingIterator : didn't find next edge")
|
print("pyExternalContourChainingIterator : didn't find next edge")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
it = AdjacencyIterator(iter)
|
it = AdjacencyIterator(iter)
|
||||||
@@ -218,8 +225,10 @@ class pySketchyChainSilhouetteIterator(ChainingIterator):
|
|||||||
ChainingIterator.__init__(self, stayInSelection, False, None, True)
|
ChainingIterator.__init__(self, stayInSelection, False, None, True)
|
||||||
self._timeStamp = CF.get_time_stamp()+nRounds
|
self._timeStamp = CF.get_time_stamp()+nRounds
|
||||||
self._nRounds = nRounds
|
self._nRounds = nRounds
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self._timeStamp = CF.get_time_stamp()+self._nRounds
|
self._timeStamp = CF.get_time_stamp()+self._nRounds
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
it = AdjacencyIterator(iter)
|
it = AdjacencyIterator(iter)
|
||||||
@@ -277,8 +286,10 @@ class pySketchyChainingIterator(ChainingIterator):
|
|||||||
ChainingIterator.__init__(self, stayInSelection, False, None, True)
|
ChainingIterator.__init__(self, stayInSelection, False, None, True)
|
||||||
self._timeStamp = CF.get_time_stamp()+nRounds
|
self._timeStamp = CF.get_time_stamp()+nRounds
|
||||||
self._nRounds = nRounds
|
self._nRounds = nRounds
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self._timeStamp = CF.get_time_stamp()+self._nRounds
|
self._timeStamp = CF.get_time_stamp()+self._nRounds
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
found = False
|
found = False
|
||||||
@@ -316,10 +327,12 @@ class pyFillOcclusionsRelativeChainingIterator(ChainingIterator):
|
|||||||
ChainingIterator.__init__(self, False, True, None, True)
|
ChainingIterator.__init__(self, False, True, None, True)
|
||||||
self._length = 0
|
self._length = 0
|
||||||
self._percent = float(percent)
|
self._percent = float(percent)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# A chain's length should preferably be evaluated only once.
|
# A chain's length should preferably be evaluated only once.
|
||||||
# Therefore, the chain length is reset here.
|
# Therefore, the chain length is reset here.
|
||||||
self._length = 0
|
self._length = 0
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
|
|
||||||
@@ -414,8 +427,10 @@ class pyFillOcclusionsAbsoluteChainingIterator(ChainingIterator):
|
|||||||
def __init__(self, length):
|
def __init__(self, length):
|
||||||
ChainingIterator.__init__(self, False, True, None, True)
|
ChainingIterator.__init__(self, False, True, None, True)
|
||||||
self._length = float(length)
|
self._length = float(length)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
winnerOrientation = False
|
winnerOrientation = False
|
||||||
@@ -481,11 +496,13 @@ class pyFillOcclusionsAbsoluteAndRelativeChainingIterator(ChainingIterator):
|
|||||||
self._length = 0
|
self._length = 0
|
||||||
self._absLength = l
|
self._absLength = l
|
||||||
self._percent = float(percent)
|
self._percent = float(percent)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# each time we're evaluating a chain length
|
# each time we're evaluating a chain length
|
||||||
# we try to do it once. Thus we reinit
|
# we try to do it once. Thus we reinit
|
||||||
# the chain length here:
|
# the chain length here:
|
||||||
self._length = 0
|
self._length = 0
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
winnerOrientation = False
|
winnerOrientation = False
|
||||||
@@ -581,10 +598,12 @@ class pyFillQi0AbsoluteAndRelativeChainingIterator(ChainingIterator):
|
|||||||
self._length = 0
|
self._length = 0
|
||||||
self._absLength = l
|
self._absLength = l
|
||||||
self._percent = float(percent)
|
self._percent = float(percent)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# A chain's length should preverably be evaluated only once.
|
# A chain's length should preverably be evaluated only once.
|
||||||
# Therefore, the chain length is reset here.
|
# Therefore, the chain length is reset here.
|
||||||
self._length = 0
|
self._length = 0
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
winnerOrientation = False
|
winnerOrientation = False
|
||||||
@@ -682,8 +701,10 @@ class pyNoIdChainSilhouetteIterator(ChainingIterator):
|
|||||||
|
|
||||||
def __init__(self, stayInSelection=True):
|
def __init__(self, stayInSelection=True):
|
||||||
ChainingIterator.__init__(self, stayInSelection, True, None, True)
|
ChainingIterator.__init__(self, stayInSelection, True, None, True)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def traverse(self, iter):
|
def traverse(self, iter):
|
||||||
winner = None
|
winner = None
|
||||||
it = AdjacencyIterator(iter)
|
it = AdjacencyIterator(iter)
|
||||||
|
@@ -94,6 +94,7 @@ from mathutils import Vector
|
|||||||
## Functions for 0D elements (vertices)
|
## Functions for 0D elements (vertices)
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
|
||||||
class CurveMaterialF0D(UnaryFunction0DMaterial):
|
class CurveMaterialF0D(UnaryFunction0DMaterial):
|
||||||
"""
|
"""
|
||||||
A replacement of the built-in MaterialF0D for stroke creation.
|
A replacement of the built-in MaterialF0D for stroke creation.
|
||||||
@@ -106,18 +107,21 @@ class CurveMaterialF0D(UnaryFunction0DMaterial):
|
|||||||
assert(fe is not None)
|
assert(fe is not None)
|
||||||
return fe.material if fe.is_smooth else fe.material_left
|
return fe.material if fe.is_smooth else fe.material_left
|
||||||
|
|
||||||
|
|
||||||
class pyInverseCurvature2DAngleF0D(UnaryFunction0DDouble):
|
class pyInverseCurvature2DAngleF0D(UnaryFunction0DDouble):
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = Curvature2DAngleF0D()
|
func = Curvature2DAngleF0D()
|
||||||
c = func(inter)
|
c = func(inter)
|
||||||
return (3.1415 - c)
|
return (3.1415 - c)
|
||||||
|
|
||||||
|
|
||||||
class pyCurvilinearLengthF0D(UnaryFunction0DDouble):
|
class pyCurvilinearLengthF0D(UnaryFunction0DDouble):
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
cp = inter.object
|
cp = inter.object
|
||||||
assert(isinstance(cp, CurvePoint))
|
assert(isinstance(cp, CurvePoint))
|
||||||
return cp.t2d
|
return cp.t2d
|
||||||
|
|
||||||
|
|
||||||
class pyDensityAnisotropyF0D(UnaryFunction0DDouble):
|
class pyDensityAnisotropyF0D(UnaryFunction0DDouble):
|
||||||
"""Estimates the anisotropy of density"""
|
"""Estimates the anisotropy of density"""
|
||||||
def __init__(self,level):
|
def __init__(self,level):
|
||||||
@@ -127,6 +131,7 @@ class pyDensityAnisotropyF0D(UnaryFunction0DDouble):
|
|||||||
self.d1Density = ReadSteerableViewMapPixelF0D(1, level)
|
self.d1Density = ReadSteerableViewMapPixelF0D(1, level)
|
||||||
self.d2Density = ReadSteerableViewMapPixelF0D(2, level)
|
self.d2Density = ReadSteerableViewMapPixelF0D(2, level)
|
||||||
self.d3Density = ReadSteerableViewMapPixelF0D(3, level)
|
self.d3Density = ReadSteerableViewMapPixelF0D(3, level)
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
c_iso = self.IsoDensity(inter)
|
c_iso = self.IsoDensity(inter)
|
||||||
c_0 = self.d0Density(inter)
|
c_0 = self.d0Density(inter)
|
||||||
@@ -141,6 +146,7 @@ class pyDensityAnisotropyF0D(UnaryFunction0DDouble):
|
|||||||
v = (cMax-cMin)/c_iso
|
v = (cMax-cMin)/c_iso
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
class pyViewMapGradientVectorF0D(UnaryFunction0DVec2f):
|
class pyViewMapGradientVectorF0D(UnaryFunction0DVec2f):
|
||||||
"""Returns the gradient vector for a pixel
|
"""Returns the gradient vector for a pixel
|
||||||
|
|
||||||
@@ -151,6 +157,7 @@ class pyViewMapGradientVectorF0D(UnaryFunction0DVec2f):
|
|||||||
UnaryFunction0DVec2f.__init__(self)
|
UnaryFunction0DVec2f.__init__(self)
|
||||||
self._l = level
|
self._l = level
|
||||||
self._step = pow(2, self._l)
|
self._step = pow(2, self._l)
|
||||||
|
|
||||||
def __call__(self, iter):
|
def __call__(self, iter):
|
||||||
p = iter.object.point_2d
|
p = iter.object.point_2d
|
||||||
gx = CF.read_complete_view_map_pixel(self._l, int(p.x+self._step), int(p.y)) - \
|
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))
|
CF.read_complete_view_map_pixel(self._l, int(p.x), int(p.y))
|
||||||
return Vector((gx, gy))
|
return Vector((gx, gy))
|
||||||
|
|
||||||
|
|
||||||
class pyViewMapGradientNormF0D(UnaryFunction0DDouble):
|
class pyViewMapGradientNormF0D(UnaryFunction0DDouble):
|
||||||
def __init__(self, l):
|
def __init__(self, l):
|
||||||
UnaryFunction0DDouble.__init__(self)
|
UnaryFunction0DDouble.__init__(self)
|
||||||
self._l = l
|
self._l = l
|
||||||
self._step = pow(2,self._l)
|
self._step = pow(2,self._l)
|
||||||
|
|
||||||
def __call__(self, iter):
|
def __call__(self, iter):
|
||||||
p = iter.object.point_2d
|
p = iter.object.point_2d
|
||||||
gx = CF.read_complete_view_map_pixel(self._l, int(p.x+self._step), int(p.y)) - \
|
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)
|
## Functions for 1D elements (curves)
|
||||||
#####################################
|
#####################################
|
||||||
|
|
||||||
|
|
||||||
class pyGetInverseProjectedZF1D(UnaryFunction1DDouble):
|
class pyGetInverseProjectedZF1D(UnaryFunction1DDouble):
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetProjectedZF1D()
|
func = GetProjectedZF1D()
|
||||||
z = func(inter)
|
z = func(inter)
|
||||||
return (1.0 - z)
|
return (1.0 - z)
|
||||||
|
|
||||||
|
|
||||||
class pyGetSquareInverseProjectedZF1D(UnaryFunction1DDouble):
|
class pyGetSquareInverseProjectedZF1D(UnaryFunction1DDouble):
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetProjectedZF1D()
|
func = GetProjectedZF1D()
|
||||||
z = func(inter)
|
z = func(inter)
|
||||||
return (1.0 - z*z)
|
return (1.0 - z*z)
|
||||||
|
|
||||||
|
|
||||||
class pyDensityAnisotropyF1D(UnaryFunction1DDouble):
|
class pyDensityAnisotropyF1D(UnaryFunction1DDouble):
|
||||||
def __init__(self,level, integrationType=IntegrationType.MEAN, sampling=2.0):
|
def __init__(self,level, integrationType=IntegrationType.MEAN, sampling=2.0):
|
||||||
UnaryFunction1DDouble.__init__(self, integrationType)
|
UnaryFunction1DDouble.__init__(self, integrationType)
|
||||||
self._func = pyDensityAnisotropyF0D(level)
|
self._func = pyDensityAnisotropyF0D(level)
|
||||||
self._integration = integrationType
|
self._integration = integrationType
|
||||||
self._sampling = sampling
|
self._sampling = sampling
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
v = integrate(self._func, inter.points_begin(self._sampling), inter.points_end(self._sampling), self._integration)
|
v = integrate(self._func, inter.points_begin(self._sampling), inter.points_end(self._sampling), self._integration)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
class pyViewMapGradientNormF1D(UnaryFunction1DDouble):
|
class pyViewMapGradientNormF1D(UnaryFunction1DDouble):
|
||||||
def __init__(self,l, integrationType, sampling=2.0):
|
def __init__(self,l, integrationType, sampling=2.0):
|
||||||
UnaryFunction1DDouble.__init__(self, integrationType)
|
UnaryFunction1DDouble.__init__(self, integrationType)
|
||||||
self._func = pyViewMapGradientNormF0D(l)
|
self._func = pyViewMapGradientNormF0D(l)
|
||||||
self._integration = integrationType
|
self._integration = integrationType
|
||||||
self._sampling = sampling
|
self._sampling = sampling
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
v = integrate(self._func, inter.points_begin(self._sampling), inter.points_end(self._sampling), self._integration)
|
v = integrate(self._func, inter.points_begin(self._sampling), inter.points_end(self._sampling), self._integration)
|
||||||
return v
|
return v
|
||||||
|
@@ -80,29 +80,35 @@ class pyHigherCurvature2DAngleUP0D(UnaryPredicate0D):
|
|||||||
def __init__(self,a):
|
def __init__(self,a):
|
||||||
UnaryPredicate0D.__init__(self)
|
UnaryPredicate0D.__init__(self)
|
||||||
self._a = a
|
self._a = a
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = Curvature2DAngleF0D()
|
func = Curvature2DAngleF0D()
|
||||||
a = func(inter)
|
a = func(inter)
|
||||||
return (a > self._a)
|
return (a > self._a)
|
||||||
|
|
||||||
|
|
||||||
class pyUEqualsUP0D(UnaryPredicate0D):
|
class pyUEqualsUP0D(UnaryPredicate0D):
|
||||||
def __init__(self,u, w):
|
def __init__(self,u, w):
|
||||||
UnaryPredicate0D.__init__(self)
|
UnaryPredicate0D.__init__(self)
|
||||||
self._u = u
|
self._u = u
|
||||||
self._w = w
|
self._w = w
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = pyCurvilinearLengthF0D()
|
func = pyCurvilinearLengthF0D()
|
||||||
u = func(inter)
|
u = func(inter)
|
||||||
return (u > (self._u-self._w)) and (u < (self._u+self._w))
|
return (u > (self._u-self._w)) and (u < (self._u+self._w))
|
||||||
|
|
||||||
|
|
||||||
class pyVertexNatureUP0D(UnaryPredicate0D):
|
class pyVertexNatureUP0D(UnaryPredicate0D):
|
||||||
def __init__(self,nature):
|
def __init__(self,nature):
|
||||||
UnaryPredicate0D.__init__(self)
|
UnaryPredicate0D.__init__(self)
|
||||||
self._nature = nature
|
self._nature = nature
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
v = inter.object
|
v = inter.object
|
||||||
return (v.nature & self._nature) != 0
|
return (v.nature & self._nature) != 0
|
||||||
|
|
||||||
|
|
||||||
## check whether an Interface0DIterator
|
## check whether an Interface0DIterator
|
||||||
## is a TVertex and is the one that is
|
## is a TVertex and is the one that is
|
||||||
## hidden (inferred from the context)
|
## hidden (inferred from the context)
|
||||||
@@ -110,6 +116,7 @@ class pyBackTVertexUP0D(UnaryPredicate0D):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
UnaryPredicate0D.__init__(self)
|
UnaryPredicate0D.__init__(self)
|
||||||
self._getQI = QuantitativeInvisibilityF0D()
|
self._getQI = QuantitativeInvisibilityF0D()
|
||||||
|
|
||||||
def __call__(self, iter):
|
def __call__(self, iter):
|
||||||
if (iter.object.nature & Nature.T_VERTEX) == 0:
|
if (iter.object.nature & Nature.T_VERTEX) == 0:
|
||||||
return False
|
return False
|
||||||
@@ -119,20 +126,24 @@ class pyBackTVertexUP0D(UnaryPredicate0D):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyParameterUP0DGoodOne(UnaryPredicate0D):
|
class pyParameterUP0DGoodOne(UnaryPredicate0D):
|
||||||
def __init__(self,pmin,pmax):
|
def __init__(self,pmin,pmax):
|
||||||
UnaryPredicate0D.__init__(self)
|
UnaryPredicate0D.__init__(self)
|
||||||
self._m = pmin
|
self._m = pmin
|
||||||
self._M = pmax
|
self._M = pmax
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
u = inter.u
|
u = inter.u
|
||||||
return ((u>=self._m) and (u<=self._M))
|
return ((u>=self._m) and (u<=self._M))
|
||||||
|
|
||||||
|
|
||||||
class pyParameterUP0D(UnaryPredicate0D):
|
class pyParameterUP0D(UnaryPredicate0D):
|
||||||
def __init__(self,pmin,pmax):
|
def __init__(self,pmin,pmax):
|
||||||
UnaryPredicate0D.__init__(self)
|
UnaryPredicate0D.__init__(self)
|
||||||
self._m = pmin
|
self._m = pmin
|
||||||
self._M = pmax
|
self._M = pmax
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = Curvature2DAngleF0D()
|
func = Curvature2DAngleF0D()
|
||||||
c = func(inter)
|
c = func(inter)
|
||||||
@@ -144,62 +155,76 @@ class pyParameterUP0D(UnaryPredicate0D):
|
|||||||
## Unary predicates for 1D elements (curves)
|
## Unary predicates for 1D elements (curves)
|
||||||
############################################
|
############################################
|
||||||
|
|
||||||
|
|
||||||
class AndUP1D(UnaryPredicate1D):
|
class AndUP1D(UnaryPredicate1D):
|
||||||
def __init__(self, pred1, pred2):
|
def __init__(self, pred1, pred2):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self.__pred1 = pred1
|
self.__pred1 = pred1
|
||||||
self.__pred2 = pred2
|
self.__pred2 = pred2
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
return self.__pred1(inter) and self.__pred2(inter)
|
return self.__pred1(inter) and self.__pred2(inter)
|
||||||
|
|
||||||
|
|
||||||
class OrUP1D(UnaryPredicate1D):
|
class OrUP1D(UnaryPredicate1D):
|
||||||
def __init__(self, pred1, pred2):
|
def __init__(self, pred1, pred2):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self.__pred1 = pred1
|
self.__pred1 = pred1
|
||||||
self.__pred2 = pred2
|
self.__pred2 = pred2
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
return self.__pred1(inter) or self.__pred2(inter)
|
return self.__pred1(inter) or self.__pred2(inter)
|
||||||
|
|
||||||
|
|
||||||
class NotUP1D(UnaryPredicate1D):
|
class NotUP1D(UnaryPredicate1D):
|
||||||
def __init__(self, pred):
|
def __init__(self, pred):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self.__pred = pred
|
self.__pred = pred
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
return not self.__pred(inter)
|
return not self.__pred(inter)
|
||||||
|
|
||||||
|
|
||||||
class pyNFirstUP1D(UnaryPredicate1D):
|
class pyNFirstUP1D(UnaryPredicate1D):
|
||||||
def __init__(self, n):
|
def __init__(self, n):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self.__n = n
|
self.__n = n
|
||||||
self.__count = 0
|
self.__count = 0
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
self.__count = self.__count + 1
|
self.__count = self.__count + 1
|
||||||
if self.__count <= self.__n:
|
if self.__count <= self.__n:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyHigherLengthUP1D(UnaryPredicate1D):
|
class pyHigherLengthUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,l):
|
def __init__(self,l):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._l = l
|
self._l = l
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
return (inter.length_2d > self._l)
|
return (inter.length_2d > self._l)
|
||||||
|
|
||||||
|
|
||||||
class pyNatureUP1D(UnaryPredicate1D):
|
class pyNatureUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,nature):
|
def __init__(self,nature):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._nature = nature
|
self._nature = nature
|
||||||
self._getNature = CurveNatureF1D()
|
self._getNature = CurveNatureF1D()
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
if(self._getNature(inter) & self._nature):
|
if(self._getNature(inter) & self._nature):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyHigherNumberOfTurnsUP1D(UnaryPredicate1D):
|
class pyHigherNumberOfTurnsUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,n,a):
|
def __init__(self,n,a):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._n = n
|
self._n = n
|
||||||
self._a = a
|
self._a = a
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
count = 0
|
count = 0
|
||||||
func = Curvature2DAngleF0D()
|
func = Curvature2DAngleF0D()
|
||||||
@@ -212,72 +237,85 @@ class pyHigherNumberOfTurnsUP1D(UnaryPredicate1D):
|
|||||||
it.increment()
|
it.increment()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyDensityUP1D(UnaryPredicate1D):
|
class pyDensityUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,wsize,threshold, integration = IntegrationType.MEAN, sampling=2.0):
|
def __init__(self, wsize, threshold, integration=IntegrationType.MEAN, sampling=2.0):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._wsize = wsize
|
self._wsize = wsize
|
||||||
self._threshold = threshold
|
self._threshold = threshold
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
self._func = DensityF1D(self._wsize, self._integration, sampling)
|
self._func = DensityF1D(self._wsize, self._integration, sampling)
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
return (self._func(inter) < self._threshold)
|
return (self._func(inter) < self._threshold)
|
||||||
|
|
||||||
|
|
||||||
class pyLowSteerableViewMapDensityUP1D(UnaryPredicate1D):
|
class pyLowSteerableViewMapDensityUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,threshold, level,integration = IntegrationType.MEAN):
|
def __init__(self, threshold, level, integration=IntegrationType.MEAN):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._threshold = threshold
|
self._threshold = threshold
|
||||||
self._level = level
|
self._level = level
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetSteerableViewMapDensityF1D(self._level, self._integration)
|
func = GetSteerableViewMapDensityF1D(self._level, self._integration)
|
||||||
return (func(inter) < self._threshold)
|
return (func(inter) < self._threshold)
|
||||||
|
|
||||||
|
|
||||||
class pyLowDirectionalViewMapDensityUP1D(UnaryPredicate1D):
|
class pyLowDirectionalViewMapDensityUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,threshold, orientation, level,integration = IntegrationType.MEAN):
|
def __init__(self, threshold, orientation, level, integration=IntegrationType.MEAN):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._threshold = threshold
|
self._threshold = threshold
|
||||||
self._orientation = orientation
|
self._orientation = orientation
|
||||||
self._level = level
|
self._level = level
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetDirectionalViewMapDensityF1D(self._orientation, self._level, self._integration)
|
func = GetDirectionalViewMapDensityF1D(self._orientation, self._level, self._integration)
|
||||||
return (func(inter) < self._threshold)
|
return (func(inter) < self._threshold)
|
||||||
|
|
||||||
|
|
||||||
class pyHighSteerableViewMapDensityUP1D(UnaryPredicate1D):
|
class pyHighSteerableViewMapDensityUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,threshold, level,integration = IntegrationType.MEAN):
|
def __init__(self, threshold, level, integration=IntegrationType.MEAN):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._threshold = threshold
|
self._threshold = threshold
|
||||||
self._level = level
|
self._level = level
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
self._func = GetSteerableViewMapDensityF1D(self._level, self._integration)
|
self._func = GetSteerableViewMapDensityF1D(self._level, self._integration)
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
return (self._func(inter) > self._threshold)
|
return (self._func(inter) > self._threshold)
|
||||||
|
|
||||||
|
|
||||||
class pyHighDirectionalViewMapDensityUP1D(UnaryPredicate1D):
|
class pyHighDirectionalViewMapDensityUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,threshold, orientation, level,integration = IntegrationType.MEAN, sampling=2.0):
|
def __init__(self, threshold, orientation, level, integration=IntegrationType.MEAN, sampling=2.0):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._threshold = threshold
|
self._threshold = threshold
|
||||||
self._orientation = orientation
|
self._orientation = orientation
|
||||||
self._level = level
|
self._level = level
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
self._sampling = sampling
|
self._sampling = sampling
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetDirectionalViewMapDensityF1D(self._orientation, self._level, self._integration, self._sampling)
|
func = GetDirectionalViewMapDensityF1D(self._orientation, self._level, self._integration, self._sampling)
|
||||||
return (func(inter) > self._threshold)
|
return (func(inter) > self._threshold)
|
||||||
|
|
||||||
|
|
||||||
class pyHighViewMapDensityUP1D(UnaryPredicate1D):
|
class pyHighViewMapDensityUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,threshold, level,integration = IntegrationType.MEAN, sampling=2.0):
|
def __init__(self, threshold, level, integration=IntegrationType.MEAN, sampling=2.0):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._threshold = threshold
|
self._threshold = threshold
|
||||||
self._level = level
|
self._level = level
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
self._sampling = sampling
|
self._sampling = sampling
|
||||||
self._func = GetCompleteViewMapDensityF1D(self._level, self._integration, self._sampling) # 2.0 is the smpling
|
self._func = GetCompleteViewMapDensityF1D(self._level, self._integration, self._sampling) # 2.0 is the smpling
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
return (self._func(inter) > self._threshold)
|
return (self._func(inter) > self._threshold)
|
||||||
|
|
||||||
|
|
||||||
class pyDensityFunctorUP1D(UnaryPredicate1D):
|
class pyDensityFunctorUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,wsize,threshold, functor, funcmin=0.0, funcmax=1.0, integration = IntegrationType.MEAN):
|
def __init__(self, wsize, threshold, functor, funcmin=0.0, funcmax=1.0, integration=IntegrationType.MEAN):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._wsize = wsize
|
self._wsize = wsize
|
||||||
self._threshold = float(threshold)
|
self._threshold = float(threshold)
|
||||||
@@ -285,6 +323,7 @@ class pyDensityFunctorUP1D(UnaryPredicate1D):
|
|||||||
self._funcmin = float(funcmin)
|
self._funcmin = float(funcmin)
|
||||||
self._funcmax = float(funcmax)
|
self._funcmax = float(funcmax)
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = DensityF1D(self._wsize, self._integration)
|
func = DensityF1D(self._wsize, self._integration)
|
||||||
res = self._functor(inter)
|
res = self._functor(inter)
|
||||||
@@ -297,14 +336,17 @@ class pyZSmallerUP1D(UnaryPredicate1D):
|
|||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._z = z
|
self._z = z
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetProjectedZF1D(self._integration)
|
func = GetProjectedZF1D(self._integration)
|
||||||
return (func(inter) < self._z)
|
return (func(inter) < self._z)
|
||||||
|
|
||||||
|
|
||||||
class pyIsOccludedByUP1D(UnaryPredicate1D):
|
class pyIsOccludedByUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,id):
|
def __init__(self,id):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._id = id
|
self._id = id
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetShapeF1D()
|
func = GetShapeF1D()
|
||||||
shapes = func(inter)
|
shapes = func(inter)
|
||||||
@@ -338,10 +380,12 @@ class pyIsOccludedByUP1D(UnaryPredicate1D):
|
|||||||
eit.increment()
|
eit.increment()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyIsInOccludersListUP1D(UnaryPredicate1D):
|
class pyIsInOccludersListUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,id):
|
def __init__(self,id):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._id = id
|
self._id = id
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetOccludersF1D()
|
func = GetOccludersF1D()
|
||||||
occluders = func(inter)
|
occluders = func(inter)
|
||||||
@@ -350,11 +394,13 @@ class pyIsInOccludersListUP1D(UnaryPredicate1D):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyIsOccludedByItselfUP1D(UnaryPredicate1D):
|
class pyIsOccludedByItselfUP1D(UnaryPredicate1D):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self.__func1 = GetOccludersF1D()
|
self.__func1 = GetOccludersF1D()
|
||||||
self.__func2 = GetShapeF1D()
|
self.__func2 = GetShapeF1D()
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
lst1 = self.__func1(inter)
|
lst1 = self.__func1(inter)
|
||||||
lst2 = self.__func2(inter)
|
lst2 = self.__func2(inter)
|
||||||
@@ -364,11 +410,13 @@ class pyIsOccludedByItselfUP1D(UnaryPredicate1D):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyIsOccludedByIdListUP1D(UnaryPredicate1D):
|
class pyIsOccludedByIdListUP1D(UnaryPredicate1D):
|
||||||
def __init__(self, idlist):
|
def __init__(self, idlist):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._idlist = idlist
|
self._idlist = idlist
|
||||||
self.__func1 = GetOccludersF1D()
|
self.__func1 = GetOccludersF1D()
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
lst1 = self.__func1(inter)
|
lst1 = self.__func1(inter)
|
||||||
for vs1 in lst1:
|
for vs1 in lst1:
|
||||||
@@ -377,24 +425,28 @@ class pyIsOccludedByIdListUP1D(UnaryPredicate1D):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyShapeIdListUP1D(UnaryPredicate1D):
|
class pyShapeIdListUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,idlist):
|
def __init__(self,idlist):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._idlist = idlist
|
self._idlist = idlist
|
||||||
self._funcs = []
|
self._funcs = []
|
||||||
for _id in idlist :
|
for _id in idlist:
|
||||||
self._funcs.append(ShapeUP1D(_id.first, _id.second))
|
self._funcs.append(ShapeUP1D(_id.first, _id.second))
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
for func in self._funcs:
|
for func in self._funcs:
|
||||||
if func(inter) == 1:
|
if func(inter) == 1:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
## deprecated
|
## deprecated
|
||||||
class pyShapeIdUP1D(UnaryPredicate1D):
|
class pyShapeIdUP1D(UnaryPredicate1D):
|
||||||
def __init__(self, _id):
|
def __init__(self, _id):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._id = _id
|
self._id = _id
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
func = GetShapeF1D()
|
func = GetShapeF1D()
|
||||||
shapes = func(inter)
|
shapes = func(inter)
|
||||||
@@ -403,26 +455,31 @@ class pyShapeIdUP1D(UnaryPredicate1D):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class pyHighDensityAnisotropyUP1D(UnaryPredicate1D):
|
class pyHighDensityAnisotropyUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,threshold, level, sampling=2.0):
|
def __init__(self,threshold, level, sampling=2.0):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._l = threshold
|
self._l = threshold
|
||||||
self.func = pyDensityAnisotropyF1D(level, IntegrationType.MEAN, sampling)
|
self.func = pyDensityAnisotropyF1D(level, IntegrationType.MEAN, sampling)
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
return (self.func(inter) > self._l)
|
return (self.func(inter) > self._l)
|
||||||
|
|
||||||
|
|
||||||
class pyHighViewMapGradientNormUP1D(UnaryPredicate1D):
|
class pyHighViewMapGradientNormUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,threshold, l, sampling=2.0):
|
def __init__(self,threshold, l, sampling=2.0):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._threshold = threshold
|
self._threshold = threshold
|
||||||
self._GetGradient = pyViewMapGradientNormF1D(l, IntegrationType.MEAN)
|
self._GetGradient = pyViewMapGradientNormF1D(l, IntegrationType.MEAN)
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
gn = self._GetGradient(inter)
|
gn = self._GetGradient(inter)
|
||||||
#print(gn)
|
#print(gn)
|
||||||
return (gn > self._threshold)
|
return (gn > self._threshold)
|
||||||
|
|
||||||
|
|
||||||
class pyDensityVariableSigmaUP1D(UnaryPredicate1D):
|
class pyDensityVariableSigmaUP1D(UnaryPredicate1D):
|
||||||
def __init__(self,functor, sigmaMin,sigmaMax, lmin, lmax, tmin, tmax, integration = IntegrationType.MEAN, sampling=2.0):
|
def __init__(self, functor, sigmaMin, sigmaMax, lmin, lmax, tmin, tmax, integration=IntegrationType.MEAN, sampling=2.0):
|
||||||
UnaryPredicate1D.__init__(self)
|
UnaryPredicate1D.__init__(self)
|
||||||
self._functor = functor
|
self._functor = functor
|
||||||
self._sigmaMin = float(sigmaMin)
|
self._sigmaMin = float(sigmaMin)
|
||||||
@@ -433,6 +490,7 @@ class pyDensityVariableSigmaUP1D(UnaryPredicate1D):
|
|||||||
self._tmax = tmax
|
self._tmax = tmax
|
||||||
self._integration = integration
|
self._integration = integration
|
||||||
self._sampling = sampling
|
self._sampling = sampling
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
sigma = (self._sigmaMax-self._sigmaMin)/(self._lmax-self._lmin)*(self._functor(inter)-self._lmin) + self._sigmaMin
|
sigma = (self._sigmaMax-self._sigmaMin)/(self._lmax-self._lmin)*(self._functor(inter)-self._lmin) + self._sigmaMin
|
||||||
t = (self._tmax-self._tmin)/(self._lmax-self._lmin)*(self._functor(inter)-self._lmin) + self._tmin
|
t = (self._tmax-self._tmin)/(self._lmax-self._lmin)*(self._functor(inter)-self._lmin) + self._tmin
|
||||||
@@ -440,6 +498,7 @@ class pyDensityVariableSigmaUP1D(UnaryPredicate1D):
|
|||||||
self._func = DensityF1D(sigma, self._integration, self._sampling)
|
self._func = DensityF1D(sigma, self._integration, self._sampling)
|
||||||
return (self._func(inter) < t)
|
return (self._func(inter) < t)
|
||||||
|
|
||||||
|
|
||||||
class pyClosedCurveUP1D(UnaryPredicate1D):
|
class pyClosedCurveUP1D(UnaryPredicate1D):
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
it = inter.vertices_begin()
|
it = inter.vertices_begin()
|
||||||
@@ -456,22 +515,27 @@ class pyClosedCurveUP1D(UnaryPredicate1D):
|
|||||||
## Binary predicates for 1D elements (curves)
|
## Binary predicates for 1D elements (curves)
|
||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
|
|
||||||
class pyZBP1D(BinaryPredicate1D):
|
class pyZBP1D(BinaryPredicate1D):
|
||||||
def __call__(self, i1, i2):
|
def __call__(self, i1, i2):
|
||||||
func = GetZF1D()
|
func = GetZF1D()
|
||||||
return (func(i1) > func(i2))
|
return (func(i1) > func(i2))
|
||||||
|
|
||||||
|
|
||||||
class pyZDiscontinuityBP1D(BinaryPredicate1D):
|
class pyZDiscontinuityBP1D(BinaryPredicate1D):
|
||||||
def __init__(self, iType = IntegrationType.MEAN):
|
def __init__(self, iType=IntegrationType.MEAN):
|
||||||
BinaryPredicate1D.__init__(self)
|
BinaryPredicate1D.__init__(self)
|
||||||
self._GetZDiscontinuity = ZDiscontinuityF1D(iType)
|
self._GetZDiscontinuity = ZDiscontinuityF1D(iType)
|
||||||
|
|
||||||
def __call__(self, i1, i2):
|
def __call__(self, i1, i2):
|
||||||
return (self._GetZDiscontinuity(i1) > self._GetZDiscontinuity(i2))
|
return (self._GetZDiscontinuity(i1) > self._GetZDiscontinuity(i2))
|
||||||
|
|
||||||
|
|
||||||
class pyLengthBP1D(BinaryPredicate1D):
|
class pyLengthBP1D(BinaryPredicate1D):
|
||||||
def __call__(self, i1, i2):
|
def __call__(self, i1, i2):
|
||||||
return (i1.length_2d > i2.length_2d)
|
return (i1.length_2d > i2.length_2d)
|
||||||
|
|
||||||
|
|
||||||
class pySilhouetteFirstBP1D(BinaryPredicate1D):
|
class pySilhouetteFirstBP1D(BinaryPredicate1D):
|
||||||
def __call__(self, inter1, inter2):
|
def __call__(self, inter1, inter2):
|
||||||
bpred = SameShapeIdBP1D()
|
bpred = SameShapeIdBP1D()
|
||||||
@@ -481,22 +545,27 @@ class pySilhouetteFirstBP1D(BinaryPredicate1D):
|
|||||||
return (inter2.nature & Nature.SILHOUETTE) != 0
|
return (inter2.nature & Nature.SILHOUETTE) != 0
|
||||||
return (inter1.nature == inter2.nature)
|
return (inter1.nature == inter2.nature)
|
||||||
|
|
||||||
|
|
||||||
class pyNatureBP1D(BinaryPredicate1D):
|
class pyNatureBP1D(BinaryPredicate1D):
|
||||||
def __call__(self, inter1, inter2):
|
def __call__(self, inter1, inter2):
|
||||||
return (inter1.nature & inter2.nature)
|
return (inter1.nature & inter2.nature)
|
||||||
|
|
||||||
|
|
||||||
class pyViewMapGradientNormBP1D(BinaryPredicate1D):
|
class pyViewMapGradientNormBP1D(BinaryPredicate1D):
|
||||||
def __init__(self,l, sampling=2.0):
|
def __init__(self,l, sampling=2.0):
|
||||||
BinaryPredicate1D.__init__(self)
|
BinaryPredicate1D.__init__(self)
|
||||||
self._GetGradient = pyViewMapGradientNormF1D(l, IntegrationType.MEAN)
|
self._GetGradient = pyViewMapGradientNormF1D(l, IntegrationType.MEAN)
|
||||||
|
|
||||||
def __call__(self, i1,i2):
|
def __call__(self, i1,i2):
|
||||||
#print("compare gradient")
|
#print("compare gradient")
|
||||||
return (self._GetGradient(i1) > self._GetGradient(i2))
|
return (self._GetGradient(i1) > self._GetGradient(i2))
|
||||||
|
|
||||||
|
|
||||||
class pyShuffleBP1D(BinaryPredicate1D):
|
class pyShuffleBP1D(BinaryPredicate1D):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
BinaryPredicate1D.__init__(self)
|
BinaryPredicate1D.__init__(self)
|
||||||
random.seed(1)
|
random.seed(1)
|
||||||
|
|
||||||
def __call__(self, inter1, inter2):
|
def __call__(self, inter1, inter2):
|
||||||
r1 = random.uniform(0,1)
|
r1 = random.uniform(0,1)
|
||||||
r2 = random.uniform(0,1)
|
r2 = random.uniform(0,1)
|
||||||
|
@@ -93,6 +93,7 @@ class pyDepthDiscontinuityThicknessShader(StrokeShader):
|
|||||||
self.__min = float(min)
|
self.__min = float(min)
|
||||||
self.__max = float(max)
|
self.__max = float(max)
|
||||||
self.__func = ZDiscontinuityF0D()
|
self.__func = ZDiscontinuityF0D()
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
z_min=0.0
|
z_min=0.0
|
||||||
z_max=1.0
|
z_max=1.0
|
||||||
@@ -105,6 +106,7 @@ class pyDepthDiscontinuityThicknessShader(StrokeShader):
|
|||||||
it.object.attribute.thickness = (thickness, thickness)
|
it.object.attribute.thickness = (thickness, thickness)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyConstantThicknessShader(StrokeShader):
|
class pyConstantThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns a constant thickness along the stroke
|
Assigns a constant thickness along the stroke
|
||||||
@@ -112,6 +114,7 @@ class pyConstantThicknessShader(StrokeShader):
|
|||||||
def __init__(self, thickness):
|
def __init__(self, thickness):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._thickness = thickness
|
self._thickness = thickness
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
@@ -119,6 +122,7 @@ class pyConstantThicknessShader(StrokeShader):
|
|||||||
it.object.attribute.thickness = (t, t)
|
it.object.attribute.thickness = (t, t)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyFXSVaryingThicknessWithDensityShader(StrokeShader):
|
class pyFXSVaryingThicknessWithDensityShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assings thickness to a stroke based on the density of the diffuse map
|
Assings thickness to a stroke based on the density of the diffuse map
|
||||||
@@ -130,6 +134,7 @@ class pyFXSVaryingThicknessWithDensityShader(StrokeShader):
|
|||||||
self.threshold_max= threshold_max
|
self.threshold_max= threshold_max
|
||||||
self._thicknessMin = thicknessMin
|
self._thicknessMin = thicknessMin
|
||||||
self._thicknessMax = thicknessMax
|
self._thicknessMax = thicknessMax
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
n = stroke.stroke_vertices_size()
|
n = stroke.stroke_vertices_size()
|
||||||
i = 0
|
i = 0
|
||||||
@@ -147,6 +152,7 @@ class pyFXSVaryingThicknessWithDensityShader(StrokeShader):
|
|||||||
i = i+1
|
i = i+1
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyIncreasingThicknessShader(StrokeShader):
|
class pyIncreasingThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Increasingly thickens the stroke
|
Increasingly thickens the stroke
|
||||||
@@ -155,6 +161,7 @@ class pyIncreasingThicknessShader(StrokeShader):
|
|||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._thicknessMin = thicknessMin
|
self._thicknessMin = thicknessMin
|
||||||
self._thicknessMax = thicknessMax
|
self._thicknessMax = thicknessMax
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
n = stroke.stroke_vertices_size()
|
n = stroke.stroke_vertices_size()
|
||||||
i = 0
|
i = 0
|
||||||
@@ -169,6 +176,7 @@ class pyIncreasingThicknessShader(StrokeShader):
|
|||||||
i = i+1
|
i = i+1
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyConstrainedIncreasingThicknessShader(StrokeShader):
|
class pyConstrainedIncreasingThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Increasingly thickens the stroke, constrained by a ratio of the
|
Increasingly thickens the stroke, constrained by a ratio of the
|
||||||
@@ -179,6 +187,7 @@ class pyConstrainedIncreasingThicknessShader(StrokeShader):
|
|||||||
self._thicknessMin = thicknessMin
|
self._thicknessMin = thicknessMin
|
||||||
self._thicknessMax = thicknessMax
|
self._thicknessMax = thicknessMax
|
||||||
self._ratio = ratio
|
self._ratio = ratio
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
slength = stroke.length_2d
|
slength = stroke.length_2d
|
||||||
tmp = self._ratio*slength
|
tmp = self._ratio*slength
|
||||||
@@ -203,6 +212,7 @@ class pyConstrainedIncreasingThicknessShader(StrokeShader):
|
|||||||
i = i+1
|
i = i+1
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyDecreasingThicknessShader(StrokeShader):
|
class pyDecreasingThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Inverse of pyIncreasingThicknessShader, decreasingly thickens the stroke
|
Inverse of pyIncreasingThicknessShader, decreasingly thickens the stroke
|
||||||
@@ -211,6 +221,7 @@ class pyDecreasingThicknessShader(StrokeShader):
|
|||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._thicknessMin = thicknessMin
|
self._thicknessMin = thicknessMin
|
||||||
self._thicknessMax = thicknessMax
|
self._thicknessMax = thicknessMax
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
l = stroke.length_2d
|
l = stroke.length_2d
|
||||||
tMax = self._thicknessMax
|
tMax = self._thicknessMax
|
||||||
@@ -229,6 +240,7 @@ class pyDecreasingThicknessShader(StrokeShader):
|
|||||||
i = i+1
|
i = i+1
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyNonLinearVaryingThicknessShader(StrokeShader):
|
class pyNonLinearVaryingThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns thickness to a stroke based on an exponential function
|
Assigns thickness to a stroke based on an exponential function
|
||||||
@@ -238,6 +250,7 @@ class pyNonLinearVaryingThicknessShader(StrokeShader):
|
|||||||
self._thicknessMin = thicknessMiddle
|
self._thicknessMin = thicknessMiddle
|
||||||
self._thicknessMax = thicknessExtremity
|
self._thicknessMax = thicknessExtremity
|
||||||
self._exponent = exponent
|
self._exponent = exponent
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
n = stroke.stroke_vertices_size()
|
n = stroke.stroke_vertices_size()
|
||||||
i = 0
|
i = 0
|
||||||
@@ -252,9 +265,11 @@ class pyNonLinearVaryingThicknessShader(StrokeShader):
|
|||||||
it.object.attribute.thickness = (t/2.0, t/2.0)
|
it.object.attribute.thickness = (t/2.0, t/2.0)
|
||||||
i = i+1
|
i = i+1
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
def smoothC(self, a, exp):
|
def smoothC(self, a, exp):
|
||||||
return pow(float(a), exp) * pow(2.0, exp)
|
return pow(float(a), exp) * pow(2.0, exp)
|
||||||
|
|
||||||
|
|
||||||
class pySLERPThicknessShader(StrokeShader):
|
class pySLERPThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns thickness to a stroke based on spherical linear interpolation
|
Assigns thickness to a stroke based on spherical linear interpolation
|
||||||
@@ -264,6 +279,7 @@ class pySLERPThicknessShader(StrokeShader):
|
|||||||
self._thicknessMin = thicknessMin
|
self._thicknessMin = thicknessMin
|
||||||
self._thicknessMax = thicknessMax
|
self._thicknessMax = thicknessMax
|
||||||
self._omega = omega
|
self._omega = omega
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
slength = stroke.length_2d
|
slength = stroke.length_2d
|
||||||
tmp = 0.33*slength
|
tmp = 0.33*slength
|
||||||
@@ -283,6 +299,7 @@ class pySLERPThicknessShader(StrokeShader):
|
|||||||
i = i+1
|
i = i+1
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyTVertexThickenerShader(StrokeShader): ## FIXME
|
class pyTVertexThickenerShader(StrokeShader): ## FIXME
|
||||||
"""
|
"""
|
||||||
Thickens TVertices (visual intersections between two edges)
|
Thickens TVertices (visual intersections between two edges)
|
||||||
@@ -291,6 +308,7 @@ class pyTVertexThickenerShader(StrokeShader): ## FIXME
|
|||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._a = a
|
self._a = a
|
||||||
self._n = n
|
self._n = n
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
predTVertex = pyVertexNatureUP0D(Nature.T_VERTEX)
|
predTVertex = pyVertexNatureUP0D(Nature.T_VERTEX)
|
||||||
@@ -333,6 +351,7 @@ class pyTVertexThickenerShader(StrokeShader): ## FIXME
|
|||||||
att.thickness = (r*tr, r*tl)
|
att.thickness = (r*tr, r*tl)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyImportance2DThicknessShader(StrokeShader):
|
class pyImportance2DThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns thickness based on distance to a given point in 2D space.
|
Assigns thickness based on distance to a given point in 2D space.
|
||||||
@@ -346,6 +365,7 @@ class pyImportance2DThicknessShader(StrokeShader):
|
|||||||
self._w = float(w)
|
self._w = float(w)
|
||||||
self._kmin = float(kmin)
|
self._kmin = float(kmin)
|
||||||
self._kmax = float(kmax)
|
self._kmax = float(kmax)
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
origin = Vector((self._x, self._y))
|
origin = Vector((self._x, self._y))
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
@@ -361,6 +381,7 @@ class pyImportance2DThicknessShader(StrokeShader):
|
|||||||
att.thickness = (k*tr/2.0, k*tl/2.0)
|
att.thickness = (k*tr/2.0, k*tl/2.0)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyImportance3DThicknessShader(StrokeShader):
|
class pyImportance3DThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns thickness based on distance to a given point in 3D space
|
Assigns thickness based on distance to a given point in 3D space
|
||||||
@@ -373,6 +394,7 @@ class pyImportance3DThicknessShader(StrokeShader):
|
|||||||
self._w = float(w)
|
self._w = float(w)
|
||||||
self._kmin = float(kmin)
|
self._kmin = float(kmin)
|
||||||
self._kmax = float(kmax)
|
self._kmax = float(kmax)
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
origin = Vector((self._x, self._y, self._z))
|
origin = Vector((self._x, self._y, self._z))
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
@@ -389,6 +411,7 @@ class pyImportance3DThicknessShader(StrokeShader):
|
|||||||
att.thickness = (k*tr/2.0, k*tl/2.0)
|
att.thickness = (k*tr/2.0, k*tl/2.0)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyZDependingThicknessShader(StrokeShader):
|
class pyZDependingThicknessShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns thickness based on an object's local Z depth (point
|
Assigns thickness based on an object's local Z depth (point
|
||||||
@@ -399,6 +422,7 @@ class pyZDependingThicknessShader(StrokeShader):
|
|||||||
self.__min = min
|
self.__min = min
|
||||||
self.__max = max
|
self.__max = max
|
||||||
self.__func = GetProjectedZF0D()
|
self.__func = GetProjectedZF0D()
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
z_min = 1
|
z_min = 1
|
||||||
@@ -426,12 +450,13 @@ class pyConstantColorShader(StrokeShader):
|
|||||||
"""
|
"""
|
||||||
Assigns a constant color to the stroke
|
Assigns a constant color to the stroke
|
||||||
"""
|
"""
|
||||||
def __init__(self,r,g,b, a = 1):
|
def __init__(self, r, g, b, a=1):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._r = r
|
self._r = r
|
||||||
self._g = g
|
self._g = g
|
||||||
self._b = b
|
self._b = b
|
||||||
self._a = a
|
self._a = a
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
@@ -449,19 +474,20 @@ class pyIncreasingColorShader(StrokeShader):
|
|||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._c1 = [r1,g1,b1,a1]
|
self._c1 = [r1,g1,b1,a1]
|
||||||
self._c2 = [r2,g2,b2,a2]
|
self._c2 = [r2,g2,b2,a2]
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
n = stroke.stroke_vertices_size() - 1
|
n = stroke.stroke_vertices_size() - 1
|
||||||
inc = 0
|
inc = 0
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
att = it.object.attribute
|
att = it.object.attribute
|
||||||
c = float(inc)/float(n)
|
c = float(inc) / float(n)
|
||||||
|
|
||||||
att.color = ((1-c)*self._c1[0] + c*self._c2[0],
|
att.color = ((1.0 - c) * self._c1[0] + c * self._c2[0],
|
||||||
(1-c)*self._c1[1] + c*self._c2[1],
|
(1.0 - c) * self._c1[1] + c * self._c2[1],
|
||||||
(1-c)*self._c1[2] + c*self._c2[2])
|
(1.0 - c) * self._c1[2] + c * self._c2[2])
|
||||||
att.alpha = (1-c)*self._c1[3] + c*self._c2[3]
|
att.alpha = (1.0 - c) * self._c1[3] + c * self._c2[3]
|
||||||
inc = inc+1
|
inc = inc + 1
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
@@ -473,21 +499,23 @@ class pyInterpolateColorShader(StrokeShader):
|
|||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._c1 = [r1,g1,b1,a1]
|
self._c1 = [r1,g1,b1,a1]
|
||||||
self._c2 = [r2,g2,b2,a2]
|
self._c2 = [r2,g2,b2,a2]
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
n = stroke.stroke_vertices_size() - 1
|
n = stroke.stroke_vertices_size() - 1
|
||||||
inc = 0
|
inc = 0
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
att = it.object.attribute
|
att = it.object.attribute
|
||||||
u = float(inc)/float(n)
|
u = float(inc) / float(n)
|
||||||
c = 1 - 2 * abs(u - 0.5)
|
c = 1.0 - 2.0 * abs(u - 0.5)
|
||||||
att.color = ((1-c)*self._c1[0] + c*self._c2[0],
|
att.color = ((1.0 - c) * self._c1[0] + c * self._c2[0],
|
||||||
(1-c)*self._c1[1] + c*self._c2[1],
|
(1.0 - c) * self._c1[1] + c * self._c2[1],
|
||||||
(1-c)*self._c1[2] + c*self._c2[2])
|
(1.0 - c) * self._c1[2] + c * self._c2[2])
|
||||||
att.alpha = (1-c)*self._c1[3] + c*self._c2[3]
|
att.alpha = (1.0-c) * self._c1[3] + c * self._c2[3]
|
||||||
inc = inc+1
|
inc = inc+1
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyMaterialColorShader(StrokeShader):
|
class pyMaterialColorShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns the color of the underlying material to the stroke
|
Assigns the color of the underlying material to the stroke
|
||||||
@@ -495,6 +523,7 @@ class pyMaterialColorShader(StrokeShader):
|
|||||||
def __init__(self, threshold=50):
|
def __init__(self, threshold=50):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._threshold = threshold
|
self._threshold = threshold
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
func = MaterialF0D()
|
func = MaterialF0D()
|
||||||
@@ -536,8 +565,8 @@ class pyMaterialColorShader(StrokeShader):
|
|||||||
v = V / (13. * L) + vn
|
v = V / (13. * L) + vn
|
||||||
|
|
||||||
Y = Yn * pow(((L+16.)/116.), 3.)
|
Y = Yn * pow(((L+16.)/116.), 3.)
|
||||||
X = -9. * Y * u / ((u - 4.)* v - u * v)
|
X = -9.0 * Y * u / ((u - 4.0) * v - u * v)
|
||||||
Z = (9. * Y - 15*v*Y - v*X) /( 3. * v)
|
Z = (9.0 * Y - 15.0 * v * Y - v * X) / (3.0 * v)
|
||||||
|
|
||||||
r = 3.240479 * X - 1.53715 * Y - 0.498535 * Z
|
r = 3.240479 * X - 1.53715 * Y - 0.498535 * Z
|
||||||
g = -0.969256 * X + 1.875991 * Y + 0.041556 * Z
|
g = -0.969256 * X + 1.875991 * Y + 0.041556 * Z
|
||||||
@@ -550,6 +579,7 @@ class pyMaterialColorShader(StrokeShader):
|
|||||||
it.object.attribute.color = (r, g, b)
|
it.object.attribute.color = (r, g, b)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyRandomColorShader(StrokeShader):
|
class pyRandomColorShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns a color to the stroke based on given seed
|
Assigns a color to the stroke based on given seed
|
||||||
@@ -557,6 +587,7 @@ class pyRandomColorShader(StrokeShader):
|
|||||||
def __init__(self, s=1):
|
def __init__(self, s=1):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
random.seed(s)
|
random.seed(s)
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
## pick a random color
|
## pick a random color
|
||||||
c0 = float(random.uniform(15,75))/100.0
|
c0 = float(random.uniform(15,75))/100.0
|
||||||
@@ -568,6 +599,7 @@ class pyRandomColorShader(StrokeShader):
|
|||||||
it.object.attribute.color = (c0,c1,c2)
|
it.object.attribute.color = (c0,c1,c2)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class py2DCurvatureColorShader(StrokeShader):
|
class py2DCurvatureColorShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns a color (greyscale) to the stroke based on the curvature.
|
Assigns a color (greyscale) to the stroke based on the curvature.
|
||||||
@@ -584,6 +616,7 @@ class py2DCurvatureColorShader(StrokeShader):
|
|||||||
it.object.attribute.color = (color, color, color)
|
it.object.attribute.color = (color, color, color)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyTimeColorShader(StrokeShader):
|
class pyTimeColorShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Assigns a greyscale value that increases for every vertex.
|
Assigns a greyscale value that increases for every vertex.
|
||||||
@@ -592,6 +625,7 @@ class pyTimeColorShader(StrokeShader):
|
|||||||
def __init__(self, step=0.01):
|
def __init__(self, step=0.01):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._step = step
|
self._step = step
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
for i, svert in enumerate(iter(stroke)):
|
for i, svert in enumerate(iter(stroke)):
|
||||||
c = i * self._step
|
c = i * self._step
|
||||||
@@ -599,6 +633,7 @@ class pyTimeColorShader(StrokeShader):
|
|||||||
|
|
||||||
## geometry modifiers
|
## geometry modifiers
|
||||||
|
|
||||||
|
|
||||||
class pySamplingShader(StrokeShader):
|
class pySamplingShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Resamples the stroke, which gives the stroke the ammount of
|
Resamples the stroke, which gives the stroke the ammount of
|
||||||
@@ -607,10 +642,12 @@ class pySamplingShader(StrokeShader):
|
|||||||
def __init__(self, sampling):
|
def __init__(self, sampling):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._sampling = sampling
|
self._sampling = sampling
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
stroke.resample(float(self._sampling))
|
stroke.resample(float(self._sampling))
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyBackboneStretcherShader(StrokeShader):
|
class pyBackboneStretcherShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Stretches the stroke's backbone by a given length (in pixels)
|
Stretches the stroke's backbone by a given length (in pixels)
|
||||||
@@ -618,6 +655,7 @@ class pyBackboneStretcherShader(StrokeShader):
|
|||||||
def __init__(self, l):
|
def __init__(self, l):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._l = l
|
self._l = l
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it0 = stroke.stroke_vertices_begin()
|
it0 = stroke.stroke_vertices_begin()
|
||||||
it1 = StrokeVertexIterator(it0)
|
it1 = StrokeVertexIterator(it0)
|
||||||
@@ -642,6 +680,7 @@ class pyBackboneStretcherShader(StrokeShader):
|
|||||||
vn.point = newLast
|
vn.point = newLast
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyLengthDependingBackboneStretcherShader(StrokeShader):
|
class pyLengthDependingBackboneStretcherShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Stretches the stroke's backbone proportional to the stroke's length
|
Stretches the stroke's backbone proportional to the stroke's length
|
||||||
@@ -649,6 +688,7 @@ class pyLengthDependingBackboneStretcherShader(StrokeShader):
|
|||||||
def __init__(self, l):
|
def __init__(self, l):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._l = l
|
self._l = l
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
l = stroke.length_2d
|
l = stroke.length_2d
|
||||||
stretch = self._l*l
|
stretch = self._l*l
|
||||||
@@ -710,6 +750,7 @@ class pyBackboneStretcherNoCuspShader(StrokeShader):
|
|||||||
def __init__(self, l):
|
def __init__(self, l):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._l = l
|
self._l = l
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it0 = stroke.stroke_vertices_begin()
|
it0 = stroke.stroke_vertices_begin()
|
||||||
it1 = StrokeVertexIterator(it0)
|
it1 = StrokeVertexIterator(it0)
|
||||||
@@ -732,6 +773,7 @@ class pyBackboneStretcherNoCuspShader(StrokeShader):
|
|||||||
vn.point = newLast
|
vn.point = newLast
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyDiffusion2Shader(StrokeShader):
|
class pyDiffusion2Shader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Iteratively adds an offset to the position of each stroke vertex
|
Iteratively adds an offset to the position of each stroke vertex
|
||||||
@@ -745,6 +787,7 @@ class pyDiffusion2Shader(StrokeShader):
|
|||||||
self._nbIter = nbIter
|
self._nbIter = nbIter
|
||||||
self._normalInfo = Normal2DF0D()
|
self._normalInfo = Normal2DF0D()
|
||||||
self._curvatureInfo = Curvature2DAngleF0D()
|
self._curvatureInfo = Curvature2DAngleF0D()
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
for i in range (1, self._nbIter):
|
for i in range (1, self._nbIter):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
@@ -756,6 +799,7 @@ class pyDiffusion2Shader(StrokeShader):
|
|||||||
it.increment()
|
it.increment()
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyTipRemoverShader(StrokeShader):
|
class pyTipRemoverShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Removes the tips of the stroke
|
Removes the tips of the stroke
|
||||||
@@ -763,6 +807,7 @@ class pyTipRemoverShader(StrokeShader):
|
|||||||
def __init__(self, l):
|
def __init__(self, l):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self._l = l
|
self._l = l
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
originalSize = stroke.stroke_vertices_size()
|
originalSize = stroke.stroke_vertices_size()
|
||||||
if originalSize < 4:
|
if originalSize < 4:
|
||||||
@@ -792,6 +837,7 @@ class pyTipRemoverShader(StrokeShader):
|
|||||||
it.increment()
|
it.increment()
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyTVertexRemoverShader(StrokeShader):
|
class pyTVertexRemoverShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Removes t-vertices from the stroke
|
Removes t-vertices from the stroke
|
||||||
@@ -809,6 +855,7 @@ class pyTVertexRemoverShader(StrokeShader):
|
|||||||
stroke.remove_vertex(itlast.object)
|
stroke.remove_vertex(itlast.object)
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
#class pyExtremitiesOrientationShader(StrokeShader):
|
#class pyExtremitiesOrientationShader(StrokeShader):
|
||||||
# def __init__(self, x1,y1,x2=0,y2=0):
|
# def __init__(self, x1,y1,x2=0,y2=0):
|
||||||
# StrokeShader.__init__(self)
|
# StrokeShader.__init__(self)
|
||||||
@@ -819,6 +866,7 @@ class pyTVertexRemoverShader(StrokeShader):
|
|||||||
# stroke.setBeginningOrientation(self._v1.x,self._v1.y)
|
# stroke.setBeginningOrientation(self._v1.x,self._v1.y)
|
||||||
# stroke.setEndingOrientation(self._v2.x,self._v2.y)
|
# stroke.setEndingOrientation(self._v2.x,self._v2.y)
|
||||||
|
|
||||||
|
|
||||||
class pyHLRShader(StrokeShader):
|
class pyHLRShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Controlls visibility based upon the quantative invisibility (QI)
|
Controlls visibility based upon the quantative invisibility (QI)
|
||||||
@@ -850,9 +898,11 @@ class pyHLRShader(StrokeShader):
|
|||||||
v.attribute.visible = False
|
v.attribute.visible = False
|
||||||
it.increment()
|
it.increment()
|
||||||
it2.increment()
|
it2.increment()
|
||||||
|
|
||||||
def get_fedge(self, it1, it2):
|
def get_fedge(self, it1, it2):
|
||||||
return it1.get_fedge(it2)
|
return it1.get_fedge(it2)
|
||||||
|
|
||||||
|
|
||||||
# broken and a mess
|
# broken and a mess
|
||||||
class pyTVertexOrientationShader(StrokeShader):
|
class pyTVertexOrientationShader(StrokeShader):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -860,6 +910,7 @@ class pyTVertexOrientationShader(StrokeShader):
|
|||||||
self._Get2dDirection = Orientation2DF1D()
|
self._Get2dDirection = Orientation2DF1D()
|
||||||
## finds the TVertex orientation from the TVertex and
|
## finds the TVertex orientation from the TVertex and
|
||||||
## the previous or next edge
|
## the previous or next edge
|
||||||
|
|
||||||
def findOrientation(self, tv, ve):
|
def findOrientation(self, tv, ve):
|
||||||
mateVE = tv.get_mate(ve)
|
mateVE = tv.get_mate(ve)
|
||||||
if ve.qi != 0 or mateVE.qi != 0:
|
if ve.qi != 0 or mateVE.qi != 0:
|
||||||
@@ -881,12 +932,14 @@ class pyTVertexOrientationShader(StrokeShader):
|
|||||||
direction = self._Get2dDirection(winner.first_fedge)
|
direction = self._Get2dDirection(winner.first_fedge)
|
||||||
return direction
|
return direction
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def castToTVertex(self, cp):
|
def castToTVertex(self, cp):
|
||||||
if cp.t2d() == 0.0:
|
if cp.t2d() == 0.0:
|
||||||
return cp.first_svertex.viewvertex
|
return cp.first_svertex.viewvertex
|
||||||
elif cp.t2d() == 1.0:
|
elif cp.t2d() == 1.0:
|
||||||
return cp.second_svertex.viewvertex
|
return cp.second_svertex.viewvertex
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
it2 = StrokeVertexIterator(it)
|
it2 = StrokeVertexIterator(it)
|
||||||
@@ -926,9 +979,11 @@ class pyTVertexOrientationShader(StrokeShader):
|
|||||||
if dir is not None:
|
if dir is not None:
|
||||||
#print(dir.x, dir.y)
|
#print(dir.x, dir.y)
|
||||||
v.attribute.set_attribute_vec2("orientation", dir)
|
v.attribute.set_attribute_vec2("orientation", dir)
|
||||||
|
|
||||||
def get_fedge(self, it1, it2):
|
def get_fedge(self, it1, it2):
|
||||||
return it1.get_fedge(it2)
|
return it1.get_fedge(it2)
|
||||||
|
|
||||||
|
|
||||||
class pySinusDisplacementShader(StrokeShader):
|
class pySinusDisplacementShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Displaces the stroke in the shape of a sine wave
|
Displaces the stroke in the shape of a sine wave
|
||||||
@@ -938,6 +993,7 @@ class pySinusDisplacementShader(StrokeShader):
|
|||||||
self._f = f
|
self._f = f
|
||||||
self._a = a
|
self._a = a
|
||||||
self._getNormal = Normal2DF0D()
|
self._getNormal = Normal2DF0D()
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
@@ -954,18 +1010,20 @@ class pySinusDisplacementShader(StrokeShader):
|
|||||||
it.increment()
|
it.increment()
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyPerlinNoise1DShader(StrokeShader):
|
class pyPerlinNoise1DShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Displaces the stroke using the curvilinear abscissa. This means
|
Displaces the stroke using the curvilinear abscissa. This means
|
||||||
that lines with the same length and sampling interval will be
|
that lines with the same length and sampling interval will be
|
||||||
identically distorded
|
identically distorded
|
||||||
"""
|
"""
|
||||||
def __init__(self, freq = 10, amp = 10, oct = 4, seed = -1):
|
def __init__(self, freq=10, amp=10, oct=4, seed=-1):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self.__noise = Noise(seed)
|
self.__noise = Noise(seed)
|
||||||
self.__freq = freq
|
self.__freq = freq
|
||||||
self.__amp = amp
|
self.__amp = amp
|
||||||
self.__oct = oct
|
self.__oct = oct
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
@@ -976,6 +1034,7 @@ class pyPerlinNoise1DShader(StrokeShader):
|
|||||||
it.increment()
|
it.increment()
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyPerlinNoise2DShader(StrokeShader):
|
class pyPerlinNoise2DShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Displaces the stroke using the strokes coordinates. This means
|
Displaces the stroke using the strokes coordinates. This means
|
||||||
@@ -984,12 +1043,13 @@ class pyPerlinNoise2DShader(StrokeShader):
|
|||||||
More information on the noise shaders can be found at
|
More information on the noise shaders can be found at
|
||||||
freestyleintegration.wordpress.com/2011/09/25/development-updates-on-september-25/
|
freestyleintegration.wordpress.com/2011/09/25/development-updates-on-september-25/
|
||||||
"""
|
"""
|
||||||
def __init__(self, freq = 10, amp = 10, oct = 4, seed = -1):
|
def __init__(self, freq=10, amp=10, oct=4, seed=-1):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self.__noise = Noise(seed)
|
self.__noise = Noise(seed)
|
||||||
self.__freq = freq
|
self.__freq = freq
|
||||||
self.__amp = amp
|
self.__amp = amp
|
||||||
self.__oct = oct
|
self.__oct = oct
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
@@ -999,15 +1059,17 @@ class pyPerlinNoise2DShader(StrokeShader):
|
|||||||
it.increment()
|
it.increment()
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyBluePrintCirclesShader(StrokeShader):
|
class pyBluePrintCirclesShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Draws the silhouette of the object as a circle
|
Draws the silhouette of the object as a circle
|
||||||
"""
|
"""
|
||||||
def __init__(self, turns = 1, random_radius = 3, random_center = 5):
|
def __init__(self, turns=1, random_radius=3, random_center=5):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self.__turns = turns
|
self.__turns = turns
|
||||||
self.__random_center = random_center
|
self.__random_center = random_center
|
||||||
self.__random_radius = random_radius
|
self.__random_radius = random_radius
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
if it.is_end:
|
if it.is_end:
|
||||||
@@ -1035,7 +1097,7 @@ class pyBluePrintCirclesShader(StrokeShader):
|
|||||||
sv_nb = sv_nb // self.__turns
|
sv_nb = sv_nb // self.__turns
|
||||||
center = (p_min + p_max) / 2
|
center = (p_min + p_max) / 2
|
||||||
radius = (center.x - p_min.x + center.y - p_min.y) / 2
|
radius = (center.x - p_min.x + center.y - p_min.y) / 2
|
||||||
p_new = Vector((0,0))
|
p_new = Vector((0.0, 0.0))
|
||||||
#######################################################
|
#######################################################
|
||||||
R = self.__random_radius
|
R = self.__random_radius
|
||||||
C = self.__random_center
|
C = self.__random_center
|
||||||
@@ -1064,15 +1126,17 @@ class pyBluePrintCirclesShader(StrokeShader):
|
|||||||
stroke.remove_vertex(sv)
|
stroke.remove_vertex(sv)
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyBluePrintEllipsesShader(StrokeShader):
|
class pyBluePrintEllipsesShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Draws the silhouette of the object as an ellips
|
Draws the silhouette of the object as an ellips
|
||||||
"""
|
"""
|
||||||
def __init__(self, turns = 1, random_radius = 3, random_center = 5):
|
def __init__(self, turns=1, random_radius=3, random_center=5):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self.__turns = turns
|
self.__turns = turns
|
||||||
self.__random_center = random_center
|
self.__random_center = random_center
|
||||||
self.__random_radius = random_radius
|
self.__random_radius = random_radius
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
if it.is_end:
|
if it.is_end:
|
||||||
@@ -1095,7 +1159,7 @@ class pyBluePrintEllipsesShader(StrokeShader):
|
|||||||
sv_nb = sv_nb // self.__turns
|
sv_nb = sv_nb // self.__turns
|
||||||
center = (p_min + p_max) / 2
|
center = (p_min + p_max) / 2
|
||||||
radius = center - p_min
|
radius = center - p_min
|
||||||
p_new = Vector((0,0))
|
p_new = Vector((0.0, 0.0))
|
||||||
#######################################################
|
#######################################################
|
||||||
R = self.__random_radius
|
R = self.__random_radius
|
||||||
C = self.__random_center
|
C = self.__random_center
|
||||||
@@ -1129,11 +1193,12 @@ class pyBluePrintSquaresShader(StrokeShader):
|
|||||||
"""
|
"""
|
||||||
Draws the silhouette of the object as a square
|
Draws the silhouette of the object as a square
|
||||||
"""
|
"""
|
||||||
def __init__(self, turns = 1, bb_len = 10, bb_rand = 0):
|
def __init__(self, turns=1, bb_len=10, bb_rand=0):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self.__turns = turns
|
self.__turns = turns
|
||||||
self.__bb_len = bb_len
|
self.__bb_len = bb_len
|
||||||
self.__bb_rand = bb_rand
|
self.__bb_rand = bb_rand
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
if it.is_end:
|
if it.is_end:
|
||||||
@@ -1203,7 +1268,7 @@ class pyBluePrintSquaresShader(StrokeShader):
|
|||||||
p_new = p_fourth + vec_fourth * float(i - third)/float(fourth - third - 1)
|
p_new = p_fourth + vec_fourth * float(i - third)/float(fourth - third - 1)
|
||||||
if i == fourth - 1:
|
if i == fourth - 1:
|
||||||
visible = False
|
visible = False
|
||||||
if it.object == None:
|
if it.object is None:
|
||||||
i = i + 1
|
i = i + 1
|
||||||
it.increment()
|
it.increment()
|
||||||
if not visible:
|
if not visible:
|
||||||
@@ -1223,16 +1288,18 @@ class pyBluePrintSquaresShader(StrokeShader):
|
|||||||
stroke.remove_vertex(sv)
|
stroke.remove_vertex(sv)
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
# needs a docstring
|
# needs a docstring
|
||||||
class pyBluePrintDirectedSquaresShader(StrokeShader):
|
class pyBluePrintDirectedSquaresShader(StrokeShader):
|
||||||
def __init__(self, turns = 1, bb_len = 10, mult = 1):
|
def __init__(self, turns=1, bb_len=10, mult=1):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self.__mult = mult
|
self.__mult = mult
|
||||||
self.__turns = turns
|
self.__turns = turns
|
||||||
self.__bb_len = 1 + float(bb_len) / 100
|
self.__bb_len = 1 + float(bb_len) / 100
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
stroke.resample(32 * self.__turns)
|
stroke.resample(32 * self.__turns)
|
||||||
p_mean = Vector((0, 0))
|
p_mean = Vector((0.0, 0.0))
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
p = it.object.point
|
p = it.object.point
|
||||||
@@ -1320,14 +1387,16 @@ class pyBluePrintDirectedSquaresShader(StrokeShader):
|
|||||||
stroke.remove_vertex(sv)
|
stroke.remove_vertex(sv)
|
||||||
stroke.update_length()
|
stroke.update_length()
|
||||||
|
|
||||||
|
|
||||||
class pyModulateAlphaShader(StrokeShader):
|
class pyModulateAlphaShader(StrokeShader):
|
||||||
"""
|
"""
|
||||||
Limits the stroke's alpha between a min and max value
|
Limits the stroke's alpha between a min and max value
|
||||||
"""
|
"""
|
||||||
def __init__(self, min = 0, max = 1):
|
def __init__(self, min=0, max=1):
|
||||||
StrokeShader.__init__(self)
|
StrokeShader.__init__(self)
|
||||||
self.__min = min
|
self.__min = min
|
||||||
self.__max = max
|
self.__max = max
|
||||||
|
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
it = stroke.stroke_vertices_begin()
|
it = stroke.stroke_vertices_begin()
|
||||||
while not it.is_end:
|
while not it.is_end:
|
||||||
@@ -1341,6 +1410,7 @@ class pyModulateAlphaShader(StrokeShader):
|
|||||||
it.object.attribute.alpha = alpha
|
it.object.attribute.alpha = alpha
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
## various
|
## various
|
||||||
class pyDummyShader(StrokeShader):
|
class pyDummyShader(StrokeShader):
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
@@ -1352,6 +1422,7 @@ class pyDummyShader(StrokeShader):
|
|||||||
att.thickness = (0, 5)
|
att.thickness = (0, 5)
|
||||||
it.increment()
|
it.increment()
|
||||||
|
|
||||||
|
|
||||||
class pyDebugShader(StrokeShader):
|
class pyDebugShader(StrokeShader):
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
fe = CF.get_selected_fedge()
|
fe = CF.get_selected_fedge()
|
||||||
|
@@ -1133,9 +1133,11 @@ def iter_three_segments(stroke):
|
|||||||
it3.increment()
|
it3.increment()
|
||||||
it4.increment()
|
it4.increment()
|
||||||
|
|
||||||
|
|
||||||
def is_tvertex(svertex):
|
def is_tvertex(svertex):
|
||||||
return type(svertex.viewvertex) is TVertex
|
return type(svertex.viewvertex) is TVertex
|
||||||
|
|
||||||
|
|
||||||
class StrokeCleaner(StrokeShader):
|
class StrokeCleaner(StrokeShader):
|
||||||
def shade(self, stroke):
|
def shade(self, stroke):
|
||||||
for sv1, sv2, sv3, sv4 in iter_three_segments(stroke):
|
for sv1, sv2, sv3, sv4 in iter_three_segments(stroke):
|
||||||
|
@@ -43,6 +43,6 @@ upred = AndUP1D(QuantitativeInvisibilityUP1D(0), pyHighViewMapDensityUP1D(0.0007
|
|||||||
Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred), NotUP1D(QuantitativeInvisibilityUP1D(0)))
|
Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred), NotUP1D(QuantitativeInvisibilityUP1D(0)))
|
||||||
shaders_list = [
|
shaders_list = [
|
||||||
ConstantThicknessShader(2),
|
ConstantThicknessShader(2),
|
||||||
ConstantColorShader(0.0, 0.0, 0.0,1)
|
ConstantColorShader(0.0, 0.0, 0.0, 1.0)
|
||||||
]
|
]
|
||||||
Operators.create(TrueUP1D(), shaders_list)
|
Operators.create(TrueUP1D(), shaders_list)
|
||||||
|
@@ -55,6 +55,7 @@ class pyDensityUP1D(UnaryPredicate1D):
|
|||||||
self._integration = integration
|
self._integration = integration
|
||||||
self._func = DensityF1D(self._wsize, self._integration, sampling)
|
self._func = DensityF1D(self._wsize, self._integration, sampling)
|
||||||
self._func2 = DensityF1D(self._wsize, IntegrationType.MAX, sampling)
|
self._func2 = DensityF1D(self._wsize, IntegrationType.MAX, sampling)
|
||||||
|
|
||||||
def __call__(self, inter):
|
def __call__(self, inter):
|
||||||
c = self._func(inter)
|
c = self._func(inter)
|
||||||
m = self._func2(inter)
|
m = self._func2(inter)
|
||||||
|
Reference in New Issue
Block a user