OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
| 3 * |
| 4 * This program is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU General Public License |
| 6 * as published by the Free Software Foundation; either version 2 |
| 7 * of the License, or (at your option) any later version. |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software Foundation, |
| 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 * |
| 18 * The Original Code is Copyright (C) 2010 Blender Foundation. |
| 19 * All rights reserved. |
| 20 * |
| 21 * The Original Code is: all of this file. |
| 22 * |
| 23 * Contributor(s): none yet. |
| 24 * |
| 25 * ***** END GPL LICENSE BLOCK ***** |
| 26 */ |
| 27 |
| 28 #ifndef __FREESTYLE_PREDICATES_0D_H__ |
| 29 #define __FREESTYLE_PREDICATES_0D_H__ |
| 30 |
| 31 /** \file blender/freestyle/intern/stroke/Predicates0D.h |
| 32 * \ingroup freestyle |
| 33 * \brief Class gathering stroke creation algorithms |
| 34 * \author Stephane Grabli |
| 35 * \author Emmanuel Turquin |
| 36 * \date 01/07/2003 |
| 37 */ |
| 38 |
| 39 #include "../python/Director.h" |
| 40 |
| 41 #include "../view_map/Functions0D.h" |
| 42 |
| 43 // |
| 44 // UnaryPredicate0D (base class for predicates in 0D) |
| 45 // |
| 46 /////////////////////////////////////////////////////////// |
| 47 |
| 48 /*! Base class for Unary Predicates that work on Interface0DIterator. |
| 49 * A UnaryPredicate0D is a functor that evaluates a condition on a Interface0DI
terator and returns |
| 50 * true or false depending on whether this condition is satisfied or not. |
| 51 * The UnaryPredicate0D is used by calling its () operator. |
| 52 * Any inherited class must overload the () operator. |
| 53 */ |
| 54 class UnaryPredicate0D |
| 55 { |
| 56 public: |
| 57 bool result; |
| 58 PyObject *py_up0D; |
| 59 |
| 60 /*! Default constructor. */ |
| 61 UnaryPredicate0D() |
| 62 { |
| 63 py_up0D = 0; |
| 64 } |
| 65 |
| 66 /*! Destructor. */ |
| 67 virtual ~UnaryPredicate0D() {} |
| 68 |
| 69 /*! Returns the string of the name of the UnaryPredicate0D. */ |
| 70 virtual string getName() const |
| 71 { |
| 72 return "UnaryPredicate0D"; |
| 73 } |
| 74 |
| 75 /*! The () operator. Must be overload by inherited classes. |
| 76 * \param it |
| 77 * The Interface0DIterator pointing onto the Interface0D at which we
wish to evaluate the predicate. |
| 78 * \return true if the condition is satisfied, false otherwise. |
| 79 */ |
| 80 virtual int operator()(Interface0DIterator& it) |
| 81 { |
| 82 return Director_BPy_UnaryPredicate0D___call__(this, it); |
| 83 } |
| 84 }; |
| 85 |
| 86 |
| 87 // |
| 88 // BinaryPredicate0D (base class for predicates in 0D) |
| 89 // |
| 90 /////////////////////////////////////////////////////////// |
| 91 |
| 92 /*! Base class for Binary Predicates working on Interface0D. |
| 93 * A BinaryPredicate0D is typically an ordering relation between two Interface0
D. |
| 94 * It evaluates a relation between 2 Interface0D and returns true or false. |
| 95 * It is used by calling the () operator. |
| 96 */ |
| 97 class BinaryPredicate0D |
| 98 { |
| 99 public: |
| 100 bool result; |
| 101 PyObject *py_bp0D; |
| 102 |
| 103 /*! Default constructor. */ |
| 104 BinaryPredicate0D() |
| 105 { |
| 106 py_bp0D = 0; |
| 107 } |
| 108 |
| 109 /*! Destructor. */ |
| 110 virtual ~BinaryPredicate0D() {} |
| 111 |
| 112 /*! Returns the string of the name of the binary predicate. */ |
| 113 virtual string getName() const |
| 114 { |
| 115 return "BinaryPredicate0D"; |
| 116 } |
| 117 |
| 118 /*! The () operator. Must be overload by inherited classes. |
| 119 * It evaluates a relation between 2 Interface0D. |
| 120 * \param inter1 |
| 121 * The first Interface0D. |
| 122 * \param inter2 |
| 123 * The second Interface0D. |
| 124 * \return true or false. |
| 125 */ |
| 126 virtual int operator()(Interface0D& inter1, Interface0D& inter2) |
| 127 { |
| 128 return Director_BPy_BinaryPredicate0D___call__(this, inter1, int
er2); |
| 129 } |
| 130 }; |
| 131 |
| 132 |
| 133 // |
| 134 // Predicates definitions |
| 135 // |
| 136 /////////////////////////////////////////////////////////// |
| 137 |
| 138 namespace Predicates0D { |
| 139 |
| 140 // TrueUP0D |
| 141 /*! Returns true any time */ |
| 142 class TrueUP0D : public UnaryPredicate0D |
| 143 { |
| 144 public: |
| 145 /*! Default constructor. */ |
| 146 TrueUP0D() {} |
| 147 |
| 148 /*! Returns the string "TrueUP0D"*/ |
| 149 string getName() const |
| 150 { |
| 151 return "TrueUP0D"; |
| 152 } |
| 153 |
| 154 /*! The () operator. */ |
| 155 int operator()(Interface0DIterator&) |
| 156 { |
| 157 result = true; |
| 158 return 0; |
| 159 } |
| 160 }; |
| 161 |
| 162 // FalseUP0D |
| 163 /*! Returns false any time */ |
| 164 class FalseUP0D : public UnaryPredicate0D |
| 165 { |
| 166 public: |
| 167 /*! Default constructor. */ |
| 168 FalseUP0D() {} |
| 169 |
| 170 /*! Returns the string "FalseUP0D"*/ |
| 171 string getName() const |
| 172 { |
| 173 return "FalseUP0D"; |
| 174 } |
| 175 |
| 176 /*! The () operator. */ |
| 177 int operator()(Interface0DIterator&) |
| 178 { |
| 179 result = false; |
| 180 return 0; |
| 181 } |
| 182 }; |
| 183 |
| 184 } // end of namespace Predicates0D |
| 185 |
| 186 #endif // __FREESTYLE_PREDICATES_0D_H__ |
OLD | NEW |