diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-10-02 03:15:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-10-02 04:59:16 +0300 |
commit | 41d2d6da0c96d351b47acb64d3e0decdba16cb16 (patch) | |
tree | 8f955ed71d907ab9f7ee97627a9a7c91192d139a /release/scripts/freestyle/modules | |
parent | bab9de2a52929fe2b45ecddb1eb09da3378e303b (diff) |
Cleanup: pep8 (indentation, spacing, long lines)
Diffstat (limited to 'release/scripts/freestyle/modules')
5 files changed, 89 insertions, 78 deletions
diff --git a/release/scripts/freestyle/modules/freestyle/chainingiterators.py b/release/scripts/freestyle/modules/freestyle/chainingiterators.py index 990a97db3f2..be9a25d1a57 100644 --- a/release/scripts/freestyle/modules/freestyle/chainingiterators.py +++ b/release/scripts/freestyle/modules/freestyle/chainingiterators.py @@ -36,14 +36,14 @@ __all__ = ( "pyFillOcclusionsAbsoluteAndRelativeChainingIterator", "pyFillQi0AbsoluteAndRelativeChainingIterator", "pyNoIdChainSilhouetteIterator", - ) +) # module members from _freestyle import ( ChainPredicateIterator, ChainSilhouetteIterator, - ) +) # constructs for predicate definition in Python from freestyle.types import ( @@ -51,15 +51,15 @@ from freestyle.types import ( ChainingIterator, Nature, TVertex, - ) +) from freestyle.predicates import ( ExternalContourUP1D, - ) +) from freestyle.utils import ( ContextFunctions as CF, get_chain_length, find_matching_vertex, - ) +) import bpy @@ -73,7 +73,7 @@ NATURES = ( Nature.SUGGESTIVE_CONTOUR, Nature.VALLEY, Nature.RIDGE - ) +) def nature_in_preceding(nature, index): @@ -97,12 +97,12 @@ class pyChainSilhouetteIterator(ChainingIterator): def traverse(self, iter): it = AdjacencyIterator(iter) - ## case of TVertex + # case of TVertex vertex = self.next_vertex if type(vertex) is TVertex: mate = vertex.get_mate(self.current_edge) return find_matching_vertex(mate.id, it) - ## case of NonTVertex + # case of NonTVertex winner = None for i, nat in enumerate(NATURES): if (nat & self.current_edge.nature): @@ -145,12 +145,12 @@ class pyChainSilhouetteGenericIterator(ChainingIterator): def traverse(self, iter): it = AdjacencyIterator(iter) - ## case of TVertex + # case of TVertex vertex = self.next_vertex if type(vertex) is TVertex: mate = vertex.get_mate(self.current_edge) return find_matching_vertex(mate.id, it) - ## case of NonTVertex + # case of NonTVertex winner = None for i, nat in enumerate(NATURES): if (nat & self.current_edge.nature): @@ -227,7 +227,7 @@ class pySketchyChainSilhouetteIterator(ChainingIterator): :type stayInSelection: bool """ - def __init__(self, nRounds=3,stayInSelection=True): + def __init__(self, nRounds=3, stayInSelection=True): ChainingIterator.__init__(self, stayInSelection, False, None, True) self._timeStamp = CF.get_time_stamp() + nRounds self._nRounds = nRounds @@ -249,12 +249,12 @@ class pySketchyChainSilhouetteIterator(ChainingIterator): def traverse(self, iter): it = AdjacencyIterator(iter) - ## case of TVertex + # case of TVertex vertex = self.next_vertex if type(vertex) is TVertex: mate = vertex.get_mate(self.current_edge) return self.make_sketchy(find_matching_vertex(mate.id, it)) - ## case of NonTVertex + # case of NonTVertex winner = None for i, nat in enumerate(NATURES): if (nat & self.current_edge.nature): @@ -342,13 +342,13 @@ class pyFillOcclusionsRelativeChainingIterator(ChainingIterator): winner = None winnerOrientation = False it = AdjacencyIterator(iter) - ## case of TVertex + # case of TVertex vertex = self.next_vertex if type(vertex) is TVertex: mate = vertex.get_mate(self.current_edge) winner = find_matching_vertex(mate.id, it) winnerOrientation = not it.is_incoming if not it.is_end else False - ## case of NonTVertex + # case of NonTVertex else: for nat in NATURES: if (self.current_edge.nature & nat): @@ -379,7 +379,8 @@ class pyFillOcclusionsRelativeChainingIterator(ChainingIterator): while (not _cit.is_end) and _cit.object.time_stamp != self.timestamp: connexl += _cit.object.length_2d _cit.increment() - if _cit.is_begin: break + if _cit.is_begin: + break if connexl > self._percent * self._length: return None @@ -411,13 +412,13 @@ class pyFillOcclusionsAbsoluteChainingIterator(ChainingIterator): winner = None winnerOrientation = False it = AdjacencyIterator(iter) - ## case of TVertex + # case of TVertex vertex = self.next_vertex if type(vertex) is TVertex: mate = vertex.get_mate(self.current_edge) winner = find_matching_vertex(mate.id, it) winnerOrientation = not it.is_incoming if not it.is_end else False - ## case of NonTVertex + # case of NonTVertex else: for nat in NATURES: if (self.current_edge.nature & nat): @@ -440,7 +441,8 @@ class pyFillOcclusionsAbsoluteChainingIterator(ChainingIterator): while (not _cit.is_end) and _cit.object.time_stamp != self.timestamp: connexl += _cit.object.length_2d _cit.increment() - if _cit.is_begin: break + if _cit.is_begin: + break if connexl > self._length: return None @@ -463,6 +465,7 @@ class pyFillOcclusionsAbsoluteAndRelativeChainingIterator(ChainingIterator): :arg l: Absolute length. :type l: float """ + def __init__(self, percent, l): ChainingIterator.__init__(self, False, True, None, True) self._length = 0.0 @@ -479,13 +482,13 @@ class pyFillOcclusionsAbsoluteAndRelativeChainingIterator(ChainingIterator): winner = None winnerOrientation = False it = AdjacencyIterator(iter) - ## case of TVertex + # case of TVertex vertex = self.next_vertex if type(vertex) is TVertex: mate = vertex.get_mate(self.current_edge) winner = find_matching_vertex(mate.id, it) winnerOrientation = not it.is_incoming if not it.is_end else False - ## case of NonTVertex + # case of NonTVertex else: for nat in NATURES: if (self.current_edge.nature & nat): @@ -499,22 +502,23 @@ class pyFillOcclusionsAbsoluteAndRelativeChainingIterator(ChainingIterator): if winner is not None and winner.time_stamp != CF.get_time_stamp(): - if self._length == 0.0: - self._length = get_chain_length(winner, winnerOrientation) - - connexl = 0.0 - _cit = pyChainSilhouetteGenericIterator(False, False) - _cit.begin = winner - _cit.current_edge = winner - _cit.orientation = winnerOrientation - _cit.init() - while (not _cit.is_end) and _cit.object.time_stamp != CF.get_time_stamp(): - connexl += _cit.object.length_2d - _cit.increment() - if _cit.is_begin: break - - if (connexl > self._percent * self._length) or (connexl > self._absLength): - return None + if self._length == 0.0: + self._length = get_chain_length(winner, winnerOrientation) + + connexl = 0.0 + _cit = pyChainSilhouetteGenericIterator(False, False) + _cit.begin = winner + _cit.current_edge = winner + _cit.orientation = winnerOrientation + _cit.init() + while (not _cit.is_end) and _cit.object.time_stamp != CF.get_time_stamp(): + connexl += _cit.object.length_2d + _cit.increment() + if _cit.is_begin: + break + + if (connexl > self._percent * self._length) or (connexl > self._absLength): + return None return winner @@ -549,13 +553,13 @@ class pyFillQi0AbsoluteAndRelativeChainingIterator(ChainingIterator): winner = None winnerOrientation = False it = AdjacencyIterator(iter) - ## case of TVertex + # case of TVertex vertex = self.next_vertex if type(vertex) is TVertex: mate = vertex.get_mate(self.current_edge) winner = find_matching_vertex(mate.id, it) winnerOrientation = not it.is_incoming if not it.is_end else False - ## case of NonTVertex + # case of NonTVertex else: for nat in NATURES: if (self.current_edge.nature & nat): @@ -569,22 +573,22 @@ class pyFillQi0AbsoluteAndRelativeChainingIterator(ChainingIterator): if winner is not None and winner.qi: + if self._length == 0.0: + self._length = get_chain_length(winner, winnerOrientation) - if self._length == 0.0: - self._length = get_chain_length(winner, winnerOrientation) - - connexl = 0 - _cit = pyChainSilhouetteGenericIterator(False, False) - _cit.begin = winner - _cit.current_edge = winner - _cit.orientation = winnerOrientation - _cit.init() - while (not _cit.is_end) and _cit.object.qi != 0: - connexl += _cit.object.length_2d - _cit.increment() - if _cit.is_begin: break - if (connexl > self._percent * self._length) or (connexl > self._absLength): - return None + connexl = 0 + _cit = pyChainSilhouetteGenericIterator(False, False) + _cit.begin = winner + _cit.current_edge = winner + _cit.orientation = winnerOrientation + _cit.init() + while (not _cit.is_end) and _cit.object.qi != 0: + connexl += _cit.object.length_2d + _cit.increment() + if _cit.is_begin: + break + if (connexl > self._percent * self._length) or (connexl > self._absLength): + return None return winner @@ -637,10 +641,10 @@ class pyNoIdChainSilhouetteIterator(ChainingIterator): if vA.id.first == vB.id.first: return ve return None - ## case of NonTVertex + # case of NonTVertex else: for i, nat in enumerate(NATURES): - if (nat & self.current_edge.nature): + if (nat & self.current_edge.nature): for ve in it: ve_nat = ve.nature if (ve_nat & nat): diff --git a/release/scripts/freestyle/modules/freestyle/predicates.py b/release/scripts/freestyle/modules/freestyle/predicates.py index 5cbe577b956..656b6952591 100644 --- a/release/scripts/freestyle/modules/freestyle/predicates.py +++ b/release/scripts/freestyle/modules/freestyle/predicates.py @@ -95,7 +95,7 @@ __all__ = ( "pyZBP1D", "pyZDiscontinuityBP1D", "pyZSmallerUP1D", - ) +) # module members @@ -117,7 +117,7 @@ from _freestyle import ( TrueUP1D, ViewMapGradientNormBP1D, WithinImageBoundaryUP1D, - ) +) # constructs for predicate definition in Python from freestyle.types import ( @@ -129,7 +129,7 @@ from freestyle.types import ( TVertex, UnaryPredicate0D, UnaryPredicate1D, - ) +) from freestyle.functions import ( Curvature2DAngleF0D, CurveNatureF1D, @@ -149,7 +149,7 @@ from freestyle.functions import ( pyCurvilinearLengthF0D, pyDensityAnisotropyF1D, pyViewMapGradientNormF1D, - ) +) from freestyle.utils import material_from_fedge @@ -194,6 +194,7 @@ class pyBackTVertexUP0D(UnaryPredicate0D): Check whether an Interface0DIterator references a TVertex and is the one that is hidden (inferred from the context). """ + def __init__(self): UnaryPredicate0D.__init__(self) self._getQI = QuantitativeInvisibilityF0D() @@ -239,7 +240,7 @@ class AndUP1D(UnaryPredicate1D): correct_types = all(isinstance(p, UnaryPredicate1D) for p in self.predicates) if not (correct_types and predicates): raise TypeError("%s: Expected one or more UnaryPredicate1D, got %r" % - (self.__class__.__name__, self.predicates)) + (self.__class__.__name__, self.predicates)) def __call__(self, inter): return all(pred(inter) for pred in self.predicates) @@ -252,7 +253,7 @@ class OrUP1D(UnaryPredicate1D): correct_types = all(isinstance(p, UnaryPredicate1D) for p in self.predicates) if not (correct_types and predicates): raise TypeError("%s: Expected one or more UnaryPredicate1D, got %r" % - (self.__class__.__name__, self.predicates)) + (self.__class__.__name__, self.predicates)) def __call__(self, inter): return any(pred(inter) for pred in self.predicates) @@ -533,7 +534,8 @@ class pyHighViewMapGradientNormUP1D(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) self._functor = functor self._sigmaMin = float(sigmaMin) @@ -571,7 +573,7 @@ class AndBP1D(BinaryPredicate1D): correct_types = all(isinstance(p, BinaryPredicate1D) for p in self.predicates) if not (correct_types and predicates): raise TypeError("%s: Expected one or more BinaryPredicate1D, got %r" % - (self.__class__.__name__, self.predicates)) + (self.__class__.__name__, self.predicates)) def __call__(self, i1, i2): return all(pred(i1, i2) for pred in self.predicates) @@ -584,7 +586,7 @@ class OrBP1D(BinaryPredicate1D): correct_types = all(isinstance(p, BinaryPredicate1D) for p in self.predicates) if not (correct_types and predicates): raise TypeError("%s: Expected one or more BinaryPredicate1D, got %r" % - (self.__class__.__name__, self.predicates)) + (self.__class__.__name__, self.predicates)) def __call__(self, i1, i2): return any(pred(i1, i2) for pred in self.predicates) @@ -672,8 +674,10 @@ class pyShuffleBP1D(BinaryPredicate1D): def __call__(self, inter1, inter2): return (random.uniform(0, 1) < random.uniform(0, 1)) + class MaterialBP1D(BinaryPredicate1D): """Checks whether the two supplied ViewEdges have the same material.""" + def __call__(self, i1, i2): fedges = (fe for ve in (i1, i2) for fe in (ve.first_fedge, ve.last_fedge)) materials = {material_from_fedge(fe) for fe in fedges} diff --git a/release/scripts/freestyle/modules/freestyle/types.py b/release/scripts/freestyle/modules/freestyle/types.py index 22f80f41dfc..72d263b26a3 100644 --- a/release/scripts/freestyle/modules/freestyle/types.py +++ b/release/scripts/freestyle/modules/freestyle/types.py @@ -170,4 +170,4 @@ from _freestyle import ( ViewShape, ViewVertex, orientedViewEdgeIterator, - ) +) diff --git a/release/scripts/freestyle/modules/freestyle/utils.py b/release/scripts/freestyle/modules/freestyle/utils.py index 2d47995d474..d129de66221 100644 --- a/release/scripts/freestyle/modules/freestyle/utils.py +++ b/release/scripts/freestyle/modules/freestyle/utils.py @@ -51,14 +51,14 @@ __all__ = ( "stroke_normal", "StrokeCollector", "tripplewise", - ) +) # module members from _freestyle import ( ContextFunctions, getCurrentScene, integrate, - ) +) # constructs for helper functions in Python from freestyle.types import ( @@ -66,7 +66,7 @@ from freestyle.types import ( Stroke, StrokeShader, StrokeVertexIterator, - ) +) from mathutils import Vector from functools import lru_cache, namedtuple @@ -288,7 +288,7 @@ class BoundingBox: "maximum", "size", "corners", - ) + ) def __init__(self, minimum: Vector, maximum: Vector): self.minimum = minimum @@ -319,6 +319,7 @@ class BoundingBox: class StrokeCollector(StrokeShader): """Collects and Stores stroke objects""" + def __init__(self): StrokeShader.__init__(self) self.strokes = [] diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py index 0b8ccf387fd..65eee93c871 100644 --- a/release/scripts/freestyle/modules/parameter_editor.py +++ b/release/scripts/freestyle/modules/parameter_editor.py @@ -34,20 +34,20 @@ from freestyle.types import ( TVertex, Material, ViewEdge, - ) +) from freestyle.chainingiterators import ( ChainPredicateIterator, ChainSilhouetteIterator, pySketchyChainSilhouetteIterator, pySketchyChainingIterator, - ) +) from freestyle.functions import ( Curvature2DAngleF0D, Normal2DF0D, QuantitativeInvisibilityF1D, VertexOrientation2DF0D, CurveMaterialF0D, - ) +) from freestyle.predicates import ( AndUP1D, ContourUP1D, @@ -67,7 +67,7 @@ from freestyle.predicates import ( pyProjectedXBP1D, pyProjectedYBP1D, pyZBP1D, - ) +) from freestyle.shaders import ( BackboneStretcherShader, BezierCurveShader, @@ -86,7 +86,7 @@ from freestyle.shaders import ( StrokeTextureStepShader, ThicknessNoiseShader as thickness_noise, TipRemoverShader, - ) +) from freestyle.utils import ( angle_x_normal, bound, @@ -103,12 +103,12 @@ from freestyle.utils import ( pairwise, simplify, stroke_normal, - ) +) from _freestyle import ( blendRamp, evaluateColorRamp, evaluateCurveMappingF, - ) +) import time import bpy @@ -608,7 +608,9 @@ class NoiseShader: class ThicknessNoiseShader(ThicknessBlenderMixIn, ScalarBlendModifier, NoiseShader): """Thickness based on pseudo-noise""" - def __init__(self, thickness_position, thickness_ratio, blend_type, influence, amplitude, period, seed=512, asymmetric=True): + + def __init__(self, thickness_position, thickness_ratio, blend_type, + influence, amplitude, period, seed=512, asymmetric=True): ScalarBlendModifier.__init__(self, blend_type, influence) ThicknessBlenderMixIn.__init__(self, thickness_position, thickness_ratio) NoiseShader.__init__(self, amplitude, period, seed) |