Commit Graph

21 Commits

Author SHA1 Message Date
Tamito Kajiyama
3df023ae82 Freestyle Python API improvements - part 8.
* Proper handling of keyword arguments was implemented in Operators and ContextFunctions,
as well as in methods of Interface0D, Interface1D, Iterator, their subclasses, Noise and
IntegrationType.

* Operators' methods and functions in the ContextFunctions module were renamed from
CamelCase to lower cases + underscores.  Style modules were updated accordingly.

* Additional code clean-up was also made.
2013-02-24 02:39:38 +00:00
Tamito Kajiyama
7b3a5f6901 Fix for __repr__() depending on .getName() and .getExactTypeName().
API users no longer need to define them in user-defined Functions, Predicates and StrokeShaders.
Also removed all .getName() and .getExactTypeName() definitions in pre-defined Functions,
Predicates and StrokeShaders subclasses.
2013-02-23 12:17:40 +00:00
Tamito Kajiyama
39f8c6e189 Freestyle Python API improvements - part 5.
Handling of keyword arguments in Python wrapper class constructors was revised.
This revision is mainly focused on Interface0D, Interface1D, Iterator, and
their subclasses, as well as a few additional view map component classes.

Implementation notes: Because of the extensive use of constructor overloading
in the underlying C++ classes, the corresponding Python wrappers try to parse
arguments through multiple calls of PyArg_ParseTupleAndKeywords() if needed.
The downside of this implementation is that most argument errors result in the
same error message ("invalid argument(s)") without indicating what is wrong.
For now this issue is left for future work.

* Now the instantiation of ViewVertex is prohibited since the underlying
C++ class is an abstract class.

* Removed the .cast_to_interface0diterator() method from CurvePointIterator
and StrokeVertexIterator.  Instead the constructor of Interface0DIterator now
accepts the instances of these two iterator classes to construct a nested
Interface0DIterator instance that can be passed to Function0D functor objects.
Specifically, an iterator 'it' is passed to a functor 'func' as follows:

  func(Interface0DIterator(it))

instead of:

  func(it.cast_to_interface0diterator())

* Boolean arguments of class constructors only accept values of boolean type.
Input values of other types are considered as error.

* Additional code clean-up was made.
2013-02-21 02:57:44 +00:00
Tamito Kajiyama
b35a893249 Freestyle Python API improvements - part 4.
Major API updates were made as in part 3 to address code review comments.
This revision focuses on Python wrappers of C++ iterators.

* Most getter/setter methods were reimplemented as attributes using PyGetSetDef.

* The naming of methods and attributes was fixed to follow the naming conventions
of the Blender Python API (i.e., lower case + underscores for methods and attributes,
and CamelCase for classes).  The only irregular naming change is the following, to
better indicate the functionality:

- ChainingIterator: getVertex --> next_vertex

* In addition, some code clean-up was done in both C++ and Python.  Also duplicated
definitions of predicate classes were removed.
2013-02-16 14:21:40 +00:00
Tamito Kajiyama
731d08d497 Freestyle Python API improvements - part 3.
Major API updates were made to address code review comments.
This revision mostly focuses on Python wrappers of C++ 0D and 1D elements (i.e.,
Interface0D and Interface1D, as well as their subclasses).

* Most getter/setter methods were reimplemented as attributes using PyGetSetDef.
Vector attributes are now implemented based on mathutils callbacks.  Boolean
attributes now only accept boolean values.

* The __getitem__ method was removed and the Sequence protocol was used instead.

* The naming of methods and attributes was fixed to follow the naming conventions
of the Blender Python API (i.e., lower case + underscores for methods and attributes,
and CamelCase for classes).  Some naming inconsistency within the Freestyle Python
API was also addressed.

* The Freestyle API had a number of method names including prefix/suffix "A" and
"B", and their meanings were inconsistent (i.e., referring to different things
depending on the classes).  The names with these two letters were replaced with
more straightforward names.  Also some attribute names were changed so as to indicate
the type of the value (e.g., FEdge.next_fedge instead of FEdge.next_edge) in line
with other names explicitly indicating what the value is (e.g., SVertex.viewvertex).

* In addition, some code clean-up was done in both C++ and Python.

Notes:

In summary, the following irregular naming changes were made through this revision
(those resulting from regular changes of naming conventions are not listed):

- CurvePoint: {A,B} --> {first,second}_svertex
- FEdge: vertex{A,B} --> {first,second}_svertex
- FEdge: {next,previous}Edge --> {next,previous}_fedge
- FEdgeSharp: normal{A,B} --> normal_{right,left}
- FEdgeSharp: {a,b}FaceMark --> face_mark_{right,left}
- FEdgeSharp: {a,b}Material --> material_{right,left}
- FEdgeSharp: {a,b}MaterialIndex --> material_index_{right,left}
- FrsCurve: empty --> is_empty
- FrsCurve: nSegments --> segments_size
- TVertex: mate() --> get_mate()
- ViewEdge: fedge{A,B} --> {first,last}_fedge
- ViewEdge: setaShape, aShape --> occlude
- ViewEdge: {A,B} --> {first,last}_viewvertex
- ViewMap: getScene3dBBox --> scene_bbox
2013-02-14 23:48:34 +00:00
Tamito Kajiyama
7e3e3a2270 Freestyle Python API improvements - part 2.
The API syntax of FrsMaterial was updated by means of getter/setter properties.
Python style modules (including the Parameter Editor) were updated accordingly.
2013-02-03 17:01:21 +00:00
Tamito Kajiyama
6ff0d15e5a Freestyle Python API improvements.
StrokeAttribute class methods were renamed from camel case to lower case plus underscore.
Also made changes to shaders.pyTVertexOrientationShader that uses the affected methods.
2013-01-27 21:51:25 +00:00
Tamito Kajiyama
156acd3370 Freestyle Python API improvements - part 1.
* The API syntax of StrokeVertex and StrokeAttribute was updated by means of getter/setter
properties instead of class methods.  Python style modules (including the Parameter Editor
implementation) were updated accordingly.

* Code clean-up was done for a few Python style modules, mostly by removing duplicated
definitions of stroke shaders and fixing indentation.
2013-01-27 20:17:49 +00:00
Tamito Kajiyama
1db5b6d283 Fix for Stroke.Resample(float iSampling) and Stroke.UpdateLength() using
StrokeVertex.point2d() instead of .getPoint().  It is noted that .point2d()
returns a 3-dimensional vector representing a 2D-projected point, with the z
component indicating a normalized depth of the original 3D point, whereas
.getPoint() returns a plain 2-dimensional vector.  This fix should have been
done in revision 48510...

Also made fix for callers of Stroke.Resample() not calling stroke.UpdateLength().
2013-01-22 01:46:16 +00:00
Tamito Kajiyama
acae0e7b1f Further fix for svn:executable. 2012-12-11 23:05:04 +00:00
Tamito Kajiyama
e7a4d45435 Added to the Parameter Editor mode new stroke geometry modifier `Blueprint'
that produces a blueprint using circular, elliptic, and square contour strokes.
Related changes and bug fixes were made as follows:

* The randomness in radius and center has been transformed into optional
parameters of the pyBluePrintCirclesShader and pyBluePrintEllipsesShader.
Also a new optional parameter to control the randomness of backbone
stretching has been added to the pyBluePrintSquaresShader.

* A bug in the pyBluePrintSquaresShader that invisible stroke vertices at
corners of rectangular contour strokes were not properly drawn.  The problem
was due to the changes of the / operator between Python 2.x to 3.x.  Even
when the two operands of the division operator are integers, Python 3.x
gives a floating-point number when the quotient is not an integer.  The fix
was just to replace the / operator by the // operator for integer division.

* An unpleasant discontinuity in circular and elliptical contour strokes
was fixed.

* The length parameter of the Backbone Stretcher geometry modifier has been
renamed to `backbone_length' in line with the parameter of the same name in
the pyBluePrintSquaresShader.
2011-11-11 20:35:03 +00:00
Tamito Kajiyama
ea11efb082 * Fix for stroke geometry shaders that did not update the 2D length after the
modifications of stroke vertices.

* Fix for a bug in pyBluePrintCirclesShader that did not check the end of
iteration over stroke vertices.

* Fix for stroke vertex removal during iteration over stroke vertices in
pyBluePrintCirclesShader, pyBluePrintEllipsesShader, pyBluePrintSquaresShader,
and pyBluePrintDirectedSquaresShader.
2011-11-01 21:08:18 +00:00
Tamito Kajiyama
aece060cbf Removed uncontrolled randomness from the pyPerlinNoise1DShader. 2011-08-18 23:44:44 +00:00
Tamito Kajiyama
4ec69d5a2b Added an optional argument 'seed' to the Freestyle.Noise class constructor.
The value is used as a seed for random number generation if it is equal to
or greater than zero; otherwise, time is used as a seed.
2011-08-18 23:07:17 +00:00
Tamito Kajiyama
d347a27a97 * Bug fixes by Stéphane Grabli with respect to pyZDependingThicknessShader,
pyMaterialColorShader, pyBluePrintEllipsesShader and pyBluePrintSquaresShader.

* Fixes for Vector instantiation that now takes only a sequence object of
2, 3, or 4 elements -- an API change in revision 28417.

* Deleted vector.py that is no longer used.
2010-07-06 20:07:07 +00:00
Tamito Kajiyama
2385c51360 Renamed FrsCurve, FrsNoise and FrsMaterial Python extension types
to those names without the "Frs" prefix.  These types are part of
the Freestyle module, so that there is no need to make their names
globally unique.
2010-05-09 18:05:33 +00:00
Tamito Kajiyama
1ff038397f Made standard style modules compatible with Python 3. 2009-09-27 00:58:38 +00:00
Tamito Kajiyama
1ed4d4cbfb Reverted all changes (i.e., deletion) in release/scripts/freestyle. 2009-09-19 22:02:15 +00:00
Tamito Kajiyama
be50ce61be Merged
https://svn.blender.org/svnroot/bf-blender/branches/soc-2008-mxcurioni (r22789) and
https://svn.blender.org/svnroot/bf-blender/trunk/blender (r23338)
with the "Ignore ancestry" and "Ignore line endings" options enabled (using
TortoiseSVN on Windows).

After the merge operation, all changes (i.e., deletion) in source/blender/freestyle/
were reverted in order to keep the primary source tree of the Freestyle renderer.
2009-09-18 22:25:49 +00:00
Tamito Kajiyama
9f79d8ae67 * freestyle_init.py: Removed all classes for wrapping extension types.
This allows users to test the types of those objects that are returned
by API functions, by means of usual Python idioms such as "type(I) is T"
and "isinstance(I, T)".

* Removed all occurrences of ViewVertex::castToTVertex() in the following
modules and rewrote the code segments using it by means of the "type(I)
is T" idiom mentioned above:

  ChainingIterators.py
  PredicatesU1D.py

* Replaced all occurrences of vector.Vec2, vector.Vec3, Vec2f and Vec3f
by Blender.Mathutils.Vector in the following modules:

  anisotropic_diffusion.py
  Functions0D.py
  shaders.py
  sketchy_topology_broken.py

* shaders.py: Fixed NameError's concerning math.pow().

* shaders.py: Added a Python equivalent of getFEdge function, defined
in source\blender\freestyle\intern\view_map\Functions0D.cpp as follows:

  FEdge* Functions0D::getFEdge(Interface0D& it1, Interface0D& it2) {
    return it1.getFEdge(it2);
  }

* shaders.py: Replaced fe.qi() by fe.viewedge().qi().

* contour.py: Fixed the import statement for freestyle_init.py.
2009-07-27 20:13:47 +00:00
Maxime Curioni
204f48c74e soc-2008-mxcurioni: sending files in release/scripts/freestyle folder 2008-09-30 04:17:39 +00:00