diff --git a/source/blender/freestyle/misc/AUTHORS.TXT b/source/blender/freestyle/misc/AUTHORS.TXT deleted file mode 100755 index 27cdb70d5ec..00000000000 --- a/source/blender/freestyle/misc/AUTHORS.TXT +++ /dev/null @@ -1,6 +0,0 @@ -Authors -------- -Frédo Durand -Stéphane Grabli -François Sillion -Emmanuel Turquin diff --git a/source/blender/freestyle/misc/BUGS.TXT b/source/blender/freestyle/misc/BUGS.TXT deleted file mode 100755 index c5bad029a47..00000000000 --- a/source/blender/freestyle/misc/BUGS.TXT +++ /dev/null @@ -1,11 +0,0 @@ -* Application doesn't exit properly (eg style window still hangs out) -* macosx: Window bar is unaccessible. -* macosx: Build leds to an application that is half-bundle (for the executable) half UNIX-style (for libraries). -* Strokes Strips are sometimes incorrect -* TVertex sometimes points towards NULL ViewEdges -* Some points are found to be outside of the grid. (for big models and mostly in release mode). Probably due to precision problems. -* Operators::recursiveChains() and ViewEdgeIterator change ViewEdgeIterator so that it supports the copy of specialized types in a transparent way. It works here only because we're never copying it and because it is passed as a reference. -* Functions0D takes a Interface0DIterator& insted of a const Interface0DIterator& as argument. dangerous. -* crashes on big models - - diff --git a/source/blender/freestyle/misc/COPYRIGHT.TXT b/source/blender/freestyle/misc/COPYRIGHT.TXT deleted file mode 100755 index cd37bd16786..00000000000 --- a/source/blender/freestyle/misc/COPYRIGHT.TXT +++ /dev/null @@ -1,9 +0,0 @@ -Freestyle - -Copyright (c) 2001-2007 by the following: - - -Frédo Durand -Stéphane Grabli -François Sillion -Emmanuel Turquin diff --git a/source/blender/freestyle/misc/INSTALL.TXT b/source/blender/freestyle/misc/INSTALL.TXT deleted file mode 100755 index 4fab1275116..00000000000 --- a/source/blender/freestyle/misc/INSTALL.TXT +++ /dev/null @@ -1,79 +0,0 @@ -Install -------- - -* UNIX/LINUX - -(for a more detailed description, see doc/linuxinstall.html) - - This is quite straightforward, provided that you have all the -needed libraries properly installed (see Requirements section in -the README.TXT file). -First, set the FREESTYLE-DIR environment variable to your -freestyle directory and then, simply type: - -$> cd "$FREESTYLE_DIR"/src -$> qmake -$> make - -Note: The SWIG wrapper hasn't been included in the qmake build -cycle yet and thus has to be compiled separately, by hand: - -$> cd "$FREESTYLE_DIR"/src/swig -$> make - -And to run the app: - -$> export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:./lib" -$> cd "$FREESTYLE_DIR"/build/linux-g++/release/ -$> ./Freestyle - - -* WINDOWS - - - If you downloaded the binary version: - -1) unzip the package -2) run vcredist_x86.exe -3) run Freestyle.exe - -- Compilation Instructions: - -(for a more detailed description, including the cygwin -compilation instructions, see doc/wininstall.html) - -1) launch 'makedsp.vcnet.debug.bat' in the 'src' subdir of your FREESTYLE_DIR to generate - a .vcproj file for each sub-project -2) open 'src/Freestyle-vc8-debug.sln' with Visual Studio (tested with VC++ 8 express edition) -3) compile the whole project using 'build solution' in the 'build' menu -4) run the app and enjoy ;) - -* MAC OS X - -(for a more detailed description, see doc/macosxinstall.html) - - This is quite straightforward, provided that you have all the -needed libraries properly installed (see Requirements section in -the README.TXT file). -First, set the FREESTYLE-DIR environment variable to your -freestyle directory and then, simply type: - -$> cd "$FREESTYLE_DIR"/src -$> qmake -$> make - -Note: The SWIG wrapper hasn't been included in the qmake build -cycle yet and thus has to be compiled separately, by hand: - -$> cd "$FREESTYLE_DIR"/src/swig -$> make - -And to run the app: - -$> build_bundle.macosx.py -$> cd "$FREESTYLE_DIR"/ -$> open Freestyle.App - - -* IRIX - -Not tested yet... diff --git a/source/blender/freestyle/misc/LICENSE.TXT b/source/blender/freestyle/misc/LICENSE.TXT deleted file mode 100644 index 5b6e7c66c27..00000000000 --- a/source/blender/freestyle/misc/LICENSE.TXT +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/source/blender/freestyle/misc/README.TXT b/source/blender/freestyle/misc/README.TXT deleted file mode 100755 index b0d026c8b9b..00000000000 --- a/source/blender/freestyle/misc/README.TXT +++ /dev/null @@ -1,51 +0,0 @@ -Freestyle, a procedural line drawing system -http://freestyle.sourceforge.net - -INTRODUCTION ------------- -Freestyle is a software for Non-Photorealistic Line Drawing rendering -from 3D scenes. It is designed as a programmable interface to allow -maximum control over the style of the final drawing: the user -"programs" how the silhouettes and other feature lines from the 3D -model should be turned into stylized strokes using a set of -programmable operators dedicated to style description. This -programmable approach, inspired by the shading languages available in -photorealistic renderers such as Pixar's RenderMan, overcomes the -limitations of integrated software with access to a limited number of -parameters and permits the design of an infinite variety of rich and -complex styles. The system currently focuses on pure line drawing as a -first step. The style description language is Python augmented with -our set of operators. Freestyle was developed in the framework of a -research project dedicated to the study of stylized line drawing -rendering from 3D scenes. Details about this research can be found at: - -http://artis.imag.fr/Projects/Style - -This software is distributed under -the terms of the GPL License. - -INSTALL -------- -Please see the file INSTALL.TXT for instructions on installation. - -REQUIREMENTS ------------- -- OpenGL >= 1.2 -- libQGLViewer = 2.2.5-1 -- lib3ds = 1.2 -- Qt = 4.2.3 -- SWIG = 1.3.31 -- Python = 2.5 - -For Linux and MacOSX: -- g++ = 4.0 or 4.1 - -For Windows: -- Visual Studio = 2003 or 2005 - -CONTACTING THE AUTHORS ----------------------- -See the AUTHORS.TXT file for contact information. - -Thank you for your interest in this project, we hope you enjoy using it. ---- diff --git a/source/blender/freestyle/misc/THANKS.TXT b/source/blender/freestyle/misc/THANKS.TXT deleted file mode 100755 index 3147715a63f..00000000000 --- a/source/blender/freestyle/misc/THANKS.TXT +++ /dev/null @@ -1,6 +0,0 @@ -The following is an incomplete list of people that have contributed to this -project in some way or another, in no particular order... - -* Thomas Netter (lib3ds fix) -* Gilles Debunne, creator and maintainer of the great libQGLViewer. -* Mark Rose, for his work on the SWIG director feature, and his help. diff --git a/source/blender/freestyle/misc/TODO.TXT b/source/blender/freestyle/misc/TODO.TXT deleted file mode 100755 index 2e24752e026..00000000000 --- a/source/blender/freestyle/misc/TODO.TXT +++ /dev/null @@ -1,9 +0,0 @@ -sgrabli: --------- - -* Update help and make it display correctly -* Recode the ViewMap building - the Y junctions are not detected for smooth objects right now. -* Check the strokes strippification code. It seems some parts are inverted. -* Fix the pbuffer so that ATI cards are supported - -* Merge Chain and Stroke classes (to Stroke) and improve the base of operators (select, chain, split, shade) consquently (also think about a way to easily specify the pipeline synchronization mode). diff --git a/source/blender/freestyle/style_modules_old/ChainingIterators.py b/source/blender/freestyle/style_modules_old/ChainingIterators.py deleted file mode 100755 index 60255c3d094..00000000000 --- a/source/blender/freestyle/style_modules_old/ChainingIterators.py +++ /dev/null @@ -1,731 +0,0 @@ -# -# Filename : ChainingIterators.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Chaining Iterators to be used with chaining operators -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * - -## 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=1): - ChainingIterator.__init__(self, stayInSelection, 1,None,1) - def getExactTypeName(self): - return "pyChainSilhouetteIterator" - def traverse(self, iter): - winner = None - it = AdjacencyIterator(iter) - nextVertex = self.getVertex() - if(nextVertex.getNature() & T_VERTEX != 0): - tvertex = nextVertex.castToTVertex() - mateVE = tvertex.mate(self.getCurrentEdge()) - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getId() == mateVE.getId() ): - winner = ve - break - it.increment() - else: - ## case of NonTVertex - natures = [SILHOUETTE,BORDER,CREASE,SUGGESTIVE_CONTOUR,VALLEY,RIDGE] - for i in range(len(natures)): - currentNature = self.getCurrentEdge().getNature() - if(natures[i] & currentNature): - count=0 - while(it.isEnd() == 0): - visitNext = 0 - oNature = it.getObject().getNature() - 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.getObject() - 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=1, stayInUnvisited=1): - ChainingIterator.__init__(self, stayInSelection, stayInUnvisited,None,1) - def getExactTypeName(self): - return "pyChainSilhouetteGenericIterator" - def traverse(self, iter): - winner = None - it = AdjacencyIterator(iter) - nextVertex = self.getVertex() - if(nextVertex.getNature() & T_VERTEX != 0): - tvertex = nextVertex.castToTVertex() - mateVE = tvertex.mate(self.getCurrentEdge()) - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getId() == mateVE.getId() ): - winner = ve - break - it.increment() - else: - ## case of NonTVertex - natures = [SILHOUETTE,BORDER,CREASE,SUGGESTIVE_CONTOUR,VALLEY,RIDGE] - for i in range(len(natures)): - currentNature = self.getCurrentEdge().getNature() - if(natures[i] & currentNature): - count=0 - while(it.isEnd() == 0): - visitNext = 0 - oNature = it.getObject().getNature() - ve = it.getObject() - if(ve.getId() == self.getCurrentEdge().getId()): - 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, 0, 1,None,1) - self._isExternalContour = ExternalContourUP1D() - - def getExactTypeName(self): - return "pyExternalContourIterator" - - def init(self): - self._nEdges = 0 - self._isInSelection = 1 - - def checkViewEdge(self, ve, orientation): - if(orientation != 0): - vertex = ve.B() - else: - vertex = ve.A() - it = AdjacencyIterator(vertex,1,1) - while(it.isEnd() == 0): - ave = it.getObject() - 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(it.isEnd() == 0): - ve = it.getObject() - if(self._isExternalContour(ve)): - if (ve.getTimeStamp() == GetTimeStampCF()): - winner = ve - it.increment() - - self._nEdges = self._nEdges+1 - if(winner == None): - orient = 1 - it = AdjacencyIterator(iter) - while(it.isEnd() == 0): - ve = it.getObject() - if(it.isIncoming() != 0): - 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=1): - ChainingIterator.__init__(self, stayInSelection, 0,None,1) - self._timeStamp = GetTimeStampCF()+nRounds - self._nRounds = nRounds - def getExactTypeName(self): - return "pySketchyChainSilhouetteIterator" - def init(self): - self._timeStamp = GetTimeStampCF()+self._nRounds - def traverse(self, iter): - winner = None - it = AdjacencyIterator(iter) - nextVertex = self.getVertex() - if(nextVertex.getNature() & T_VERTEX != 0): - tvertex = nextVertex.castToTVertex() - mateVE = tvertex.mate(self.getCurrentEdge()) - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getId() == mateVE.getId() ): - winner = ve - break - it.increment() - else: - ## case of NonTVertex - natures = [SILHOUETTE,BORDER,CREASE,SUGGESTIVE_CONTOUR,VALLEY,RIDGE] - for i in range(len(natures)): - currentNature = self.getCurrentEdge().getNature() - if(natures[i] & currentNature): - count=0 - while(it.isEnd() == 0): - visitNext = 0 - oNature = it.getObject().getNature() - ve = it.getObject() - if(ve.getId() == self.getCurrentEdge().getId()): - 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 - if(winner == None): - winner = self.getCurrentEdge() - if(winner.getChainingTimeStamp() == self._timeStamp): - winner = None - return winner - - -# Chaining iterator designed for sketchy style. -# can chain several times the same ViewEdge -# in order to produce multiple strokes per ViewEdge. -class pySketchyChainingIterator(ChainingIterator): - def __init__(self, nRounds=3, stayInSelection=1): - ChainingIterator.__init__(self, stayInSelection, 0,None,1) - self._timeStamp = GetTimeStampCF()+nRounds - self._nRounds = nRounds - def getExactTypeName(self): - return "pySketchyChainingIterator" - - def init(self): - self._timeStamp = GetTimeStampCF()+self._nRounds - - def traverse(self, iter): - winner = None - it = AdjacencyIterator(iter) - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getId() == self.getCurrentEdge().getId()): - it.increment() - continue - winner = ve - it.increment() - if(winner == None): - winner = self.getCurrentEdge() - if(winner.getChainingTimeStamp() == self._timeStamp): - return None - return winner - - -## Chaining iterator that fills small occlusions -## percent -## The max length of the occluded part -## expressed in % of the total chain length -class pyFillOcclusionsRelativeChainingIterator(ChainingIterator): - def __init__(self, percent): - ChainingIterator.__init__(self, 0, 1,None,1) - self._length = 0 - self._percent = float(percent) - def getExactTypeName(self): - return "pyFillOcclusionsChainingIterator" - def init(self): - # each time we're evaluating a chain length - # we try to do it once. Thus we reinit - # the chain length here: - self._length = 0 - def traverse(self, iter): - winner = None - winnerOrientation = 0 - print self.getCurrentEdge().getId().getFirst(), self.getCurrentEdge().getId().getSecond() - it = AdjacencyIterator(iter) - nextVertex = self.getVertex() - if(nextVertex.getNature() & T_VERTEX != 0): - tvertex = nextVertex.castToTVertex() - mateVE = tvertex.mate(self.getCurrentEdge()) - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getId() == mateVE.getId() ): - winner = ve - if(it.isIncoming() == 0): - winnerOrientation = 1 - else: - winnerOrientation = 0 - break - it.increment() - else: - ## case of NonTVertex - natures = [SILHOUETTE,BORDER,CREASE,SUGGESTIVE_CONTOUR,VALLEY,RIDGE] - for nat in natures: - if(self.getCurrentEdge().getNature() & nat != 0): - count=0 - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getNature() & nat != 0): - count = count+1 - winner = ve - if(it.isIncoming() == 0): - winnerOrientation = 1 - else: - winnerOrientation = 0 - it.increment() - if(count != 1): - winner = None - break - if(winner != None): - # check whether this edge was part of the selection - if(winner.getTimeStamp() != GetTimeStampCF()): - #print "---", winner.getId().getFirst(), winner.getId().getSecond() - # if not, let's check whether it's short enough with - # respect to the chain made without staying in the selection - #------------------------------------------------------------ - # Did we compute the prospective chain length already ? - if(self._length == 0): - #if not, let's do it - _it = pyChainSilhouetteGenericIterator(0,0) - _it.setBegin(winner) - _it.setCurrentEdge(winner) - _it.setOrientation(winnerOrientation) - _it.init() - while(_it.isEnd() == 0): - ve = _it.getObject() - #print "--------", ve.getId().getFirst(), ve.getId().getSecond() - self._length = self._length + ve.getLength2D() - _it.increment() - if(_it.isBegin() != 0): - break; - _it.setBegin(winner) - _it.setCurrentEdge(winner) - _it.setOrientation(winnerOrientation) - if(_it.isBegin() == 0): - _it.decrement() - while ((_it.isEnd() == 0) and (_it.isBegin() == 0)): - ve = _it.getObject() - #print "--------", ve.getId().getFirst(), ve.getId().getSecond() - self._length = self._length + ve.getLength2D() - _it.decrement() - - # let's do the comparison: - # nw let's compute the length of this connex non selected part: - connexl = 0 - _cit = pyChainSilhouetteGenericIterator(0,0) - _cit.setBegin(winner) - _cit.setCurrentEdge(winner) - _cit.setOrientation(winnerOrientation) - _cit.init() - while((_cit.isEnd() == 0) and (_cit.getObject().getTimeStamp() != GetTimeStampCF())): - ve = _cit.getObject() - #print "-------- --------", ve.getId().getFirst(), ve.getId().getSecond() - connexl = connexl + ve.getLength2D() - _cit.increment() - if(connexl > self._percent * self._length): - winner = None - return winner - -## Chaining iterator that fills small occlusions -## size -## The max length of the occluded part -## expressed in pixels -class pyFillOcclusionsAbsoluteChainingIterator(ChainingIterator): - def __init__(self, length): - ChainingIterator.__init__(self, 0, 1,None,1) - self._length = float(length) - def getExactTypeName(self): - return "pySmallFillOcclusionsChainingIterator" - def traverse(self, iter): - winner = None - winnerOrientation = 0 - #print self.getCurrentEdge().getId().getFirst(), self.getCurrentEdge().getId().getSecond() - it = AdjacencyIterator(iter) - nextVertex = self.getVertex() - if(nextVertex.getNature() & T_VERTEX != 0): - tvertex = nextVertex.castToTVertex() - mateVE = tvertex.mate(self.getCurrentEdge()) - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getId() == mateVE.getId() ): - winner = ve - if(it.isIncoming() == 0): - winnerOrientation = 1 - else: - winnerOrientation = 0 - break - it.increment() - else: - ## case of NonTVertex - natures = [SILHOUETTE,BORDER,CREASE,SUGGESTIVE_CONTOUR,VALLEY,RIDGE] - for nat in natures: - if(self.getCurrentEdge().getNature() & nat != 0): - count=0 - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getNature() & nat != 0): - count = count+1 - winner = ve - if(it.isIncoming() == 0): - winnerOrientation = 1 - else: - winnerOrientation = 0 - it.increment() - if(count != 1): - winner = None - break - if(winner != None): - # check whether this edge was part of the selection - if(winner.getTimeStamp() != GetTimeStampCF()): - #print "---", winner.getId().getFirst(), winner.getId().getSecond() - # nw let's compute the length of this connex non selected part: - connexl = 0 - _cit = pyChainSilhouetteGenericIterator(0,0) - _cit.setBegin(winner) - _cit.setCurrentEdge(winner) - _cit.setOrientation(winnerOrientation) - _cit.init() - while((_cit.isEnd() == 0) and (_cit.getObject().getTimeStamp() != GetTimeStampCF())): - ve = _cit.getObject() - #print "-------- --------", ve.getId().getFirst(), ve.getId().getSecond() - connexl = connexl + ve.getLength2D() - _cit.increment() - if(connexl > self._length): - winner = None - return winner - - -## Chaining iterator that fills small occlusions -## percent -## The max length of the occluded part -## expressed in % of the total chain length -class pyFillOcclusionsAbsoluteAndRelativeChainingIterator(ChainingIterator): - def __init__(self, percent, l): - ChainingIterator.__init__(self, 0, 1,None,1) - self._length = 0 - self._absLength = l - self._percent = float(percent) - def getExactTypeName(self): - return "pyFillOcclusionsChainingIterator" - def init(self): - # each time we're evaluating a chain length - # we try to do it once. Thus we reinit - # the chain length here: - self._length = 0 - def traverse(self, iter): - winner = None - winnerOrientation = 0 - print self.getCurrentEdge().getId().getFirst(), self.getCurrentEdge().getId().getSecond() - it = AdjacencyIterator(iter) - nextVertex = self.getVertex() - if(nextVertex.getNature() & T_VERTEX != 0): - tvertex = nextVertex.castToTVertex() - mateVE = tvertex.mate(self.getCurrentEdge()) - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getId() == mateVE.getId() ): - winner = ve - if(it.isIncoming() == 0): - winnerOrientation = 1 - else: - winnerOrientation = 0 - break - it.increment() - else: - ## case of NonTVertex - natures = [SILHOUETTE,BORDER,CREASE,SUGGESTIVE_CONTOUR,VALLEY,RIDGE] - for nat in natures: - if(self.getCurrentEdge().getNature() & nat != 0): - count=0 - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getNature() & nat != 0): - count = count+1 - winner = ve - if(it.isIncoming() == 0): - winnerOrientation = 1 - else: - winnerOrientation = 0 - it.increment() - if(count != 1): - winner = None - break - if(winner != None): - # check whether this edge was part of the selection - if(winner.getTimeStamp() != GetTimeStampCF()): - #print "---", winner.getId().getFirst(), winner.getId().getSecond() - # if not, let's check whether it's short enough with - # respect to the chain made without staying in the selection - #------------------------------------------------------------ - # Did we compute the prospective chain length already ? - if(self._length == 0): - #if not, let's do it - _it = pyChainSilhouetteGenericIterator(0,0) - _it.setBegin(winner) - _it.setCurrentEdge(winner) - _it.setOrientation(winnerOrientation) - _it.init() - while(_it.isEnd() == 0): - ve = _it.getObject() - #print "--------", ve.getId().getFirst(), ve.getId().getSecond() - self._length = self._length + ve.getLength2D() - _it.increment() - if(_it.isBegin() != 0): - break; - _it.setBegin(winner) - _it.setCurrentEdge(winner) - _it.setOrientation(winnerOrientation) - if(_it.isBegin() == 0): - _it.decrement() - while ((_it.isEnd() == 0) and (_it.isBegin() == 0)): - ve = _it.getObject() - #print "--------", ve.getId().getFirst(), ve.getId().getSecond() - self._length = self._length + ve.getLength2D() - _it.decrement() - - # let's do the comparison: - # nw let's compute the length of this connex non selected part: - connexl = 0 - _cit = pyChainSilhouetteGenericIterator(0,0) - _cit.setBegin(winner) - _cit.setCurrentEdge(winner) - _cit.setOrientation(winnerOrientation) - _cit.init() - while((_cit.isEnd() == 0) and (_cit.getObject().getTimeStamp() != GetTimeStampCF())): - ve = _cit.getObject() - #print "-------- --------", ve.getId().getFirst(), ve.getId().getSecond() - connexl = connexl + ve.getLength2D() - _cit.increment() - if((connexl > self._percent * self._length) or (connexl > self._absLength)): - winner = None - return winner - -## Chaining iterator that fills small occlusions without caring about the -## actual selection -## percent -## The max length of the occluded part -## expressed in % of the total chain length -class pyFillQi0AbsoluteAndRelativeChainingIterator(ChainingIterator): - def __init__(self, percent, l): - ChainingIterator.__init__(self, 0, 1,None,1) - self._length = 0 - self._absLength = l - self._percent = float(percent) - def getExactTypeName(self): - return "pyFillOcclusionsChainingIterator" - def init(self): - # each time we're evaluating a chain length - # we try to do it once. Thus we reinit - # the chain length here: - self._length = 0 - def traverse(self, iter): - winner = None - winnerOrientation = 0 - print self.getCurrentEdge().getId().getFirst(), self.getCurrentEdge().getId().getSecond() - it = AdjacencyIterator(iter) - nextVertex = self.getVertex() - if(nextVertex.getNature() & T_VERTEX != 0): - tvertex = nextVertex.castToTVertex() - mateVE = tvertex.mate(self.getCurrentEdge()) - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getId() == mateVE.getId() ): - winner = ve - if(it.isIncoming() == 0): - winnerOrientation = 1 - else: - winnerOrientation = 0 - break - it.increment() - else: - ## case of NonTVertex - natures = [SILHOUETTE,BORDER,CREASE,SUGGESTIVE_CONTOUR,VALLEY,RIDGE] - for nat in natures: - if(self.getCurrentEdge().getNature() & nat != 0): - count=0 - while(it.isEnd() == 0): - ve = it.getObject() - if(ve.getNature() & nat != 0): - count = count+1 - winner = ve - if(it.isIncoming() == 0): - winnerOrientation = 1 - else: - winnerOrientation = 0 - it.increment() - if(count != 1): - winner = None - break - if(winner != None): - # check whether this edge was part of the selection - if(winner.qi() != 0): - #print "---", winner.getId().getFirst(), winner.getId().getSecond() - # if not, let's check whether it's short enough with - # respect to the chain made without staying in the selection - #------------------------------------------------------------ - # Did we compute the prospective chain length already ? - if(self._length == 0): - #if not, let's do it - _it = pyChainSilhouetteGenericIterator(0,0) - _it.setBegin(winner) - _it.setCurrentEdge(winner) - _it.setOrientation(winnerOrientation) - _it.init() - while(_it.isEnd() == 0): - ve = _it.getObject() - #print "--------", ve.getId().getFirst(), ve.getId().getSecond() - self._length = self._length + ve.getLength2D() - _it.increment() - if(_it.isBegin() != 0): - break; - _it.setBegin(winner) - _it.setCurrentEdge(winner) - _it.setOrientation(winnerOrientation) - if(_it.isBegin() == 0): - _it.decrement() - while ((_it.isEnd() == 0) and (_it.isBegin() == 0)): - ve = _it.getObject() - #print "--------", ve.getId().getFirst(), ve.getId().getSecond() - self._length = self._length + ve.getLength2D() - _it.decrement() - - # let's do the comparison: - # nw let's compute the length of this connex non selected part: - connexl = 0 - _cit = pyChainSilhouetteGenericIterator(0,0) - _cit.setBegin(winner) - _cit.setCurrentEdge(winner) - _cit.setOrientation(winnerOrientation) - _cit.init() - while((_cit.isEnd() == 0) and (_cit.getObject().qi() != 0)): - ve = _cit.getObject() - #print "-------- --------", ve.getId().getFirst(), ve.getId().getSecond() - connexl = connexl + ve.getLength2D() - _cit.increment() - if((connexl > self._percent * self._length) or (connexl > self._absLength)): - winner = None - 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. -class pyNoIdChainSilhouetteIterator(ChainingIterator): - def __init__(self, stayInSelection=1): - ChainingIterator.__init__(self, stayInSelection, 1,None,1) - def getExactTypeName(self): - return "pyChainSilhouetteIterator" - def traverse(self, iter): - winner = None - it = AdjacencyIterator(iter) - nextVertex = self.getVertex() - if(nextVertex.getNature() & T_VERTEX != 0): - tvertex = nextVertex.castToTVertex() - mateVE = tvertex.mate(self.getCurrentEdge()) - while(it.isEnd() == 0): - ve = it.getObject() - feB = self.getCurrentEdge().fedgeB() - feA = ve.fedgeA() - vB = feB.vertexB() - vA = feA.vertexA() - if vA.getId().getFirst() == vB.getId().getFirst(): - winner = ve - break - feA = self.getCurrentEdge().fedgeA() - feB = ve.fedgeB() - vB = feB.vertexB() - vA = feA.vertexA() - if vA.getId().getFirst() == vB.getId().getFirst(): - winner = ve - break - feA = self.getCurrentEdge().fedgeB() - feB = ve.fedgeB() - vB = feB.vertexB() - vA = feA.vertexB() - if vA.getId().getFirst() == vB.getId().getFirst(): - winner = ve - break - feA = self.getCurrentEdge().fedgeA() - feB = ve.fedgeA() - vB = feB.vertexA() - vA = feA.vertexA() - if vA.getId().getFirst() == vB.getId().getFirst(): - winner = ve - break - it.increment() - else: - ## case of NonTVertex - natures = [SILHOUETTE,BORDER,CREASE,SUGGESTIVE_CONTOUR,VALLEY,RIDGE] - for i in range(len(natures)): - currentNature = self.getCurrentEdge().getNature() - if(natures[i] & currentNature): - count=0 - while(it.isEnd() == 0): - visitNext = 0 - oNature = it.getObject().getNature() - 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.getObject() - it.increment() - if(count != 1): - winner = None - break - return winner - diff --git a/source/blender/freestyle/style_modules_old/Functions0D.py b/source/blender/freestyle/style_modules_old/Functions0D.py deleted file mode 100755 index c1ba591c789..00000000000 --- a/source/blender/freestyle/style_modules_old/Functions0D.py +++ /dev/null @@ -1,81 +0,0 @@ -from Freestyle import * - - -class pyInverseCurvature2DAngleF0D(UnaryFunction0DDouble): - def getName(self): - return "InverseCurvature2DAngleF0D" - - def __call__(self, inter): - func = Curvature2DAngleF0D() - c = func(inter) - return (3.1415 - c) - -class pyCurvilinearLengthF0D(UnaryFunction0DDouble): - def getName(self): - return "CurvilinearLengthF0D" - - def __call__(self, inter): - i0d = inter.getObject() - s = i0d.getExactTypeName() - if (string.find(s, "CurvePoint") == -1): - print "CurvilinearLengthF0D: not implemented yet for %s" % (s) - return -1 - cp = castToCurvePoint(i0d) - return cp.t2d() - -## estimate anisotropy of density -class pyDensityAnisotropyF0D(UnaryFunction0DDouble): - def __init__(self,level): - UnaryFunction0DDouble.__init__(self) - self.IsoDensity = ReadCompleteViewMapPixelF0D(level) - self.d0Density = ReadSteerableViewMapPixelF0D(0, level) - self.d1Density = ReadSteerableViewMapPixelF0D(1, level) - self.d2Density = ReadSteerableViewMapPixelF0D(2, level) - self.d3Density = ReadSteerableViewMapPixelF0D(3, level) - def getName(self): - return "pyDensityAnisotropyF0D" - def __call__(self, inter): - c_iso = self.IsoDensity(inter) - c_0 = self.d0Density(inter) - c_1 = self.d1Density(inter) - c_2 = self.d2Density(inter) - c_3 = self.d3Density(inter) - cMax = max( max(c_0,c_1), max(c_2,c_3)) - cMin = min( min(c_0,c_1), min(c_2,c_3)) - if ( c_iso == 0 ): - v = 0 - else: - v = (cMax-cMin)/c_iso - return (v) - -## Returns the gradient vector for a pixel -## l -## the level at which one wants to compute the gradient -class pyViewMapGradientVectorF0D(UnaryFunction0DVec2f): - def __init__(self, l): - UnaryFunction0DVec2f.__init__(self) - self._l = l - self._step = pow(2,self._l) - def getName(self): - return "pyViewMapGradientVectorF0D" - def __call__(self, iter): - p = iter.getObject().getPoint2D() - gx = ReadCompleteViewMapPixelCF(self._l, int(p.x()+self._step), int(p.y()))- ReadCompleteViewMapPixelCF(self._l, int(p.x()), int(p.y())) - gy = ReadCompleteViewMapPixelCF(self._l, int(p.x()), int(p.y()+self._step))- ReadCompleteViewMapPixelCF(self._l, int(p.x()), int(p.y())) - return Vec2f(gx, gy) - -class pyViewMapGradientNormF0D(UnaryFunction0DDouble): - def __init__(self, l): - UnaryFunction0DDouble.__init__(self) - self._l = l - self._step = pow(2,self._l) - def getName(self): - return "pyViewMapGradientNormF0D" - def __call__(self, iter): - p = iter.getObject().getPoint2D() - gx = ReadCompleteViewMapPixelCF(self._l, int(p.x()+self._step), int(p.y()))- ReadCompleteViewMapPixelCF(self._l, int(p.x()), int(p.y())) - gy = ReadCompleteViewMapPixelCF(self._l, int(p.x()), int(p.y()+self._step))- ReadCompleteViewMapPixelCF(self._l, int(p.x()), int(p.y())) - grad = Vec2f(gx, gy) - return grad.norm() - - diff --git a/source/blender/freestyle/style_modules_old/Functions1D.py b/source/blender/freestyle/style_modules_old/Functions1D.py deleted file mode 100755 index e2505466aae..00000000000 --- a/source/blender/freestyle/style_modules_old/Functions1D.py +++ /dev/null @@ -1,45 +0,0 @@ -from Freestyle import * -from Functions0D import * -import string - -class pyGetInverseProjectedZF1D(UnaryFunction1DDouble): - def getName(self): - return "pyGetInverseProjectedZF1D" - - def __call__(self, inter): - func = GetProjectedZF1D() - z = func(inter) - return (1.0 - z) - -class pyGetSquareInverseProjectedZF1D(UnaryFunction1DDouble): - def getName(self): - return "pyGetInverseProjectedZF1D" - - def __call__(self, inter): - func = GetProjectedZF1D() - z = func(inter) - return (1.0 - z*z) - -class pyDensityAnisotropyF1D(UnaryFunction1DDouble): - def __init__(self,level, integrationType=MEAN, sampling=2.0): - UnaryFunction1DDouble.__init__(self, integrationType) - self._func = pyDensityAnisotropyF0D(level) - self._integration = integrationType - self._sampling = sampling - def getName(self): - return "pyDensityAnisotropyF1D" - def __call__(self, inter): - v = integrateDouble(self._func, inter.pointsBegin(self._sampling), inter.pointsEnd(self._sampling), self._integration) - return v - -class pyViewMapGradientNormF1D(UnaryFunction1DDouble): - def __init__(self,l, integrationType, sampling=2.0): - UnaryFunction1DDouble.__init__(self, integrationType) - self._func = pyViewMapGradientNormF0D(l) - self._integration = integrationType - self._sampling = sampling - def getName(self): - return "pyViewMapGradientNormF1D" - def __call__(self, inter): - v = integrateDouble(self._func, inter.pointsBegin(self._sampling), inter.pointsEnd(self._sampling), self._integration) - return v diff --git a/source/blender/freestyle/style_modules_old/PredicatesB1D.py b/source/blender/freestyle/style_modules_old/PredicatesB1D.py deleted file mode 100755 index dfc895e8d9b..00000000000 --- a/source/blender/freestyle/style_modules_old/PredicatesB1D.py +++ /dev/null @@ -1,70 +0,0 @@ -from Freestyle import * -from Functions1D import * -from random import * - -class pyZBP1D(BinaryPredicate1D): - def getName(self): - return "pyZBP1D" - - def __call__(self, i1, i2): - func = GetZF1D() - return (func(i1) > func(i2)) - -class pyZDiscontinuityBP1D(BinaryPredicate1D): - def __init__(self, iType = MEAN): - BinaryPredicate1D.__init__(self) - self._GetZDiscontinuity = ZDiscontinuityF1D(iType) - - def getName(self): - return "pyZDiscontinuityBP1D" - - def __call__(self, i1, i2): - return (self._GetZDiscontinuity(i1) > self._GetZDiscontinuity(i2)) - -class pyLengthBP1D(BinaryPredicate1D): - def getName(self): - return "LengthBP1D" - - def __call__(self, i1, i2): - return (i1.getLength2D() > i2.getLength2D()) - -class pySilhouetteFirstBP1D(BinaryPredicate1D): - def getName(self): - return "SilhouetteFirstBP1D" - - def __call__(self, inter1, inter2): - bpred = SameShapeIdBP1D() - if (bpred(inter1, inter2) != 1): - return 0 - if (inter1.getNature() & SILHOUETTE): - return (inter2.getNature() & SILHOUETTE) - return (inter1.getNature() == inter2.getNature()) - -class pyNatureBP1D(BinaryPredicate1D): - def getName(self): - return "NatureBP1D" - - def __call__(self, inter1, inter2): - return (inter1.getNature() & inter2.getNature()) - -class pyViewMapGradientNormBP1D(BinaryPredicate1D): - def __init__(self,l, sampling=2.0): - BinaryPredicate1D.__init__(self) - self._GetGradient = pyViewMapGradientNormF1D(l, MEAN) - def getName(self): - return "pyViewMapGradientNormBP1D" - def __call__(self, i1,i2): - print "compare gradient" - return (self._GetGradient(i1) > self._GetGradient(i2)) - -class pyShuffleBP1D(BinaryPredicate1D): - def __init__(self): - BinaryPredicate1D.__init__(self) - seed(1) - def getName(self): - return "pyNearAndContourFirstBP1D" - - def __call__(self, inter1, inter2): - r1 = uniform(0,1) - r2 = uniform(0,1) - return (r1 self._a) - -class pyUEqualsUP0D(UnaryPredicate0D): - def __init__(self,u, w): - UnaryPredicate0D.__init__(self) - self._u = u - self._w = w - - def getName(self): - return "UEqualsUP0D" - - def __call__(self, inter): - func = pyCurvilinearLengthF0D() - u = func(inter) - return ( ( u > (self._u-self._w) ) and ( u < (self._u+self._w) ) ) - -class pyVertexNatureUP0D(UnaryPredicate0D): - def __init__(self,nature): - UnaryPredicate0D.__init__(self) - self._nature = nature - - def getName(self): - return "pyVertexNatureUP0D" - - def __call__(self, inter): - v = inter.getObject() - nat = v.getNature() - if(nat & self._nature): - return 1; - return 0 - -## check whether an Interface0DIterator -## is a TVertex and is the one that is -## hidden (inferred from the context) -class pyBackTVertexUP0D(UnaryPredicate0D): - def __init__(self): - UnaryPredicate0D.__init__(self) - self._getQI = QuantitativeInvisibilityF0D() - def getName(self): - return "pyBackTVertexUP0D" - def __call__(self, iter): - v = iter.getObject() - nat = v.getNature() - if(nat & T_VERTEX == 0): - return 0 - next = iter - if(next.isEnd()): - return 0 - if(self._getQI(next) != 0): - return 1 - return 0 - -class pyParameterUP0DGoodOne(UnaryPredicate0D): - def __init__(self,pmin,pmax): - UnaryPredicate0D.__init__(self) - self._m = pmin - self._M = pmax - #self.getCurvilinearAbscissa = GetCurvilinearAbscissaF0D() - - def getName(self): - return "pyCurvilinearAbscissaHigherThanUP0D" - - def __call__(self, inter): - #s = self.getCurvilinearAbscissa(inter) - u = inter.u() - #print u - return ((u>=self._m) and (u<=self._M)) - -class pyParameterUP0D(UnaryPredicate0D): - def __init__(self,pmin,pmax): - UnaryPredicate0D.__init__(self) - self._m = pmin - self._M = pmax - #self.getCurvilinearAbscissa = GetCurvilinearAbscissaF0D() - - def getName(self): - return "pyCurvilinearAbscissaHigherThanUP0D" - - def __call__(self, inter): - func = Curvature2DAngleF0D() - c = func(inter) - b1 = (c>0.1) - #s = self.getCurvilinearAbscissa(inter) - u = inter.u() - #print u - b = ((u>=self._m) and (u<=self._M)) - return b and b1 - - diff --git a/source/blender/freestyle/style_modules_old/PredicatesU1D.py b/source/blender/freestyle/style_modules_old/PredicatesU1D.py deleted file mode 100755 index 18e9686f9df..00000000000 --- a/source/blender/freestyle/style_modules_old/PredicatesU1D.py +++ /dev/null @@ -1,381 +0,0 @@ -from Freestyle import * -from Functions1D import * - -count = 0 -class pyNFirstUP1D(UnaryPredicate1D): - def __init__(self, n): - UnaryPredicate1D.__init__(self) - self.__n = n - def __call__(self, inter): - global count - count = count + 1 - if count <= self.__n: - return 1 - return 0 - -class pyHigherLengthUP1D(UnaryPredicate1D): - def __init__(self,l): - UnaryPredicate1D.__init__(self) - self._l = l - - def getName(self): - return "HigherLengthUP1D" - - def __call__(self, inter): - return (inter.getLength2D() > self._l) - -class pyNatureUP1D(UnaryPredicate1D): - def __init__(self,nature): - UnaryPredicate1D.__init__(self) - self._nature = nature - self._getNature = CurveNatureF1D() - - def getName(self): - return "pyNatureUP1D" - - def __call__(self, inter): - if(self._getNature(inter) & self._nature): - return 1 - return 0 - -class pyHigherNumberOfTurnsUP1D(UnaryPredicate1D): - def __init__(self,n,a): - UnaryPredicate1D.__init__(self) - self._n = n - self._a = a - - def getName(self): - return "HigherNumberOfTurnsUP1D" - - def __call__(self, inter): - count = 0 - func = Curvature2DAngleF0D() - it = inter.verticesBegin() - while(it.isEnd() == 0): - if(func(it) > self._a): - count = count+1 - if(count > self._n): - return 1 - it.increment() - return 0 - -class pyDensityUP1D(UnaryPredicate1D): - def __init__(self,wsize,threshold, integration = MEAN, sampling=2.0): - UnaryPredicate1D.__init__(self) - self._wsize = wsize - self._threshold = threshold - self._integration = integration - self._func = DensityF1D(self._wsize, self._integration, sampling) - - def getName(self): - return "pyDensityUP1D" - - def __call__(self, inter): - if(self._func(inter) < self._threshold): - return 1 - return 0 - -class pyLowSteerableViewMapDensityUP1D(UnaryPredicate1D): - def __init__(self,threshold, level,integration = MEAN): - UnaryPredicate1D.__init__(self) - self._threshold = threshold - self._level = level - self._integration = integration - - def getName(self): - return "pyLowSteerableViewMapDensityUP1D" - - def __call__(self, inter): - func = GetSteerableViewMapDensityF1D(self._level, self._integration) - v = func(inter) - print v - if(v < self._threshold): - return 1 - return 0 - -class pyLowDirectionalViewMapDensityUP1D(UnaryPredicate1D): - def __init__(self,threshold, orientation, level,integration = MEAN): - UnaryPredicate1D.__init__(self) - self._threshold = threshold - self._orientation = orientation - self._level = level - self._integration = integration - - def getName(self): - return "pyLowDirectionalViewMapDensityUP1D" - - def __call__(self, inter): - func = GetDirectionalViewMapDensityF1D(self._orientation, self._level, self._integration) - v = func(inter) - #print v - if(v < self._threshold): - return 1 - return 0 - -class pyHighSteerableViewMapDensityUP1D(UnaryPredicate1D): - def __init__(self,threshold, level,integration = MEAN): - UnaryPredicate1D.__init__(self) - self._threshold = threshold - self._level = level - self._integration = integration - self._func = GetSteerableViewMapDensityF1D(self._level, self._integration) - def getName(self): - return "pyHighSteerableViewMapDensityUP1D" - - def __call__(self, inter): - - v = self._func(inter) - if(v > self._threshold): - return 1 - return 0 - -class pyHighDirectionalViewMapDensityUP1D(UnaryPredicate1D): - def __init__(self,threshold, orientation, level,integration = MEAN, sampling=2.0): - UnaryPredicate1D.__init__(self) - self._threshold = threshold - self._orientation = orientation - self._level = level - self._integration = integration - self._sampling = sampling - def getName(self): - return "pyLowDirectionalViewMapDensityUP1D" - - def __call__(self, inter): - func = GetDirectionalViewMapDensityF1D(self._orientation, self._level, self._integration, self._sampling) - v = func(inter) - if(v > self._threshold): - return 1 - return 0 - -class pyHighViewMapDensityUP1D(UnaryPredicate1D): - def __init__(self,threshold, level,integration = MEAN, sampling=2.0): - UnaryPredicate1D.__init__(self) - self._threshold = threshold - self._level = level - self._integration = integration - self._sampling = sampling - self._func = GetCompleteViewMapDensityF1D(self._level, self._integration, self._sampling) # 2.0 is the smpling - - def getName(self): - return "pyHighViewMapDensityUP1D" - - def __call__(self, inter): - #print "toto" - #print func.getName() - #print inter.getExactTypeName() - v= self._func(inter) - if(v > self._threshold): - return 1 - return 0 - -class pyDensityFunctorUP1D(UnaryPredicate1D): - def __init__(self,wsize,threshold, functor, funcmin=0.0, funcmax=1.0, integration = MEAN): - UnaryPredicate1D.__init__(self) - self._wsize = wsize - self._threshold = float(threshold) - self._functor = functor - self._funcmin = float(funcmin) - self._funcmax = float(funcmax) - self._integration = integration - - def getName(self): - return "pyDensityFunctorUP1D" - - def __call__(self, inter): - func = DensityF1D(self._wsize, self._integration) - res = self._functor(inter) - k = (res-self._funcmin)/(self._funcmax-self._funcmin) - if(func(inter) < self._threshold*k): - return 1 - return 0 - -class pyZSmallerUP1D(UnaryPredicate1D): - def __init__(self,z, integration=MEAN): - UnaryPredicate1D.__init__(self) - self._z = z - self._integration = integration - def getName(self): - return "pyZSmallerUP1D" - - def __call__(self, inter): - func = GetProjectedZF1D(self._integration) - if(func(inter) < self._z): - return 1 - return 0 - -class pyIsOccludedByUP1D(UnaryPredicate1D): - def __init__(self,id): - UnaryPredicate1D.__init__(self) - self._id = id - def getName(self): - return "pyIsOccludedByUP1D" - def __call__(self, inter): - func = GetShapeF1D() - shapes = func(inter) - for s in shapes: - if(s.getId() == self._id): - return 0 - it = inter.verticesBegin() - itlast = inter.verticesEnd() - itlast.decrement() - v = it.getObject() - vlast = itlast.getObject() - tvertex = v.castToTVertex() - if(tvertex != None): - #print "TVertex: [ ", tvertex.getId().getFirst(), ",", tvertex.getId().getSecond()," ]" - eit = tvertex.edgesBegin() - while(eit.isEnd() == 0): - ve = eit.getObject().first - if(ve.shape_id() == self._id): - return 1 - #print "-------", ve.getId().getFirst(), "-", ve.getId().getSecond() - eit.increment() - tvertex = vlast.castToTVertex() - if(tvertex != None): - #print "TVertex: [ ", tvertex.getId().getFirst(), ",", tvertex.getId().getSecond()," ]" - eit = tvertex.edgesBegin() - while(eit.isEnd() == 0): - ve = eit.getObject().first - if(ve.shape_id() == self._id): - return 1 - #print "-------", ve.getId().getFirst(), "-", ve.getId().getSecond() - eit.increment() - return 0 - -class pyIsInOccludersListUP1D(UnaryPredicate1D): - def __init__(self,id): - UnaryPredicate1D.__init__(self) - self._id = id - def getName(self): - return "pyIsInOccludersListUP1D" - def __call__(self, inter): - func = GetOccludersF1D() - occluders = func(inter) - for a in occluders: - if(a.getId() == self._id): - return 1 - return 0 - -class pyIsOccludedByItselfUP1D(UnaryPredicate1D): - def __init__(self): - UnaryPredicate1D.__init__(self) - self.__func1 = GetOccludersF1D() - self.__func2 = GetShapeF1D() - def getName(self): - return "pyIsOccludedByItselfUP1D" - def __call__(self, inter): - lst1 = self.__func1(inter) - lst2 = self.__func2(inter) - for vs1 in lst1: - for vs2 in lst2: - if vs1.getId() == vs2.getId(): - return 1 - return 0 - -class pyIsOccludedByIdListUP1D(UnaryPredicate1D): - def __init__(self, idlist): - UnaryPredicate1D.__init__(self) - self._idlist = idlist - self.__func1 = GetOccludersF1D() - def getName(self): - return "pyIsOccludedByIdListUP1D" - def __call__(self, inter): - lst1 = self.__func1(inter) - for vs1 in lst1: - for id in self._idlist: - if vs1.getId() == id: - return 1 - return 0 - -class pyShapeIdListUP1D(UnaryPredicate1D): - def __init__(self,idlist): - UnaryPredicate1D.__init__(self) - self._idlist = idlist - self._funcs = [] - for id in idlist : - self._funcs.append(ShapeUP1D(id.getFirst(), id.getSecond())) - - def getName(self): - return "pyShapeIdUP1D" - def __call__(self, inter): - for func in self._funcs : - if(func(inter) == 1) : - return 1 - return 0 - -## deprecated -class pyShapeIdUP1D(UnaryPredicate1D): - def __init__(self,id): - UnaryPredicate1D.__init__(self) - self._id = id - def getName(self): - return "pyShapeIdUP1D" - def __call__(self, inter): - func = GetShapeF1D() - shapes = func(inter) - for a in shapes: - if(a.getId() == self._id): - return 1 - return 0 - -class pyHighDensityAnisotropyUP1D(UnaryPredicate1D): - def __init__(self,threshold, level, sampling=2.0): - UnaryPredicate1D.__init__(self) - self._l = threshold - self.func = pyDensityAnisotropyF1D(level, MEAN, sampling) - def getName(self): - return "pyHighDensityAnisotropyUP1D" - def __call__(self, inter): - return (self.func(inter) > self._l) - -class pyHighViewMapGradientNormUP1D(UnaryPredicate1D): - def __init__(self,threshold, l, sampling=2.0): - UnaryPredicate1D.__init__(self) - self._threshold = threshold - self._GetGradient = pyViewMapGradientNormF1D(l, MEAN) - def getName(self): - return "pyHighViewMapGradientNormUP1D" - def __call__(self, inter): - gn = self._GetGradient(inter) - #print gn - return (gn > self._threshold) - -class pyDensityVariableSigmaUP1D(UnaryPredicate1D): - def __init__(self,functor, sigmaMin,sigmaMax, lmin, lmax, tmin, tmax, integration = MEAN, sampling=2.0): - UnaryPredicate1D.__init__(self) - self._functor = functor - self._sigmaMin = float(sigmaMin) - self._sigmaMax = float(sigmaMax) - self._lmin = float(lmin) - self._lmax = float(lmax) - self._tmin = tmin - self._tmax = tmax - self._integration = integration - self._sampling = sampling - - def getName(self): - return "pyDensityUP1D" - - def __call__(self, inter): - 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 - if(sigma 4* c ): - if ( c < 1.5*self._threshold ): - return 1 - return 0 - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(),NotUP1D(QuantitativeInvisibilityUP1D(0))) -Operators.select(pyHigherLengthUP1D(40)) -## selects lines having a high anisotropic a priori density -Operators.select(pyHighDensityAnisotropyUP1D(0.3,4)) -Operators.sort(pyLengthBP1D()) -shaders_list = [ - SamplingShader(2.0), - ConstantThicknessShader(2), - ConstantColorShader(0.2,0.2,0.25,1), - ] -## uniform culling -Operators.create(pyDensityUP1D(3.0,2.0e-2, MEAN, 0.1), shaders_list) - - diff --git a/source/blender/freestyle/style_modules_old/multiple_parameterization.py b/source/blender/freestyle/style_modules_old/multiple_parameterization.py deleted file mode 100755 index ff04c5930c5..00000000000 --- a/source/blender/freestyle/style_modules_old/multiple_parameterization.py +++ /dev/null @@ -1,51 +0,0 @@ -# -# Filename : multiple_parameterization.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : The thickness and the color of the strokes vary continuously -# independently from occlusions although only -# visible lines are actually drawn. This is equivalent -# to assigning the thickness using a parameterization covering -# the complete silhouette (visible+invisible) and drawing -# the strokes using a second parameterization that only -# covers the visible portions. -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from ChainingIterators import * -from shaders import * - -Operators.select(QuantitativeInvisibilityUP1D(0)) -## Chain following the same nature, but without the restriction -## of staying inside the selection (0). -Operators.bidirectionalChain(ChainSilhouetteIterator(0)) -shaders_list = [ - SamplingShader(20), - IncreasingThicknessShader(1.5, 30), - ConstantColorShader(0.0,0.0,0.0), - IncreasingColorShader(1,0,0,1,0,1,0,1), - TextureAssignerShader(-1), - pyHLRShader() ## this shader draws only visible portions - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/nature.py b/source/blender/freestyle/style_modules_old/nature.py deleted file mode 100755 index 8cfd480ba3b..00000000000 --- a/source/blender/freestyle/style_modules_old/nature.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# Filename : nature.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Uses the NatureUP1D predicate to select the lines -# of a given type (among SILHOUETTE, CREASE, SUGGESTIVE_CONTOURS, -# BORDERS). -# The suggestive contours must have been enabled in the -# options dialog to appear in the View Map. -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesB1D import * -from shaders import * - -Operators.select(pyNatureUP1D(SILHOUETTE)) -Operators.bidirectionalChain(ChainSilhouetteIterator(),NotUP1D( pyNatureUP1D( SILHOUETTE) ) ) -shaders_list = [ - IncreasingThicknessShader(3, 10), - IncreasingColorShader(0.0,0.0,0.0, 1, 0.8,0,0,1) - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/near_lines.py b/source/blender/freestyle/style_modules_old/near_lines.py deleted file mode 100755 index b132f6b5802..00000000000 --- a/source/blender/freestyle/style_modules_old/near_lines.py +++ /dev/null @@ -1,44 +0,0 @@ -# -# Filename : near_lines.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws the lines that are "closer" than a threshold -# (between 0 and 1) -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - - -from Freestyle import * -from logical_operators import * -from PredicatesB1D import * -from PredicatesU1D import * -from shaders import * - -upred = AndUP1D(QuantitativeInvisibilityUP1D(0), pyZSmallerUP1D(0.5, MEAN)) -Operators.select(upred) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(upred)) -shaders_list = [ - TextureAssignerShader(-1), - ConstantThicknessShader(5), - ConstantColorShader(0.0, 0.0, 0.0) - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/occluded_by_specific_object.py b/source/blender/freestyle/style_modules_old/occluded_by_specific_object.py deleted file mode 100755 index 96f431c2c4e..00000000000 --- a/source/blender/freestyle/style_modules_old/occluded_by_specific_object.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Filename : occluded_by_specific_object.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws only the lines that are occluded by a given object -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesU1D import * -from shaders import * - -## the id of the occluder (use SHIFT+click on the ViewMap to -## retrieve ids) -id = Id(3,0) -upred = AndUP1D(NotUP1D(QuantitativeInvisibilityUP1D(0)), -pyIsInOccludersListUP1D(id)) -Operators.select(upred) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(upred)) -shaders_list = [ - SamplingShader(5), - ConstantThicknessShader(3), - ConstantColorShader(0.3,0.3,0.3,1) - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/polygonalize.py b/source/blender/freestyle/style_modules_old/polygonalize.py deleted file mode 100755 index 81d47178404..00000000000 --- a/source/blender/freestyle/style_modules_old/polygonalize.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# Filename : polygonalize.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Make the strokes more "polygonal" -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# -from Freestyle import * -from logical_operators import * -from ChainingIterators import * -from shaders import * - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(),NotUP1D(QuantitativeInvisibilityUP1D(0))) -shaders_list = [ - SamplingShader(2.0), - ConstantThicknessShader(3), - ConstantColorShader(0.0,0.0,0.0), - PolygonalizationShader(8) - ] -Operators.create(TrueUP1D(), shaders_list) \ No newline at end of file diff --git a/source/blender/freestyle/style_modules_old/qi0.py b/source/blender/freestyle/style_modules_old/qi0.py deleted file mode 100755 index f742b777738..00000000000 --- a/source/blender/freestyle/style_modules_old/qi0.py +++ /dev/null @@ -1,41 +0,0 @@ -# -# Filename : qi0.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws the visible lines (chaining follows same nature lines) -# (most basic style module) -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from ChainingIterators import * -from shaders import * - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) -shaders_list = [ - SamplingShader(5.0), - ConstantThicknessShader(4.0), - ConstantColorShader(0.0,0.0,0.0) - ] -Operators.create(TrueUP1D(), shaders_list) \ No newline at end of file diff --git a/source/blender/freestyle/style_modules_old/qi0_not_external_contour.py b/source/blender/freestyle/style_modules_old/qi0_not_external_contour.py deleted file mode 100755 index 047ab7e1a8e..00000000000 --- a/source/blender/freestyle/style_modules_old/qi0_not_external_contour.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# Filename : qi0_not_external_contour.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws the visible lines (chaining follows same nature lines) -# that do not belong to the external contour of the scene -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * - -upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ExternalContourUP1D()) -Operators.select(upred) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(upred)) -shaders_list = [ - SamplingShader(4), - SpatialNoiseShader(4, 150, 2, 1, 1), - IncreasingThicknessShader(2, 5), - BackboneStretcherShader(20), - IncreasingColorShader(1,0,0,1,0,1,0,1), - TextureAssignerShader(4) - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/qi1.py b/source/blender/freestyle/style_modules_old/qi1.py deleted file mode 100755 index 234d196f15e..00000000000 --- a/source/blender/freestyle/style_modules_old/qi1.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# Filename : qi1.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws lines hidden by one surface. -# *** Quantitative Invisibility must have been -# enabled in the options dialog to use this style module **** -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesB1D import * -from shaders import * - -Operators.select(QuantitativeInvisibilityUP1D(1)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(1))) -shaders_list = [ - SamplingShader(5.0), - ConstantThicknessShader(3), - ConstantColorShader(0.5,0.5,0.5, 1) - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/qi2.py b/source/blender/freestyle/style_modules_old/qi2.py deleted file mode 100755 index 8e45914c619..00000000000 --- a/source/blender/freestyle/style_modules_old/qi2.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# Filename : qi2.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws lines hidden by two surfaces. -# *** Quantitative Invisibility must have been -# enabled in the options dialog to use this style module **** -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesB1D import * -from shaders import * - -Operators.select(QuantitativeInvisibilityUP1D(2)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(2))) -shaders_list = [ - SamplingShader(10), - ConstantThicknessShader(1.5), - ConstantColorShader(0.7,0.7,0.7, 1) - ] -Operators.create(TrueUP1D(), shaders_list) \ No newline at end of file diff --git a/source/blender/freestyle/style_modules_old/sequentialsplit_sketchy.py b/source/blender/freestyle/style_modules_old/sequentialsplit_sketchy.py deleted file mode 100755 index b33cd5d4043..00000000000 --- a/source/blender/freestyle/style_modules_old/sequentialsplit_sketchy.py +++ /dev/null @@ -1,68 +0,0 @@ -# -# Filename : sequentialsplit_sketchy.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Use the sequential split with two different -# predicates to specify respectively the starting and -# the stopping extremities for strokes -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesU1D import * -from PredicatesU0D import * -from Functions0D import * - -## Predicate to tell whether a TVertex -## corresponds to a change from 0 to 1 or not. -class pyBackTVertexUP0D(UnaryPredicate0D): - def __init__(self): - UnaryPredicate0D.__init__(self) - self._getQI = QuantitativeInvisibilityF0D() - def getName(self): - return "pyBackTVertexUP0D" - def __call__(self, iter): - v = iter.getObject() - nat = v.getNature() - if(nat & T_VERTEX == 0): - return 0 - if(self._getQI(iter) != 0): - return 1 - return 0 - - -upred = QuantitativeInvisibilityUP1D(0) -Operators.select(upred) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(upred)) -## starting and stopping predicates: -start = pyVertexNatureUP0D(NON_T_VERTEX) -stop = pyBackTVertexUP0D() -Operators.sequentialSplit(start, stop, 10) -shaders_list = [ - SpatialNoiseShader(7, 120, 2, 1, 1), - IncreasingThicknessShader(5, 8), - ConstantColorShader(0.2, 0.2, 0.2, 1), - TextureAssignerShader(4) - ] -Operators.create(TrueUP1D(), shaders_list) - diff --git a/source/blender/freestyle/style_modules_old/shaders.py b/source/blender/freestyle/style_modules_old/shaders.py deleted file mode 100755 index 208dfe91bb6..00000000000 --- a/source/blender/freestyle/style_modules_old/shaders.py +++ /dev/null @@ -1,1288 +0,0 @@ -from Freestyle import * -from PredicatesU0D import * -from PredicatesB1D import * -from PredicatesU1D import * -from logical_operators import * -from ChainingIterators import * -from random import * -from math import * -from vector import * - -## thickness modifiers -###################### - -class pyDepthDiscontinuityThicknessShader(StrokeShader): - def __init__(self, min, max): - StrokeShader.__init__(self) - self.__min = float(min) - self.__max = float(max) - self.__func = ZDiscontinuityF0D() - def getName(self): - return "pyDepthDiscontinuityThicknessShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - z_min=0.0 - z_max=1.0 - a = (self.__max - self.__min)/(z_max-z_min) - b = (self.__min*z_max-self.__max*z_min)/(z_max-z_min) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - z = self.__func(it.castToInterface0DIterator()) - thickness = a*z+b - it.getObject().attribute().setThickness(thickness, thickness) - it.increment() - -class pyConstantThicknessShader(StrokeShader): - def __init__(self, thickness): - StrokeShader.__init__(self) - self._thickness = thickness - - def getName(self): - return "pyConstantThicknessShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - t = self._thickness/2.0 - att.setThickness(t, t) - it.increment() - -class pyFXSThicknessShader(StrokeShader): - def __init__(self, thickness): - StrokeShader.__init__(self) - self._thickness = thickness - - def getName(self): - return "pyFXSThicknessShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - t = self._thickness/2.0 - att.setThickness(t, t) - it.increment() - -class pyFXSVaryingThicknessWithDensityShader(StrokeShader): - def __init__(self, wsize, threshold_min, threshold_max, thicknessMin, thicknessMax): - StrokeShader.__init__(self) - self.wsize= wsize - self.threshold_min= threshold_min - self.threshold_max= threshold_max - self._thicknessMin = thicknessMin - self._thicknessMax = thicknessMax - - def getName(self): - return "pyVaryingThicknessWithDensityShader" - def shade(self, stroke): - n = stroke.strokeVerticesSize() - i = 0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - func = DensityF0D(self.wsize) - while it.isEnd() == 0: - att = it.getObject().attribute() - toto = it.castToInterface0DIterator() - c= func(toto) - if (c < self.threshold_min ): - c = self.threshold_min - if (c > self.threshold_max ): - c = self.threshold_max -## t = (c - self.threshold_min)/(self.threshold_max - self.threshold_min)*(self._thicknessMax-self._thicknessMin) + self._thicknessMin - t = (self.threshold_max - c )/(self.threshold_max - self.threshold_min)*(self._thicknessMax-self._thicknessMin) + self._thicknessMin - att.setThickness(t/2.0, t/2.0) - i = i+1 - it.increment() -class pyIncreasingThicknessShader(StrokeShader): - def __init__(self, thicknessMin, thicknessMax): - StrokeShader.__init__(self) - self._thicknessMin = thicknessMin - self._thicknessMax = thicknessMax - - def getName(self): - return "pyIncreasingThicknessShader" - def shade(self, stroke): - n = stroke.strokeVerticesSize() - i = 0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - c = float(i)/float(n) - if(i < float(n)/2.0): - t = (1.0 - c)*self._thicknessMin + c * self._thicknessMax - else: - t = (1.0 - c)*self._thicknessMax + c * self._thicknessMin - att.setThickness(t/2.0, t/2.0) - i = i+1 - it.increment() - -class pyConstrainedIncreasingThicknessShader(StrokeShader): - def __init__(self, thicknessMin, thicknessMax, ratio): - StrokeShader.__init__(self) - self._thicknessMin = thicknessMin - self._thicknessMax = thicknessMax - self._ratio = ratio - - def getName(self): - return "pyConstrainedIncreasingThicknessShader" - def shade(self, stroke): - slength = stroke.getLength2D() - tmp = self._ratio*slength - maxT = 0.0 - if(tmp < self._thicknessMax): - maxT = tmp - else: - maxT = self._thicknessMax - n = stroke.strokeVerticesSize() - i = 0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - c = float(i)/float(n) - if(i < float(n)/2.0): - t = (1.0 - c)*self._thicknessMin + c * maxT - else: - t = (1.0 - c)*maxT + c * self._thicknessMin - att.setThickness(t/2.0, t/2.0) - if(i == n-1): - att.setThickness(self._thicknessMin/2.0, self._thicknessMin/2.0) - i = i+1 - it.increment() - -class pyDecreasingThicknessShader(StrokeShader): - def __init__(self, thicknessMax, thicknessMin): - StrokeShader.__init__(self) - self._thicknessMin = thicknessMin - self._thicknessMax = thicknessMax - - def getName(self): - return "pyDecreasingThicknessShader" - def shade(self, stroke): - l = stroke.getLength2D() - tMax = self._thicknessMax - if(self._thicknessMax > 0.33*l): - tMax = 0.33*l - tMin = self._thicknessMin - if(self._thicknessMin > 0.1*l): - tMin = 0.1*l - n = stroke.strokeVerticesSize() - i = 0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - c = float(i)/float(n) - t = (1.0 - c)*tMax +c*tMin - att.setThickness(t/2.0, t/2.0) - i = i+1 - it.increment() - -def smoothC( a, exp ): - c = pow(float(a),exp)*pow(2.0,exp) - return c - -class pyNonLinearVaryingThicknessShader(StrokeShader): - def __init__(self, thicknessExtremity, thicknessMiddle, exponent): - StrokeShader.__init__(self) - self._thicknessMin = thicknessMiddle - self._thicknessMax = thicknessExtremity - self._exponent = exponent - - def getName(self): - return "pyNonLinearVaryingThicknessShader" - def shade(self, stroke): - n = stroke.strokeVerticesSize() - i = 0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - if(i < float(n)/2.0): - c = float(i)/float(n) - else: - c = float(n-i)/float(n) - c = smoothC(c, self._exponent) - t = (1.0 - c)*self._thicknessMax + c * self._thicknessMin - att.setThickness(t/2.0, t/2.0) - i = i+1 - it.increment() - -## Spherical linear interpolation (cos) -class pySLERPThicknessShader(StrokeShader): - def __init__(self, thicknessMin, thicknessMax, omega=1.2): - StrokeShader.__init__(self) - self._thicknessMin = thicknessMin - self._thicknessMax = thicknessMax - self._omega = omega - - def getName(self): - return "pySLERPThicknessShader" - def shade(self, stroke): - slength = stroke.getLength2D() - tmp = 0.33*slength - maxT = self._thicknessMax - if(tmp < self._thicknessMax): - maxT = tmp - - n = stroke.strokeVerticesSize() - i = 0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - c = float(i)/float(n) - if(i < float(n)/2.0): - t = sin((1-c)*self._omega)/sinh(self._omega)*self._thicknessMin + sin(c*self._omega)/sinh(self._omega) * maxT - else: - t = sin((1-c)*self._omega)/sinh(self._omega)*maxT + sin(c*self._omega)/sinh(self._omega) * self._thicknessMin - att.setThickness(t/2.0, t/2.0) - i = i+1 - it.increment() - -class pyTVertexThickenerShader(StrokeShader): ## FIXME - def __init__(self, a=1.5, n=3): - StrokeShader.__init__(self) - self._a = a - self._n = n - - def getName(self): - return "pyTVertexThickenerShader" - - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - predTVertex = pyVertexNatureUP0D(T_VERTEX) - while it.isEnd() == 0: - if(predTVertex(it) == 1): - it2 = StrokeVertexIterator(it) - it2.increment() - if not(it.isBegin() or it2.isEnd()): - it.increment() - continue - n = self._n - a = self._a - if(it.isBegin()): - it3 = StrokeVertexIterator(it) - count = 0 - while (it3.isEnd() == 0 and count < n): - att = it3.getObject().attribute() - tr = att.getThicknessR(); - tl = att.getThicknessL(); - r = (a-1.0)/float(n-1)*(float(n)/float(count+1) - 1) + 1 - #r = (1.0-a)/float(n-1)*count + a - att.setThickness(r*tr, r*tl) - it3.increment() - count = count + 1 - if(it2.isEnd()): - it4 = StrokeVertexIterator(it) - count = 0 - while (it4.isBegin() == 0 and count < n): - att = it4.getObject().attribute() - tr = att.getThicknessR(); - tl = att.getThicknessL(); - r = (a-1.0)/float(n-1)*(float(n)/float(count+1) - 1) + 1 - #r = (1.0-a)/float(n-1)*count + a - att.setThickness(r*tr, r*tl) - it4.decrement() - count = count + 1 - if ((it4.isBegin() == 1)): - att = it4.getObject().attribute() - tr = att.getThicknessR(); - tl = att.getThicknessL(); - r = (a-1.0)/float(n-1)*(float(n)/float(count+1) - 1) + 1 - #r = (1.0-a)/float(n-1)*count + a - att.setThickness(r*tr, r*tl) - it.increment() - -class pyImportance2DThicknessShader(StrokeShader): - def __init__(self, x, y, w, kmin, kmax): - StrokeShader.__init__(self) - self._x = x - self._y = y - self._w = float(w) - self._kmin = float(kmin) - self._kmax = float(kmax) - - def getName(self): - return "pyImportanceThicknessShader" - def shade(self, stroke): - origin = Vec2(self._x, self._y) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - v = it.getObject() - p = Vec2(v.getProjectedX(), v.getProjectedY()) - d = (p-origin).length() - if(d>self._w): - k = self._kmin - else: - k = (self._kmax*(self._w-d) + self._kmin*d)/self._w - att = v.attribute() - tr = att.getThicknessR() - tl = att.getThicknessL() - att.setThickness(k*tr/2.0, k*tl/2.0) - it.increment() - -class pyImportance3DThicknessShader(StrokeShader): - def __init__(self, x, y, z, w, kmin, kmax): - StrokeShader.__init__(self) - self._x = x - self._y = y - self._z = z - self._w = float(w) - self._kmin = float(kmin) - self._kmax = float(kmax) - - def getName(self): - return "pyImportance3DThicknessShader" - def shade(self, stroke): - origin = Vec3(self._x, self._y, self._z) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - v = it.getObject() - p = Vec3(v.getX(), v.getY(), v.getZ()) - d = (p-origin).length() - if(d>self._w): - k = self._kmin - else: - k = (self._kmax*(self._w-d) + self._kmin*d)/self._w - att = v.attribute() - tr = att.getThicknessR() - tl = att.getThicknessL() - att.setThickness(k*tr/2.0, k*tl/2.0) - it.increment() - -class pyZDependingThicknessShader(StrokeShader): - def __init__(self, min, max): - StrokeShader.__init__(self) - self.__min = min - self.__max = max - self.__func = GetProjectedZF0D() - def getName(self): - return "pyZDependingThicknessShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - z_min = 1 - z_max = 0 - while it.isEnd() == 0: - z = self.__func(it.castToInterface0DIterator()) - if z < z_min: - z_min = z - elif z > z_max: - z_max = z - it.increment() - z_diff = 1 / (z_max - z_min) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - z = (self.__func(it.castToInterface0DIterator()) - z_min) * z_diff - thickness = (1 - z) * self.__max + z * self.__min - it.getObject().attribute().setThickness(thickness, thickness) - it.increment() - - -## color modifiers -################## - -class pyConstantColorShader(StrokeShader): - def __init__(self,r,g,b, a = 1): - StrokeShader.__init__(self) - self._r = r - self._g = g - self._b = b - self._a = a - def getName(self): - return "pyConstantColorShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - att.setColor(self._r, self._g, self._b) - att.setAlpha(self._a) - it.increment() - -#c1->c2 -class pyIncreasingColorShader(StrokeShader): - def __init__(self,r1,g1,b1,a1, r2,g2,b2,a2): - StrokeShader.__init__(self) - self._c1 = [r1,g1,b1,a1] - self._c2 = [r2,g2,b2,a2] - def getName(self): - return "pyIncreasingColorShader" - def shade(self, stroke): - n = stroke.strokeVerticesSize() - 1 - inc = 0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - c = float(inc)/float(n) - - att.setColor( (1-c)*self._c1[0] + c*self._c2[0], - (1-c)*self._c1[1] + c*self._c2[1], - (1-c)*self._c1[2] + c*self._c2[2],) - att.setAlpha((1-c)*self._c1[3] + c*self._c2[3],) - inc = inc+1 - it.increment() - -# c1->c2->c1 -class pyInterpolateColorShader(StrokeShader): - def __init__(self,r1,g1,b1,a1, r2,g2,b2,a2): - StrokeShader.__init__(self) - self._c1 = [r1,g1,b1,a1] - self._c2 = [r2,g2,b2,a2] - def getName(self): - return "pyInterpolateColorShader" - def shade(self, stroke): - n = stroke.strokeVerticesSize() - 1 - inc = 0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - u = float(inc)/float(n) - c = 1-2*(fabs(u-0.5)) - att.setColor( (1-c)*self._c1[0] + c*self._c2[0], - (1-c)*self._c1[1] + c*self._c2[1], - (1-c)*self._c1[2] + c*self._c2[2],) - att.setAlpha((1-c)*self._c1[3] + c*self._c2[3],) - inc = inc+1 - it.increment() - -class pyMaterialColorShader(StrokeShader): - def __init__(self, threshold=50): - StrokeShader.__init__(self) - self._threshold = threshold - - def getName(self): - return "pyMaterialColorShader" - - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - func = MaterialF0D() - xn = 0.312713 - yn = 0.329016 - Yn = 1.0 - un = 4.* xn/ ( -2.*xn + 12.*yn + 3. ) - vn= 9.* yn/ ( -2.*xn + 12.*yn +3. ) - while it.isEnd() == 0: - toto = it.castToInterface0DIterator() - mat = func(toto) - - r = mat.diffuseR() - g = mat.diffuseG() - b = mat.diffuseB() - - X = 0.412453*r + 0.35758 *g + 0.180423*b - Y = 0.212671*r + 0.71516 *g + 0.072169*b - Z = 0.019334*r + 0.119193*g + 0.950227*b - - if((X == 0) and (Y == 0) and (Z == 0)): - X = 0.01 - Y = 0.01 - Z = 0.01 - u = 4.*X / (X + 15.*Y + 3.*Z) - v = 9.*Y / (X + 15.*Y + 3.*Z) - - L= 116. * math.pow((Y/Yn),(1./3.)) -16 - U = 13. * L * (u - un) - V = 13. * L * (v - vn) - - if (L > self._threshold): - L = L/1.3 - U = U+10 - else: - L = L +2.5*(100-L)/5. - U = U/3.0 - V = V/3.0 - u = U / (13. * L) + un - v = V / (13. * L) + vn - - Y = Yn * math.pow( ((L+16.)/116.), 3.) - X = -9. * Y * u / ((u - 4.)* v - u * v) - Z = (9. * Y - 15*v*Y - v*X) /( 3. * v) - - r = 3.240479 * X - 1.53715 * Y - 0.498535 * Z - g = -0.969256 * X + 1.875991 * Y + 0.041556 * Z - b = 0.055648 * X - 0.204043 * Y + 1.057311 * Z - - att = it.getObject().attribute() - att.setColor(r, g, b) - it.increment() - -class pyRandomColorShader(StrokeShader): - def getName(self): - return "pyRandomColorShader" - def __init__(self, s=1): - StrokeShader.__init__(self) - seed(s) - def shade(self, stroke): - ## pick a random color - c0 = float(uniform(15,75))/100.0 - c1 = float(uniform(15,75))/100.0 - c2 = float(uniform(15,75))/100.0 - print c0, c1, c2 - it = stroke.strokeVerticesBegin() - while(it.isEnd() == 0): - it.getObject().attribute().setColor(c0,c1,c2) - it.increment() - -class py2DCurvatureColorShader(StrokeShader): - def getName(self): - return "py2DCurvatureColorShader" - - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - func = Curvature2DAngleF0D() - while it.isEnd() == 0: - toto = it.castToInterface0DIterator() - sv = it.getObject() - att = sv.attribute() - c = func(toto) - if (c<0): - print "negative 2D curvature" - color = 10.0 * c/3.1415 - print color - att.setColor(color,color,color); - it.increment() - -class pyTimeColorShader(StrokeShader): - def __init__(self, step=0.01): - StrokeShader.__init__(self) - self._t = 0 - self._step = step - def shade(self, stroke): - c = self._t*1.0 - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - att = it.getObject().attribute() - att.setColor(c,c,c) - it.increment() - self._t = self._t+self._step - -## geometry modifiers - -class pySamplingShader(StrokeShader): - def __init__(self, sampling): - StrokeShader.__init__(self) - self._sampling = sampling - def getName(self): - return "pySamplingShader" - def shade(self, stroke): - stroke.Resample(float(self._sampling)) - -class pyBackboneStretcherShader(StrokeShader): - def __init__(self, l): - StrokeShader.__init__(self) - self._l = l - def getName(self): - return "pyBackboneStretcherShader" - def shade(self, stroke): - it0 = stroke.strokeVerticesBegin() - it1 = StrokeVertexIterator(it0) - it1.increment() - itn = stroke.strokeVerticesEnd() - itn.decrement() - itn_1 = StrokeVertexIterator(itn) - itn_1.decrement() - v0 = it0.getObject() - v1 = it1.getObject() - vn_1 = itn_1.getObject() - vn = itn.getObject() - p0 = Vec2f(v0.getProjectedX(), v0.getProjectedY()) - pn = Vec2f(vn.getProjectedX(), vn.getProjectedY()) - p1 = Vec2f(v1.getProjectedX(), v1.getProjectedY()) - pn_1 = Vec2f(vn_1.getProjectedX(), vn_1.getProjectedY()) - d1 = p0-p1 - d1 = d1/d1.norm() - dn = pn-pn_1 - dn = dn/dn.norm() - newFirst = p0+d1*float(self._l) - newLast = pn+dn*float(self._l) - v0.setPoint(newFirst) - vn.setPoint(newLast) - -class pyLengthDependingBackboneStretcherShader(StrokeShader): - def __init__(self, l): - StrokeShader.__init__(self) - self._l = l - def getName(self): - return "pyBackboneStretcherShader" - def shade(self, stroke): - l = stroke.getLength2D() - stretch = self._l*l - it0 = stroke.strokeVerticesBegin() - it1 = StrokeVertexIterator(it0) - it1.increment() - itn = stroke.strokeVerticesEnd() - itn.decrement() - itn_1 = StrokeVertexIterator(itn) - itn_1.decrement() - v0 = it0.getObject() - v1 = it1.getObject() - vn_1 = itn_1.getObject() - vn = itn.getObject() - p0 = Vec2f(v0.getProjectedX(), v0.getProjectedY()) - pn = Vec2f(vn.getProjectedX(), vn.getProjectedY()) - p1 = Vec2f(v1.getProjectedX(), v1.getProjectedY()) - pn_1 = Vec2f(vn_1.getProjectedX(), vn_1.getProjectedY()) - d1 = p0-p1 - d1 = d1/d1.norm() - dn = pn-pn_1 - dn = dn/dn.norm() - newFirst = p0+d1*float(stretch) - newLast = pn+dn*float(stretch) - v0.setPoint(newFirst) - vn.setPoint(newLast) - - -## Shader to replace a stroke by its corresponding tangent -class pyGuidingLineShader(StrokeShader): - def getName(self): - return "pyGuidingLineShader" - ## shading method - def shade(self, stroke): - it = stroke.strokeVerticesBegin() ## get the first vertex - itlast = stroke.strokeVerticesEnd() ## - itlast.decrement() ## get the last one - t = itlast.getObject().getPoint() - it.getObject().getPoint() ## tangent direction - itmiddle = StrokeVertexIterator(it) ## - while(itmiddle.getObject().u()<0.5): ## look for the stroke middle vertex - itmiddle.increment() ## - it = StrokeVertexIterator(itmiddle) - it.increment() - while(it.isEnd() == 0): ## position all the vertices along the tangent for the right part - it.getObject().setPoint(itmiddle.getObject().getPoint() \ - +t*(it.getObject().u()-itmiddle.getObject().u())) - it.increment() - it = StrokeVertexIterator(itmiddle) - it.decrement() - while(it.isBegin() == 0): ## position all the vertices along the tangent for the left part - it.getObject().setPoint(itmiddle.getObject().getPoint() \ - -t*(itmiddle.getObject().u()-it.getObject().u())) - it.decrement() - it.getObject().setPoint(itmiddle.getObject().getPoint()-t*(itmiddle.getObject().u())) ## first vertex - - -class pyBackboneStretcherNoCuspShader(StrokeShader): - def __init__(self, l): - StrokeShader.__init__(self) - self._l = l - def getName(self): - return "pyBackboneStretcherNoCuspShader" - def shade(self, stroke): - it0 = stroke.strokeVerticesBegin() - it1 = StrokeVertexIterator(it0) - it1.increment() - itn = stroke.strokeVerticesEnd() - itn.decrement() - itn_1 = StrokeVertexIterator(itn) - itn_1.decrement() - v0 = it0.getObject() - v1 = it1.getObject() - if((v0.getNature() & CUSP == 0) and (v1.getNature() & CUSP == 0)): - p0 = v0.getPoint() - p1 = v1.getPoint() - d1 = p0-p1 - d1 = d1/d1.norm() - newFirst = p0+d1*float(self._l) - v0.setPoint(newFirst) - vn_1 = itn_1.getObject() - vn = itn.getObject() - if((vn.getNature() & CUSP == 0) and (vn_1.getNature() & CUSP == 0)): - pn = vn.getPoint() - pn_1 = vn_1.getPoint() - dn = pn-pn_1 - dn = dn/dn.norm() - newLast = pn+dn*float(self._l) - vn.setPoint(newLast) - -normalInfo=Normal2DF0D() -curvatureInfo=Curvature2DAngleF0D() - -def edgestopping(x, sigma): - return exp(- x*x/(2*sigma*sigma)) - -class pyDiffusion2Shader(StrokeShader): - def __init__(self, lambda1, nbIter): - StrokeShader.__init__(self) - self._lambda = lambda1 - self._nbIter = nbIter - self._normalInfo = Normal2DF0D() - self._curvatureInfo = Curvature2DAngleF0D() - def getName(self): - return "pyDiffusionShader" - def shade(self, stroke): - for i in range (1, self._nbIter): - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - v=it.getObject() - p1 = v.getPoint() - p2 = self._normalInfo(it.castToInterface0DIterator())*self._lambda*self._curvatureInfo(it.castToInterface0DIterator()) - v.setPoint(p1+p2) - it.increment() - -class pyTipRemoverShader(StrokeShader): - def __init__(self, l): - StrokeShader.__init__(self) - self._l = l - def getName(self): - return "pyTipRemoverShader" - def shade(self, stroke): - originalSize = stroke.strokeVerticesSize() - if(originalSize<4): - return - verticesToRemove = [] - oldAttributes = [] - it = stroke.strokeVerticesBegin() - while(it.isEnd() == 0): - v = it.getObject() - if((v.curvilinearAbscissa() < self._l) or (v.strokeLength()-v.curvilinearAbscissa() < self._l)): - verticesToRemove.append(v) - oldAttributes.append(StrokeAttribute(v.attribute())) - it.increment() - if(originalSize-len(verticesToRemove) < 2): - return - for sv in verticesToRemove: - stroke.RemoveVertex(sv) - stroke.Resample(originalSize) - if(stroke.strokeVerticesSize() != originalSize): - print "pyTipRemover: Warning: resampling problem" - it = stroke.strokeVerticesBegin() - for a in oldAttributes: - if(it.isEnd() == 1): - break - v = it.getObject() - v.setAttribute(a) - it.increment() - -class pyTVertexRemoverShader(StrokeShader): - def getName(self): - return "pyTVertexRemoverShader" - def shade(self, stroke): - if(stroke.strokeVerticesSize() <= 3 ): - return - predTVertex = pyVertexNatureUP0D(T_VERTEX) - it = stroke.strokeVerticesBegin() - itlast = stroke.strokeVerticesEnd() - itlast.decrement() - if(predTVertex(it) == 1): - stroke.RemoveVertex(it.getObject()) - if(predTVertex(itlast) == 1): - stroke.RemoveVertex(itlast.getObject()) - -class pyExtremitiesOrientationShader(StrokeShader): - def __init__(self, x1,y1,x2=0,y2=0): - StrokeShader.__init__(self) - self._v1 = Vec2(x1,y1) - self._v2 = Vec2(x2,y2) - def getName(self): - return "pyExtremitiesOrientationShader" - def shade(self, stroke): - print self._v1.x(),self._v1.y() - stroke.setBeginningOrientation(self._v1.x(),self._v1.y()) - stroke.setEndingOrientation(self._v2.x(),self._v2.y()) - -class pyHLRShader(StrokeShader): - def getName(self): - return "pyHLRShader" - def shade(self, stroke): - originalSize = stroke.strokeVerticesSize() - if(originalSize<4): - return - it = stroke.strokeVerticesBegin() - invisible = 0 - it2 = StrokeVertexIterator(it) - it2.increment() - fe = getFEdge(it.getObject(), it2.getObject()) - if(fe.qi() != 0): - invisible = 1 - while(it2.isEnd() == 0): - v = it.getObject() - vnext = it2.getObject() - if(v.getNature() & VIEW_VERTEX): - #if(v.getNature() & T_VERTEX): - fe = getFEdge(v,vnext) - qi = fe.qi() - if(qi != 0): - invisible = 1 - else: - invisible = 0 - if(invisible == 1): - v.attribute().setVisible(0) - it.increment() - it2.increment() - -class pyTVertexOrientationShader(StrokeShader): - def __init__(self): - StrokeShader.__init__(self) - self._Get2dDirection = Orientation2DF1D() - def getName(self): - return "pyTVertexOrientationShader" - ## finds the TVertex orientation from the TVertex and - ## the previous or next edge - def findOrientation(self, tv, ve): - mateVE = tv.mate(ve) - if((ve.qi() != 0) or (mateVE.qi() != 0)): - ait = AdjacencyIterator(tv,1,0) - winner = None - incoming = 1 - while(ait.isEnd() == 0): - ave = ait.getObject() - if((ave.getId() != ve.getId()) and (ave.getId() != mateVE.getId())): - winner = ait.getObject() - if(ait.isIncoming() == 0): - incoming = 0 - break - ait.increment() - if(winner != None): - if(incoming != 0): - direction = self._Get2dDirection(winner.fedgeB()) - else: - direction = self._Get2dDirection(winner.fedgeA()) - return direction - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - it2 = StrokeVertexIterator(it) - it2.increment() - ## case where the first vertex is a TVertex - v = it.getObject() - if(v.getNature() & T_VERTEX): - tv = v.castToTVertex() - ve = getFEdge(v, it2.getObject()).viewedge() - if(tv != None): - dir = self.findOrientation(tv, ve) - #print dir.x(), dir.y() - v.attribute().setAttributeVec2f("orientation", dir) - while(it2.isEnd() == 0): - vprevious = it.getObject() - v = it2.getObject() - if(v.getNature() & T_VERTEX): - tv = v.castToTVertex() - ve = getFEdge(vprevious, v).viewedge() - if(tv != None): - dir = self.findOrientation(tv, ve) - #print dir.x(), dir.y() - v.attribute().setAttributeVec2f("orientation", dir) - it.increment() - it2.increment() - ## case where the last vertex is a TVertex - v = it.getObject() - if(v.getNature() & T_VERTEX): - itPrevious = StrokeVertexIterator(it) - itPrevious.decrement() - tv = v.castToTVertex() - ve = getFEdge(itPrevious.getObject(), v).viewedge() - if(tv != None): - dir = self.findOrientation(tv, ve) - #print dir.x(), dir.y() - v.attribute().setAttributeVec2f("orientation", dir) - -class pySinusDisplacementShader(StrokeShader): - def __init__(self, f, a): - StrokeShader.__init__(self) - self._f = f - self._a = a - self._getNormal = Normal2DF0D() - - def getName(self): - return "pySinusDisplacementShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - v = it.getObject() - #print self._getNormal.getName() - n = self._getNormal(it.castToInterface0DIterator()) - p = v.getPoint() - u = v.u() - a = self._a*(1-2*(fabs(u-0.5))) - n = n*a*cos(self._f*u*6.28) - #print n.x(), n.y() - v.setPoint(p+n) - #v.setPoint(v.getPoint()+n*a*cos(f*v.u())) - it.increment() - -class pyPerlinNoise1DShader(StrokeShader): - def __init__(self, freq = 10, amp = 10, oct = 4): - StrokeShader.__init__(self) - self.__noise = Noise() - self.__freq = freq - self.__amp = amp - self.__oct = oct - def getName(self): - return "pyPerlinNoise1DShader" - def shade(self, stroke): - i = randint(0, 50) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - v = it.getObject() - nres = self.__noise.turbulence1(i, self.__freq, self.__amp, self.__oct) - v.setPoint(v.getProjectedX() + nres, v.getProjectedY() + nres) - i = i+1 - it.increment() - -class pyPerlinNoise2DShader(StrokeShader): - def __init__(self, freq = 10, amp = 10, oct = 4): - StrokeShader.__init__(self) - self.__noise = Noise() - self.__freq = freq - self.__amp = amp - self.__oct = oct - def getName(self): - return "pyPerlinNoise2DShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - v = it.getObject() - vec = Vec2f(v.getProjectedX(), v.getProjectedY()) - nres = self.__noise.turbulence2(vec, self.__freq, self.__amp, self.__oct) - v.setPoint(v.getProjectedX() + nres, v.getProjectedY() + nres) - it.increment() - -class pyBluePrintCirclesShader(StrokeShader): - def __init__(self, turns = 1): - StrokeShader.__init__(self) - self.__turns = turns - def getName(self): - return "pyBluePrintCirclesShader" - def shade(self, stroke): - p_min = Vec2f(10000, 10000) - p_max = Vec2f(0, 0) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - p = it.getObject().getPoint() - if (p.x() < p_min.x()): - p_min.setX(p.x()) - if (p.x() > p_max.x()): - p_max.setX(p.x()) - if (p.y() < p_min.y()): - p_min.setY(p.y()) - if (p.y() > p_max.y()): - p_max.setY(p.y()) - it.increment() - stroke.Resample(32 * self.__turns) - sv_nb = stroke.strokeVerticesSize() -# print "min :", p_min.x(), p_min.y() # DEBUG -# print "mean :", p_sum.x(), p_sum.y() # DEBUG -# print "max :", p_max.x(), p_max.y() # DEBUG -# print "----------------------" # DEBUG -####################################################### - sv_nb = sv_nb / self.__turns - center = (p_min + p_max) / 2 - radius = (center.x() - p_min.x() + center.y() - p_min.y()) / 2 - p_new = Vec2f() -####################################################### - it = stroke.strokeVerticesBegin() - for j in range(self.__turns): - radius = radius + randint(-3, 3) - center_x = center.x() + randint(-5, 5) - center_y = center.y() + randint(-5, 5) - center.setX(center_x) - center.setY(center_y) - i = 0 - while i < sv_nb: - p_new.setX(center.x() + radius * cos(2 * pi * float(i) / float(sv_nb - 1))) - p_new.setY(center.y() + radius * sin(2 * pi * float(i) / float(sv_nb - 1))) - it.getObject().setPoint(p_new.x(), p_new.y()) - i = i + 1 - it.increment() - while it.isEnd() == 0: - stroke.RemoveVertex(it.getObject()) - it.increment() - - -class pyBluePrintEllipsesShader(StrokeShader): - def __init__(self, turns = 1): - StrokeShader.__init__(self) - self.__turns = turns - def getName(self): - return "pyBluePrintEllipsesShader" - def shade(self, stroke): - p_min = Vec2f(10000, 10000) - p_max = Vec2f(0, 0) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - p = it.getObject().getPoint() - if (p.x() < p_min.x()): - p_min.setX(p.x()) - if (p.x() > p_max.x()): - p_max.setX(p.x()) - if (p.y() < p_min.y()): - p_min.setY(p.y()) - if (p.y() > p_max.y()): - p_max.setY(p.y()) - it.increment() - stroke.Resample(32 * self.__turns) - sv_nb = stroke.strokeVerticesSize() -# print "min :", p_min.x(), p_min.y() # DEBUG -# print "mean :", p_sum.x(), p_sum.y() # DEBUG -# print "max :", p_max.x(), p_max.y() # DEBUG -# print "----------------------" # DEBUG -####################################################### - sv_nb = sv_nb / self.__turns - center = (p_min + p_max) / 2 - radius_x = center.x() - p_min.x() - radius_y = center.y() - p_min.y() - p_new = Vec2f() -####################################################### - it = stroke.strokeVerticesBegin() - for j in range(self.__turns): - radius_x = radius_x + randint(-3, 3) - radius_y = radius_y + randint(-3, 3) - center_x = center.x() + randint(-5, 5) - center_y = center.y() + randint(-5, 5) - center.setX(center_x) - center.setY(center_y) - i = 0 - while i < sv_nb: - p_new.setX(center.x() + radius_x * cos(2 * pi * float(i) / float(sv_nb - 1))) - p_new.setY(center.y() + radius_y * sin(2 * pi * float(i) / float(sv_nb - 1))) - it.getObject().setPoint(p_new.x(), p_new.y()) - i = i + 1 - it.increment() - while it.isEnd() == 0: - stroke.RemoveVertex(it.getObject()) - it.increment() - - -class pyBluePrintSquaresShader(StrokeShader): - def __init__(self, turns = 1, bb_len = 10): - StrokeShader.__init__(self) - self.__turns = turns - self.__bb_len = bb_len - def getName(self): - return "pyBluePrintSquaresShader" - def shade(self, stroke): - p_min = Vec2f(10000, 10000) - p_max = Vec2f(0, 0) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - p = it.getObject().getPoint() - if (p.x() < p_min.x()): - p_min.setX(p.x()) - if (p.x() > p_max.x()): - p_max.setX(p.x()) - if (p.y() < p_min.y()): - p_min.setY(p.y()) - if (p.y() > p_max.y()): - p_max.setY(p.y()) - it.increment() - stroke.Resample(32 * self.__turns) - sv_nb = stroke.strokeVerticesSize() -####################################################### - sv_nb = sv_nb / self.__turns - first = sv_nb / 4 - second = 2 * first - third = 3 * first - fourth = sv_nb - vec_first = Vec2f(p_max.x() - p_min.x() + 2 * self.__bb_len, 0) - vec_second = Vec2f(0, p_max.y() - p_min.y() + 2 * self.__bb_len) - vec_third = vec_first * -1 - vec_fourth = vec_second * -1 - p_first = Vec2f(p_min.x() - self.__bb_len, p_min.y()) - p_second = Vec2f(p_max.x(), p_min.y() - self.__bb_len) - p_third = Vec2f(p_max.x() + self.__bb_len, p_max.y()) - p_fourth = Vec2f(p_min.x(), p_max.y() + self.__bb_len) -####################################################### - it = stroke.strokeVerticesBegin() - visible = 1 - for j in range(self.__turns): - i = 0 - while i < sv_nb: - if i < first: - p_new = p_first + vec_first * float(i)/float(first - 1) - if i == first - 1: - visible = 0 - elif i < second: - p_new = p_second + vec_second * float(i - first)/float(second - first - 1) - if i == second - 1: - visible = 0 - elif i < third: - p_new = p_third + vec_third * float(i - second)/float(third - second - 1) - if i == third - 1: - visible = 0 - else: - p_new = p_fourth + vec_fourth * float(i - third)/float(fourth - third - 1) - if i == fourth - 1: - visible = 0 - it.getObject().setPoint(p_new.x(), p_new.y()) - it.getObject().attribute().setVisible(visible) - if visible == 0: - visible = 1 - i = i + 1 - it.increment() - while it.isEnd() == 0: - stroke.RemoveVertex(it.getObject()) - it.increment() - - -class pyBluePrintDirectedSquaresShader(StrokeShader): - def __init__(self, turns = 1, bb_len = 10, mult = 1): - StrokeShader.__init__(self) - self.__mult = mult - self.__turns = turns - self.__bb_len = 1 + float(bb_len) / 100 - def getName(self): - return "pyBluePrintDirectedSquaresShader" - def shade(self, stroke): - stroke.Resample(32 * self.__turns) - p_mean = Vec2f(0, 0) - p_min = Vec2f(10000, 10000) - p_max = Vec2f(0, 0) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - p = it.getObject().getPoint() - p_mean = p_mean + p -## if (p.x() < p_min.x()): -## p_min.setX(p.x()) -## if (p.x() > p_max.x()): -## p_max.setX(p.x()) -## if (p.y() < p_min.y()): -## p_min.setY(p.y()) -## if (p.y() > p_max.y()): -## p_max.setY(p.y()) - it.increment() - sv_nb = stroke.strokeVerticesSize() - p_mean = p_mean / sv_nb - p_var_xx = 0 - p_var_yy = 0 - p_var_xy = 0 - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - p = it.getObject().getPoint() - p_var_xx = p_var_xx + pow(p.x() - p_mean.x(), 2) - p_var_yy = p_var_yy + pow(p.y() - p_mean.y(), 2) - p_var_xy = p_var_xy + (p.x() - p_mean.x()) * (p.y() - p_mean.y()) - it.increment() - p_var_xx = p_var_xx / sv_nb - p_var_yy = p_var_yy / sv_nb - p_var_xy = p_var_xy / sv_nb -## print p_var_xx, p_var_yy, p_var_xy - trace = p_var_xx + p_var_yy - det = p_var_xx * p_var_yy - p_var_xy * p_var_xy - sqrt_coeff = sqrt(trace * trace - 4 * det) - lambda1 = (trace + sqrt_coeff) / 2 - lambda2 = (trace - sqrt_coeff) / 2 -## print lambda1, lambda2 - theta = atan(2 * p_var_xy / (p_var_xx - p_var_yy)) / 2 -## print theta - if p_var_yy > p_var_xx: - e1 = Vec2f(cos(theta + pi / 2), sin(theta + pi / 2)) * sqrt(lambda1) * self.__mult - e2 = Vec2f(cos(theta + pi), sin(theta + pi)) * sqrt(lambda2) * self.__mult - else: - e1 = Vec2f(cos(theta), sin(theta)) * sqrt(lambda1) * self.__mult - e2 = Vec2f(cos(theta + pi / 2), sin(theta + pi / 2)) * sqrt(lambda2) * self.__mult -####################################################### - sv_nb = sv_nb / self.__turns - first = sv_nb / 4 - second = 2 * first - third = 3 * first - fourth = sv_nb - bb_len1 = self.__bb_len - bb_len2 = 1 + (bb_len1 - 1) * sqrt(lambda1 / lambda2) - p_first = p_mean - e1 - e2 * bb_len2 - p_second = p_mean - e1 * bb_len1 + e2 - p_third = p_mean + e1 + e2 * bb_len2 - p_fourth = p_mean + e1 * bb_len1 - e2 - vec_first = e2 * bb_len2 * 2 - vec_second = e1 * bb_len1 * 2 - vec_third = vec_first * -1 - vec_fourth = vec_second * -1 -####################################################### - it = stroke.strokeVerticesBegin() - visible = 1 - for j in range(self.__turns): - i = 0 - while i < sv_nb: - if i < first: - p_new = p_first + vec_first * float(i)/float(first - 1) - if i == first - 1: - visible = 0 - elif i < second: - p_new = p_second + vec_second * float(i - first)/float(second - first - 1) - if i == second - 1: - visible = 0 - elif i < third: - p_new = p_third + vec_third * float(i - second)/float(third - second - 1) - if i == third - 1: - visible = 0 - else: - p_new = p_fourth + vec_fourth * float(i - third)/float(fourth - third - 1) - if i == fourth - 1: - visible = 0 - it.getObject().setPoint(p_new.x(), p_new.y()) - it.getObject().attribute().setVisible(visible) - if visible == 0: - visible = 1 - i = i + 1 - it.increment() - while it.isEnd() == 0: - stroke.RemoveVertex(it.getObject()) - it.increment() - -class pyModulateAlphaShader(StrokeShader): - def __init__(self, min = 0, max = 1): - StrokeShader.__init__(self) - self.__min = min - self.__max = max - def getName(self): - return "pyModulateAlphaShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - alpha = it.getObject().attribute().getAlpha() - p = it.getObject().getPoint() - alpha = alpha * p.y() / 400 - if alpha < self.__min: - alpha = self.__min - elif alpha > self.__max: - alpha = self.__max - it.getObject().attribute().setAlpha(alpha) - it.increment() - - -## various -class pyDummyShader(StrokeShader): - def getName(self): - return "pyDummyShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - it_end = stroke.strokeVerticesEnd() - while it.isEnd() == 0: - toto = it.castToInterface0DIterator() - att = it.getObject().attribute() - att.setColor(0.3, 0.4, 0.4) - att.setThickness(0, 5) - it.increment() - -class pyDebugShader(StrokeShader): - def getName(self): - return "pyDebugShader" - - def shade(self, stroke): - fe = GetSelectedFEdgeCF() - id1=fe.vertexA().getId() - id2=fe.vertexB().getId() - #print id1.getFirst(), id1.getSecond() - #print id2.getFirst(), id2.getSecond() - it = stroke.strokeVerticesBegin() - found = 0 - foundfirst = 0 - foundsecond = 0 - while it.isEnd() == 0: - cp = it.getObject() - if((cp.A().getId() == id1) or (cp.B().getId() == id1)): - foundfirst = 1 - if((cp.A().getId() == id2) or (cp.B().getId() == id2)): - foundsecond = 1 - if((foundfirst != 0) and (foundsecond != 0)): - found = 1 - break - it.increment() - if(found != 0): - print "The selected Stroke id is: ", stroke.getId().getFirst(), stroke.getId().getSecond() - diff --git a/source/blender/freestyle/style_modules_old/sketchy_multiple_parameterization.py b/source/blender/freestyle/style_modules_old/sketchy_multiple_parameterization.py deleted file mode 100755 index 69e6f11751d..00000000000 --- a/source/blender/freestyle/style_modules_old/sketchy_multiple_parameterization.py +++ /dev/null @@ -1,48 +0,0 @@ -# -# Filename : sketchy_multiple_parameterization.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Builds sketchy strokes whose topology relies on a -# parameterization that covers the complete lines (visible+invisible) -# whereas only the visible portions are actually drawn -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from ChainingIterators import * -from shaders import * - - -Operators.select(QuantitativeInvisibilityUP1D(0)) -## 0: don't restrict to selection -Operators.bidirectionalChain(pySketchyChainSilhouetteIterator(3,0)) -shaders_list = [ - SamplingShader(2), - SpatialNoiseShader(15, 120, 2, 1, 1), - IncreasingThicknessShader(5, 30), - SmoothingShader(100, 0.05, 0, 0.2, 0, 0, 0, 1), - IncreasingColorShader(0,0.2,0,1,0.2,0.7,0.2,1), - TextureAssignerShader(6), - pyHLRShader() - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/sketchy_topology_broken.py b/source/blender/freestyle/style_modules_old/sketchy_topology_broken.py deleted file mode 100755 index 7383347a0fb..00000000000 --- a/source/blender/freestyle/style_modules_old/sketchy_topology_broken.py +++ /dev/null @@ -1,89 +0,0 @@ -# -# Filename : sketchy_topology_broken.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : The topology of the strokes is, first, built -# independantly from the 3D topology of objects, -# and, second, so as to chain several times the same ViewEdge. -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from ChainingIterators import * -from shaders import * - -## Backbone stretcher that leaves cusps intact to avoid cracks -class pyBackboneStretcherNoCuspShader(StrokeShader): - def __init__(self, l): - StrokeShader.__init__(self) - self._l = l - def getName(self): - return "pyBackboneStretcherNoCuspShader" - def shade(self, stroke): - it0 = stroke.strokeVerticesBegin() - it1 = StrokeVertexIterator(it0) - it1.increment() - itn = stroke.strokeVerticesEnd() - itn.decrement() - itn_1 = StrokeVertexIterator(itn) - itn_1.decrement() - v0 = it0.getObject() - v1 = it1.getObject() - if((v0.getNature() & CUSP == 0) and (v1.getNature() & CUSP == 0)): - p0 = v0.getPoint() - p1 = v1.getPoint() - d1 = p0-p1 - d1 = d1/d1.norm() - newFirst = p0+d1*float(self._l) - v0.setPoint(newFirst) - else: - print "got a v0 cusp" - vn_1 = itn_1.getObject() - vn = itn.getObject() - if((vn.getNature() & CUSP == 0) and (vn_1.getNature() & CUSP == 0)): - pn = vn.getPoint() - pn_1 = vn_1.getPoint() - dn = pn-pn_1 - dn = dn/dn.norm() - newLast = pn+dn*float(self._l) - vn.setPoint(newLast) - else: - print "got a vn cusp" - - -Operators.select(QuantitativeInvisibilityUP1D(0)) -## Chain 3 times each ViewEdge indpendantly from the -## initial objects topology -Operators.bidirectionalChain(pySketchyChainingIterator(3)) -shaders_list = [ - SamplingShader(4), - SpatialNoiseShader(6, 120, 2, 1, 1), - IncreasingThicknessShader(4, 10), - SmoothingShader(100, 0.1, 0, 0.2, 0, 0, 0, 1), - pyBackboneStretcherNoCuspShader(20), - #ConstantColorShader(0.0,0.0,0.0) - IncreasingColorShader(0.2,0.2,0.2,1,0.5,0.5,0.5,1), - #IncreasingColorShader(1,0,0,1,0,1,0,1), - TextureAssignerShader(4) - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/sketchy_topology_preserved.py b/source/blender/freestyle/style_modules_old/sketchy_topology_preserved.py deleted file mode 100755 index bc56a272bd5..00000000000 --- a/source/blender/freestyle/style_modules_old/sketchy_topology_preserved.py +++ /dev/null @@ -1,49 +0,0 @@ -# -# Filename : sketchy_topology_preserved.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : The topology of the strokes is built -# so as to chain several times the same ViewEdge. -# The topology of the objects is preserved -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from ChainingIterators import * -from PredicatesU1D import * -from shaders import * - -upred = QuantitativeInvisibilityUP1D(0) -Operators.select(upred) -Operators.bidirectionalChain(pySketchyChainSilhouetteIterator(3,1)) -shaders_list = [ - SamplingShader(4), - SpatialNoiseShader(20, 220, 2, 1, 1), - IncreasingThicknessShader(4, 8), - SmoothingShader(300, 0.05, 0, 0.2, 0, 0, 0, 0.5), - ConstantColorShader(0.6,0.2,0.0), - TextureAssignerShader(4), - ] - -Operators.create(TrueUP1D(), shaders_list) - diff --git a/source/blender/freestyle/style_modules_old/split_at_highest_2d_curvatures.py b/source/blender/freestyle/style_modules_old/split_at_highest_2d_curvatures.py deleted file mode 100755 index 0f42080292b..00000000000 --- a/source/blender/freestyle/style_modules_old/split_at_highest_2d_curvatures.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# Filename : split_at_highest_2d_curvature.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws the visible lines (chaining follows same nature lines) -# (most basic style module) -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesU1D import * -from Functions0D import * - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) -func = pyInverseCurvature2DAngleF0D() -Operators.recursiveSplit(func, pyParameterUP0D(0.4,0.6), NotUP1D(pyHigherLengthUP1D(100)), 2) -shaders_list = [ConstantThicknessShader(10), IncreasingColorShader(1,0,0,1,0,1,0,1), TextureAssignerShader(3)] -Operators.create(TrueUP1D(), shaders_list) - diff --git a/source/blender/freestyle/style_modules_old/split_at_tvertices.py b/source/blender/freestyle/style_modules_old/split_at_tvertices.py deleted file mode 100755 index dde586fd1f0..00000000000 --- a/source/blender/freestyle/style_modules_old/split_at_tvertices.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# Filename : split_at_tvertices.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws strokes that starts and stops at Tvertices (visible or not) -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesU1D import * -from PredicatesU0D import * -from Functions0D import * - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) -start = pyVertexNatureUP0D(T_VERTEX) -## use the same predicate to decide where to start and where to stop -## the strokes: -Operators.sequentialSplit(start, start, 10) -shaders_list = [ConstantThicknessShader(5), IncreasingColorShader(1,0,0,1,0,1,0,1), TextureAssignerShader(3)] -Operators.create(TrueUP1D(), shaders_list) - diff --git a/source/blender/freestyle/style_modules_old/stroke_texture.py b/source/blender/freestyle/style_modules_old/stroke_texture.py deleted file mode 100755 index d6c753bf9e6..00000000000 --- a/source/blender/freestyle/style_modules_old/stroke_texture.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# Filename : stroke_texture.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws textured strokes (illustrate the StrokeTextureShader shader) -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesB1D import * -from shaders import * -from ChainingIterators import * - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) -shaders_list = [ - SamplingShader(3), - BezierCurveShader(4), - StrokeTextureShader("washbrushAlpha.bmp", Stroke.DRY_MEDIUM, 1), - ConstantThicknessShader(40), - ConstantColorShader(0,0,0,1), - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/suggestive.py b/source/blender/freestyle/style_modules_old/suggestive.py deleted file mode 100755 index 99a419ca23f..00000000000 --- a/source/blender/freestyle/style_modules_old/suggestive.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# Filename : suggestive.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Draws the suggestive contours. -# ***** The suggestive contours must be enabled -# in the options dialog ***** -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from PredicatesB1D import * -from PredicatesU1D import * -from shaders import * - -upred = AndUP1D(pyNatureUP1D(SUGGESTIVE_CONTOUR), QuantitativeInvisibilityUP1D(0)) -Operators.select(upred) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(upred)) -shaders_list = [ - IncreasingThicknessShader(1, 3), - ConstantColorShader(0.2,0.2,0.2, 1) - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/thickness_fof_depth_discontinuity.py b/source/blender/freestyle/style_modules_old/thickness_fof_depth_discontinuity.py deleted file mode 100755 index 06687fd9a00..00000000000 --- a/source/blender/freestyle/style_modules_old/thickness_fof_depth_discontinuity.py +++ /dev/null @@ -1,62 +0,0 @@ -# -# Filename : thickness_fof_depth_discontinuity.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Assigns to strokes a thickness that depends on the depth discontinuity -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - -from Freestyle import * -from logical_operators import * -from ChainingIterators import * -from shaders import * - -class pyDepthDiscontinuityThicknessShader(StrokeShader): - def __init__(self, min, max): - StrokeShader.__init__(self) - self.__min = float(min) - self.__max = float(max) - self.__func = ZDiscontinuityF0D() - def getName(self): - return "pyDepthDiscontinuityThicknessShader" - def shade(self, stroke): - it = stroke.strokeVerticesBegin() - z_min=0.0 - z_max=1.0 - a = (self.__max - self.__min)/(z_max-z_min) - b = (self.__min*z_max-self.__max*z_min)/(z_max-z_min) - it = stroke.strokeVerticesBegin() - while it.isEnd() == 0: - z = self.__func(it.castToInterface0DIterator()) - thickness = a*z+b - it.getObject().attribute().setThickness(thickness, thickness) - it.increment() - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) -shaders_list = [ - SamplingShader(1), - ConstantThicknessShader(3), - ConstantColorShader(0.0,0.0,0.0), - pyDepthDiscontinuityThicknessShader(0.8, 6) - ] -Operators.create(TrueUP1D(), shaders_list) \ No newline at end of file diff --git a/source/blender/freestyle/style_modules_old/tipremover.py b/source/blender/freestyle/style_modules_old/tipremover.py deleted file mode 100755 index b87eb7a573a..00000000000 --- a/source/blender/freestyle/style_modules_old/tipremover.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# Filename : tipremover.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Removes strokes extremities -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - - -from Freestyle import * -from logical_operators import * -from ChainingIterators import * -from shaders import * - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) -shaders_list = [ - SamplingShader(5), - ConstantThicknessShader(3), - ConstantColorShader(0,0,0), - TipRemoverShader(20) - ] -Operators.create(TrueUP1D(), shaders_list) \ No newline at end of file diff --git a/source/blender/freestyle/style_modules_old/tvertex_remover.py b/source/blender/freestyle/style_modules_old/tvertex_remover.py deleted file mode 100755 index b55754381f7..00000000000 --- a/source/blender/freestyle/style_modules_old/tvertex_remover.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# Filename : tvertex_remover.py -# Author : Stephane Grabli -# Date : 04/08/2005 -# Purpose : Removes TVertices -# -############################################################################# -# -# Copyright (C) : Please refer to the COPYRIGHT file distributed -# with this source distribution. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################# - - -from Freestyle import * -from logical_operators import * -from PredicatesB1D import * -from shaders import * - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) -shaders_list = [ - IncreasingThicknessShader(3, 5), - ConstantColorShader(0.2,0.2,0.2, 1), - SamplingShader(10.0), - pyTVertexRemoverShader() - ] -Operators.create(TrueUP1D(), shaders_list) diff --git a/source/blender/freestyle/style_modules_old/uniformpruning_zsort.py b/source/blender/freestyle/style_modules_old/uniformpruning_zsort.py deleted file mode 100755 index 7e719417af0..00000000000 --- a/source/blender/freestyle/style_modules_old/uniformpruning_zsort.py +++ /dev/null @@ -1,40 +0,0 @@ -from Freestyle import * -from logical_operators import * -from PredicatesU1D import * -from PredicatesU0D import * -from PredicatesB1D import * -from Functions0D import * -from Functions1D import * -from shaders import * - -class pyDensityUP1D(UnaryPredicate1D): - def __init__(self,wsize,threshold, integration = MEAN, sampling=2.0): - UnaryPredicate1D.__init__(self) - self._wsize = wsize - self._threshold = threshold - self._integration = integration - self._func = DensityF1D(self._wsize, self._integration, sampling) - - def getName(self): - return "pyDensityUP1D" - - def __call__(self, inter): - d = self._func(inter) - print "For Chain ", inter.getId().getFirst(), inter.getId().getSecond(), "density is ", d - if(d < self._threshold): - return 1 - return 0 - -Operators.select(QuantitativeInvisibilityUP1D(0)) -Operators.bidirectionalChain(ChainSilhouetteIterator()) -#Operators.sequentialSplit(pyVertexNatureUP0D(VIEW_VERTEX), 2) -Operators.sort(pyZBP1D()) -shaders_list = [ - StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, 0), - ConstantThicknessShader(3), - SamplingShader(5.0), - ConstantColorShader(0,0,0,1) - ] -Operators.create(pyDensityUP1D(2,0.05, MEAN,4), shaders_list) -#Operators.create(pyDensityFunctorUP1D(8,0.03, pyGetInverseProjectedZF1D(), 0,1, MEAN), shaders_list) - diff --git a/source/blender/freestyle/style_modules_old/vector.py b/source/blender/freestyle/style_modules_old/vector.py deleted file mode 100755 index 039f262546b..00000000000 --- a/source/blender/freestyle/style_modules_old/vector.py +++ /dev/null @@ -1,241 +0,0 @@ -# This module defines 3d geometrical vectors with the standard -# operations on them. -# -# Written by: Konrad Hinsen -# Last revision: 1996-1-26 -# - -"""This module defines three-dimensional geometrical vectors. Vectors support -the usual mathematical operations (v1, v2: vectors, s: scalar): - v1+v2 addition - v1-v2 subtraction - v1*v2 scalar product - s*v1 multiplication with a scalar - v1/s division by a scalar - v1.cross(v2) cross product - v1.length() length - v1.normal() normal vector in direction of v1 - v1.angle(v2) angle between two vectors - v1.x(), v1[0] first element - v1.y(), v1[1] second element - v1.z(), v1[2] third element - -The module offers the following items for export: - Vec3D(x,y,z) the constructor for vectors - isVector(x) a type check function - ex, ey, ez unit vectors along the x-, y-, and z-axes (predefined constants) - -Note: vector elements can be any kind of numbers on which the operations -addition, subtraction, multiplication, division, comparison, sqrt, and acos -are defined. Integer elements are treated as floating point elements. -""" - -import math, types - -class Vec3: - - isVec3 = 1 - - def __init__(self, x=0., y=0., z=0.): - self.data = [x,y,z] - - def __repr__(self): - return 'Vec3(%s,%s,%s)' % (`self.data[0]`,\ - `self.data[1]`,`self.data[2]`) - - def __str__(self): - return `self.data` - - def __add__(self, other): - return Vec3(self.data[0]+other.data[0],\ - self.data[1]+other.data[1],self.data[2]+other.data[2]) - __radd__ = __add__ - - def __neg__(self): - return Vec3(-self.data[0], -self.data[1], -self.data[2]) - - def __sub__(self, other): - return Vec3(self.data[0]-other.data[0],\ - self.data[1]-other.data[1],self.data[2]-other.data[2]) - - def __rsub__(self, other): - return Vec3(other.data[0]-self.data[0],\ - other.data[1]-self.data[1],other.data[2]-self.data[2]) - - def __mul__(self, other): - if isVec3(other): - return reduce(lambda a,b: a+b, - map(lambda a,b: a*b, self.data, other.data)) - else: - return Vec3(self.data[0]*other, self.data[1]*other, - self.data[2]*other) - - def __rmul__(self, other): - if isVec3(other): - return reduce(lambda a,b: a+b, - map(lambda a,b: a*b, self.data, other.data)) - else: - return Vec3(other*self.data[0], other*self.data[1], - other*self.data[2]) - - def __div__(self, other): - if isVec3(other): - raise TypeError, "Can't divide by a vector" - else: - return Vec3(_div(self.data[0],other), _div(self.data[1],other), - _div(self.data[2],other)) - - def __rdiv__(self, other): - raise TypeError, "Can't divide by a vector" - - def __cmp__(self, other): - return cmp(self.data[0],other.data[0]) \ - or cmp(self.data[1],other.data[1]) \ - or cmp(self.data[2],other.data[2]) - - def __getitem__(self, index): - return self.data[index] - - def x(self): - return self.data[0] - def y(self): - return self.data[1] - def z(self): - return self.data[2] - - def length(self): - return math.sqrt(self*self) - - def normal(self): - len = self.length() - if len == 0: - raise ZeroDivisionError, "Can't normalize a zero-length vector" - return self/len - - def cross(self, other): - if not isVec3(other): - raise TypeError, "Cross product with non-vector" - return Vec3(self.data[1]*other.data[2]-self.data[2]*other.data[1], - self.data[2]*other.data[0]-self.data[0]*other.data[2], - self.data[0]*other.data[1]-self.data[1]*other.data[0]) - - def angle(self, other): - if not isVec3(other): - raise TypeError, "Angle between vector and non-vector" - cosa = (self*other)/(self.length()*other.length()) - cosa = max(-1.,min(1.,cosa)) - return math.acos(cosa) - - -class Vec2: - - isVec2 = 1 - - def __init__(self, x=0., y=0.): - self.data = [x,y] - - def __repr__(self): - return 'Vec2(%s,%s,%s)' % (`self.data[0]`,\ - `self.data[1]`) - - def __str__(self): - return `self.data` - - def __add__(self, other): - return Vec2(self.data[0]+other.data[0],\ - self.data[1]+other.data[1]) - __radd__ = __add__ - - def __neg__(self): - return Vec2(-self.data[0], -self.data[1]) - - def __sub__(self, other): - return Vec2(self.data[0]-other.data[0],\ - self.data[1]-other.data[1]) - - def __rsub__(self, other): - return Vec2(other.data[0]-self.data[0],\ - other.data[1]-self.data[1]) - - def __mul__(self, other): - if isVec2(other): - return reduce(lambda a,b: a+b, - map(lambda a,b: a*b, self.data, other.data)) - else: - return Vec2(self.data[0]*other, self.data[1]*other) - - def __rmul__(self, other): - if isVec2(other): - return reduce(lambda a,b: a+b, - map(lambda a,b: a*b, self.data, other.data)) - else: - return Vec2(other*self.data[0], other*self.data[1]) - - def __div__(self, other): - if isVec2(other): - raise TypeError, "Can't divide by a vector" - else: - return Vec2(_div(self.data[0],other), _div(self.data[1],other)) - - def __rdiv__(self, other): - raise TypeError, "Can't divide by a vector" - - def __cmp__(self, other): - return cmp(self.data[0],other.data[0]) \ - or cmp(self.data[1],other.data[1]) - - def __getitem__(self, index): - return self.data[index] - - def x(self): - return self.data[0] - def y(self): - return self.data[1] - - def length(self): - return math.sqrt(self*self) - - def normal(self): - len = self.length() - if len == 0: - raise ZeroDivisionError, "Can't normalize a zero-length vector" - return self/len - - #def cross(self, other): -# if not isVec2(other): -# raise TypeError, "Cross product with non-vector" -# return Vec2(self.data[1]*other.data[2]-self.data[2]*other.data[1], -# self.data[2]*other.data[0]-self.data[0]*other.data[2], -# self.data[0]*other.data[1]-self.data[1]*other.data[0]) - - def angle(self, other): - if not isVec2(other): - raise TypeError, "Angle between vector and non-vector" - cosa = (self*other)/(self.length()*other.length()) - cosa = max(-1.,min(1.,cosa)) - return math.acos(cosa) - - - -# Type check - -def isVec3(x): - return hasattr(x,'isVec3') - -def isVec2(x): - return hasattr(x,'isVec2') - -# "Correct" division for arbitrary number types - -def _div(a,b): - if type(a) == types.IntType and type(b) == types.IntType: - return float(a)/float(b) - else: - return a/b - - -# Some useful constants - -ex = Vec3(1.,0.,0.) -ey = Vec3(0.,1.,0.) -ez = Vec3(0.,0.,1.)