Freestyle: Added logical operators for binary predicates for 1D elements.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Fri, 18 Apr 2014 04:57:10 +0000 (13:57 +0900)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Fri, 18 Apr 2014 06:02:44 +0000 (15:02 +0900)
The implemented operators are:
freestyle.predicates.AndBP1D
freestyle.predicates.NotBP1D
freestyle.predicates.OrBP1D

release/scripts/freestyle/modules/freestyle/predicates.py

index 0bcba160341105aa70fc9e41c95d0221b931b9b1..ce6f0a35ffeae832d86dbd4ebecf9fbed5b09f78 100644 (file)
@@ -155,7 +155,6 @@ class pyParameterUP0D(UnaryPredicate0D):
 ## Unary predicates for 1D elements (curves)
 ############################################
 
-
 class AndUP1D(UnaryPredicate1D):
     def __init__(self, pred1, pred2):
         UnaryPredicate1D.__init__(self)
@@ -515,6 +514,34 @@ class pyClosedCurveUP1D(UnaryPredicate1D):
 ## Binary predicates for 1D elements (curves)
 #############################################
 
+class AndBP1D(BinaryPredicate1D):
+    def __init__(self, pred1, pred2):
+        BinaryPredicate1D.__init__(self)
+        self.__pred1 = pred1
+        self.__pred2 = pred2
+
+    def __call__(self, inter1, inter2):
+        return self.__pred1(inter1, inter2) and self.__pred2(inter1, inter2)
+
+
+class OrBP1D(BinaryPredicate1D):
+    def __init__(self, pred1, pred2):
+        BinaryPredicate1D.__init__(self)
+        self.__pred1 = pred1
+        self.__pred2 = pred2
+
+    def __call__(self, inter1, inter2):
+        return self.__pred1(inter1, inter2) or self.__pred2(inter1, inter2)
+
+
+class NotBP1D(BinaryPredicate1D):
+    def __init__(self, pred):
+        BinaryPredicate1D.__init__(self)
+        self.__pred = pred
+
+    def __call__(self, inter1, inter2):
+        return not self.__pred(inter1, inter2)
+
 
 class pyZBP1D(BinaryPredicate1D):
     def __init__(self, iType=IntegrationType.MEAN):