[Bf-blender-cvs] [6498b96] master: Reorganized the Freestyle Python API in a hierarchical package structure.
Tamito Kajiyama
noreply at git.blender.org
Tue Jan 28 15:38:12 CET 2014
Commit: 6498b96ce7081db039354228213d72e8c70bd3aa
Author: Tamito Kajiyama
Date: Sun Nov 24 00:28:01 2013 +0000
https://developer.blender.org/rB6498b96ce7081db039354228213d72e8c70bd3aa
Reorganized the Freestyle Python API in a hierarchical package structure.
Both C- and Python-coded API components were rearranged into logical groups.
New Python modules are packaged as follows:
freestyle - Top-level package
freestyle.types - Classes for core data structues (e.g., view map)
freestyle.chainingiterators - Pre-defined chaining iterators
freestyle.functions - Pre-defined 0D and 1D functions
freestyle.predicates - Pre-defined 0D and 1D predicates
freestyle.shaders - Pre-defined stroke shaders
freestyle.utils - Utility functions
The Python modules are installed in scripts/freestyle/modules. Pre-defined
styles are installed in scripts/freestyle/styles.
To-do: update styles according to the new Freestyle API package structure.
===================================================================
A release/scripts/freestyle/modules/freestyle/__init__.py
A release/scripts/freestyle/modules/freestyle/chainingiterators.py
A release/scripts/freestyle/modules/freestyle/functions.py
A release/scripts/freestyle/modules/freestyle/predicates.py
A release/scripts/freestyle/modules/freestyle/shaders.py
A release/scripts/freestyle/modules/freestyle/types.py
A release/scripts/freestyle/modules/freestyle/utils.py
A release/scripts/freestyle/modules/parameter_editor.py
D release/scripts/freestyle/style_modules/ChainingIterators.py
D release/scripts/freestyle/style_modules/Functions0D.py
D release/scripts/freestyle/style_modules/Functions1D.py
D release/scripts/freestyle/style_modules/PredicatesB1D.py
D release/scripts/freestyle/style_modules/PredicatesU0D.py
D release/scripts/freestyle/style_modules/PredicatesU1D.py
D release/scripts/freestyle/style_modules/anisotropic_diffusion.py
D release/scripts/freestyle/style_modules/apriori_and_causal_density.py
D release/scripts/freestyle/style_modules/apriori_density.py
D release/scripts/freestyle/style_modules/backbone_stretcher.py
D release/scripts/freestyle/style_modules/blueprint_circles.py
D release/scripts/freestyle/style_modules/blueprint_ellipses.py
D release/scripts/freestyle/style_modules/blueprint_squares.py
D release/scripts/freestyle/style_modules/cartoon.py
D release/scripts/freestyle/style_modules/contour.py
D release/scripts/freestyle/style_modules/curvature2d.py
D release/scripts/freestyle/style_modules/external_contour.py
D release/scripts/freestyle/style_modules/external_contour_sketchy.py
D release/scripts/freestyle/style_modules/external_contour_smooth.py
D release/scripts/freestyle/style_modules/haloing.py
D release/scripts/freestyle/style_modules/ignore_small_occlusions.py
D release/scripts/freestyle/style_modules/invisible_lines.py
D release/scripts/freestyle/style_modules/japanese_bigbrush.py
D release/scripts/freestyle/style_modules/logical_operators.py
D release/scripts/freestyle/style_modules/long_anisotropically_dense.py
D release/scripts/freestyle/style_modules/multiple_parameterization.py
D release/scripts/freestyle/style_modules/nature.py
D release/scripts/freestyle/style_modules/near_lines.py
D release/scripts/freestyle/style_modules/occluded_by_specific_object.py
D release/scripts/freestyle/style_modules/parameter_editor.py
D release/scripts/freestyle/style_modules/polygonalize.py
D release/scripts/freestyle/style_modules/qi0.py
D release/scripts/freestyle/style_modules/qi0_not_external_contour.py
D release/scripts/freestyle/style_modules/qi1.py
D release/scripts/freestyle/style_modules/qi2.py
D release/scripts/freestyle/style_modules/sequentialsplit_sketchy.py
D release/scripts/freestyle/style_modules/shaders.py
D release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py
D release/scripts/freestyle/style_modules/sketchy_topology_broken.py
D release/scripts/freestyle/style_modules/sketchy_topology_preserved.py
D release/scripts/freestyle/style_modules/split_at_highest_2d_curvatures.py
D release/scripts/freestyle/style_modules/split_at_tvertices.py
D release/scripts/freestyle/style_modules/stroke_texture.py
D release/scripts/freestyle/style_modules/suggestive.py
D release/scripts/freestyle/style_modules/thickness_fof_depth_discontinuity.py
D release/scripts/freestyle/style_modules/tipremover.py
D release/scripts/freestyle/style_modules/tvertex_remover.py
D release/scripts/freestyle/style_modules/uniformpruning_zsort.py
A release/scripts/freestyle/styles/anisotropic_diffusion.py
A release/scripts/freestyle/styles/apriori_and_causal_density.py
A release/scripts/freestyle/styles/apriori_density.py
A release/scripts/freestyle/styles/backbone_stretcher.py
A release/scripts/freestyle/styles/blueprint_circles.py
A release/scripts/freestyle/styles/blueprint_ellipses.py
A release/scripts/freestyle/styles/blueprint_squares.py
A release/scripts/freestyle/styles/cartoon.py
A release/scripts/freestyle/styles/contour.py
A release/scripts/freestyle/styles/curvature2d.py
A release/scripts/freestyle/styles/external_contour.py
A release/scripts/freestyle/styles/external_contour_sketchy.py
A release/scripts/freestyle/styles/external_contour_smooth.py
A release/scripts/freestyle/styles/haloing.py
A release/scripts/freestyle/styles/ignore_small_occlusions.py
A release/scripts/freestyle/styles/invisible_lines.py
A release/scripts/freestyle/styles/japanese_bigbrush.py
A release/scripts/freestyle/styles/long_anisotropically_dense.py
A release/scripts/freestyle/styles/multiple_parameterization.py
A release/scripts/freestyle/styles/nature.py
A release/scripts/freestyle/styles/near_lines.py
A release/scripts/freestyle/styles/occluded_by_specific_object.py
A release/scripts/freestyle/styles/polygonalize.py
A release/scripts/freestyle/styles/qi0.py
A release/scripts/freestyle/styles/qi0_not_external_contour.py
A release/scripts/freestyle/styles/qi1.py
A release/scripts/freestyle/styles/qi2.py
A release/scripts/freestyle/styles/sequentialsplit_sketchy.py
A release/scripts/freestyle/styles/sketchy_multiple_parameterization.py
A release/scripts/freestyle/styles/sketchy_topology_broken.py
A release/scripts/freestyle/styles/sketchy_topology_preserved.py
A release/scripts/freestyle/styles/split_at_highest_2d_curvatures.py
A release/scripts/freestyle/styles/split_at_tvertices.py
A release/scripts/freestyle/styles/stroke_texture.py
A release/scripts/freestyle/styles/suggestive.py
A release/scripts/freestyle/styles/thickness_fof_depth_discontinuity.py
A release/scripts/freestyle/styles/tipremover.py
A release/scripts/freestyle/styles/tvertex_remover.py
A release/scripts/freestyle/styles/uniformpruning_zsort.py
M source/blender/freestyle/intern/application/AppConfig.cpp
M source/blender/freestyle/intern/python/BPy_Freestyle.cpp
===================================================================
diff --git a/release/scripts/freestyle/style_modules/backbone_stretcher.py b/release/scripts/freestyle/modules/freestyle/__init__.py
similarity index 54%
copy from release/scripts/freestyle/style_modules/backbone_stretcher.py
copy to release/scripts/freestyle/modules/freestyle/__init__.py
index c920d66..284b96e 100644
--- a/release/scripts/freestyle/style_modules/backbone_stretcher.py
+++ b/release/scripts/freestyle/modules/freestyle/__init__.py
@@ -16,20 +16,6 @@
#
# ##### END GPL LICENSE BLOCK #####
-# Filename : backbone_stretcher.py
-# Author : Stephane Grabli
-# Date : 04/08/2005
-# Purpose : Stretches the geometry of visible lines
-
-from freestyle import BackboneStretcherShader, ChainSilhouetteIterator, ConstantColorShader, \
- Operators, QuantitativeInvisibilityUP1D, TextureAssignerShader, TrueUP1D
-from logical_operators import NotUP1D
-
-Operators.select(QuantitativeInvisibilityUP1D(0))
-Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0)))
-shaders_list = [
- TextureAssignerShader(4),
- ConstantColorShader(0.5, 0.5, 0.5),
- BackboneStretcherShader(20),
- ]
-Operators.create(TrueUP1D(), shaders_list)
+# module members
+from _freestyle import Operators
+from . import chainingiterators, functions, predicates, types, utils
diff --git a/release/scripts/freestyle/modules/freestyle/chainingiterators.py b/release/scripts/freestyle/modules/freestyle/chainingiterators.py
new file mode 100644
index 0000000..1e8c192
--- /dev/null
+++ b/release/scripts/freestyle/modules/freestyle/chainingiterators.py
@@ -0,0 +1,716 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# module members
+from _freestyle import (
+ ChainPredicateIterator,
+ ChainSilhouetteIterator,
+ )
+
+# modules for implementing chaining iterators
+from freestyle.types import (
+ AdjacencyIterator,
+ ChainingIterator,
+ )
+from freestyle.utils import ContextFunctions as CF
+import bpy
+
+## the natural chaining iterator
+## It follows the edges of same nature following the topology of
+## objects with preseance on silhouettes, then borders,
+## then suggestive contours, then everything else. It doesn't chain the same ViewEdge twice
+## You can specify whether to stay in the selection or not.
+class pyChainSilhouetteIterator(ChainingIterator):
+ def __init__(self, stayInSelection=True):
+ ChainingIterator.__init__(self, stayInSelection, True, None, True)
+ def init(self):
+ pass
+ def traverse(self, iter):
+ winner = None
+ it = AdjacencyIterator(iter)
+ tvertex = self.next_vertex
+ if type(tvertex) is TVertex:
+ mateVE = tvertex.get_mate(self.current_edge)
+ while not it.is_end:
+ ve = it.object
+ if ve.id == mateVE.id:
+ winner = ve
+ break
+ it.increment()
+ else:
+ ## case of NonTVertex
+ natures = [Nature.SILHOUETTE,Nature.BORDER,Nature.CREASE,Nature.SUGGESTIVE_CONTOUR,Nature.VALLEY,Nature.RIDGE]
+ for i in range(len(natures)):
+ currentNature = self.current_edge.nature
+ if (natures[i] & currentNature) != 0:
+ count=0
+ while not it.is_end:
+ visitNext = 0
+ oNature = it.object.nature
+ if (oNature & natures[i]) != 0:
+ if natures[i] != oNature:
+ for j in range(i):
+ if (natures[j] & oNature) != 0:
+ visitNext = 1
+ break
+ if visitNext != 0:
+ break
+ count = count+1
+ winner = it.object
+ it.increment()
+ if count != 1:
+ winner = None
+ break
+ return winner
+
+## the natural chaining iterator
+## It follows the edges of same nature on the same
+## objects with preseance on silhouettes, then borders,
+## then suggestive contours, then everything else. It doesn't chain the same ViewEdge twice
+## You can specify whether to stay in the selection or not.
+## You can specify whether to chain iterate over edges that were
+## already visited or not.
+class pyChainSilhouetteGenericIterator(ChainingIterator):
+ def __init__(self, stayInSelection=True, stayInUnvisited=True):
+ ChainingIterator.__init__(self, stayInSelection, stayInUnvisited, None, True)
+ def init(self):
+ pass
+ def traverse(self, iter):
+ winner = None
+ it = AdjacencyIterator(iter)
+ tvertex = self.next_vertex
+ if type(tvertex) is TVertex:
+ mateVE = tvertex.get_mate(self.current_edge)
+ while not it.is_end:
+ ve = it.object
+ if ve.id == mateVE.id:
+ winner = ve
+ break
+ it.increment()
+ else:
+ ## case of NonTVertex
+ natures = [Nature.SILHOUETTE,Nature.BORDER,Nature.CREASE,Nature.SUGGESTIVE_CONTOUR,Nature.VALLEY,Nature.RIDGE]
+ for i in range(len(natures)):
+ currentNature = self.current_edge.nature
+ if (natures[i] & currentNature) != 0:
+ count=0
+ while not it.is_end:
+ visitNext = 0
+ oNature = it.object.nature
+ ve = it.object
+ if ve.id == self.current_edge.id:
+ it.increment()
+ continue
+ if (oNature & natures[i]) != 0:
+ if natures[i] != oNature:
+ for j in range(i):
+ if (natures[j] & oNature) != 0:
+ visitNext = 1
+ break
+ if visitNext != 0:
+ break
+ count = count+1
+ winner = ve
+ it.increment()
+ if count != 1:
+ winner = None
+ break
+ return winner
+
+class pyExternalContourChainingIterator(ChainingIterator):
+ def __init__(self):
+ ChainingIterator.__init__(self, False, True, None, True)
+ self._isExternalContour = ExternalContourUP1D()
+ def init(self):
+ self._nEdges = 0
+ self._isInSelection = 1
+ def checkViewEdge(self, ve, orientation):
+ if orientation != 0:
+ vertex = ve.second_svertex()
+ else:
+ vertex = ve.first_svertex()
+ it = AdjacencyIterator(vertex,1,1)
+ while not it.is_end:
+ ave = it.object
+ if self._isExternalContour(ave):
+ return 1
+ it.increment()
+ print("pyExternlContourChainingIterator : didn't find next edge")
+ return 0
+ def traverse(self, iter):
+ winner = None
+ it = AdjacencyIterator(iter)
+ while not it.is_end:
+ ve = it.object
+ if self._isExternalContour(ve):
+ if ve.time_stamp == CF.get_time_stamp():
+ winner = ve
+ it.increment()
+
+ self._nEdges = self._nEdges+1
+ if winner is None:
+ orient = 1
+ it = AdjacencyIterator(iter)
+ while not it.is_end:
+ ve = it.object
+ if it.is_incoming:
+ orient = 0
+ good = self.checkViewEdge(ve,orient)
+ if good != 0:
+ winner = ve
+ it.increment()
+ return winner
+
+## the natural chaining iterator
+## with a sketchy multiple touch
+class pySketchyChainSilhouetteIterator(ChainingIterator):
+ def __init__(self, nRounds=3,stayInSelection=True):
+ ChainingIterator.__init__(self, stayInSelection, False, None, True)
+ self._timeStamp = CF.get_time_stamp()+nRounds
+ self._nRounds = nRounds
+ def init(self):
+ self._timeStamp = CF.get_time_stamp()+self._nRounds
+ def traverse(self, iter):
+ winner = None
+ it = AdjacencyIterator(iter)
+ tvertex = self.next_vertex
+ if type(tvertex) is TVertex:
+ mateVE = tvertex.get_mate(self.current_edge)
+ while not it.is_end:
+ ve = it.object
+ if ve.id == mateVE.id:
+ winner = ve
+ break
+ it.increment()
+ else:
+ ## case of NonTVertex
+ natures = [Nature.SILHOUETTE,Nature.BORDER,Nature.CREASE,Nature.SUGGESTIVE_CONTOUR,Nature.VALLEY,Nature.RIDGE]
+ for i in range(len(natures)):
+ currentNature = self.current_edge.nature
+ if (natures[i] & currentNature) != 0:
+ count=0
+ while not it.is_end:
+ visitNext = 0
+ oNature = it.object.nature
+ ve = it.object
+ if ve.id == self.current_ed
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list