[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41321] branches/soc-2008-mxcurioni: Extended the set of conditions for feature edge selection by edge types.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Thu Oct 27 22:57:15 CEST 2011


Revision: 41321
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41321
Author:   kjym3
Date:     2011-10-27 20:57:14 +0000 (Thu, 27 Oct 2011)
Log Message:
-----------
Extended the set of conditions for feature edge selection by edge types.

In the Parameter Editor mode, each edge type check button in the Selection
by Edge Types has now an associated toggle button to exclude the edge type
from the feature edge selection.  This allows you to select, for instance,
those edges that are silhouette lines but not external contours.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
    branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h
    branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c

Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py	2011-10-27 17:39:15 UTC (rev 41320)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py	2011-10-27 20:57:14 UTC (rev 41321)
@@ -505,7 +505,7 @@
 
 def join_unary_predicates(upred_list, bpred):
     if not upred_list:
-        return TrueUP1D()
+        return None
     upred = upred_list[0]
     for p in upred_list[1:]:
         upred = bpred(upred, p)
@@ -835,47 +835,36 @@
     # prepare selection criteria by edge types
     if lineset.select_by_edge_types:
         edge_type_criteria = []
-        if lineset.edge_type_combination == "OR":
-            flags = Nature.NO_FEATURE
-            if lineset.select_silhouette:
-                flags |= Nature.SILHOUETTE
-            if lineset.select_border:
-                flags |= Nature.BORDER
-            if lineset.select_crease:
-                flags |= Nature.CREASE
-            if lineset.select_ridge:
-                flags |= Nature.RIDGE
-            if lineset.select_valley:
-                flags |= Nature.VALLEY
-            if lineset.select_suggestive_contour:
-                flags |= Nature.SUGGESTIVE_CONTOUR
-            if lineset.select_material_boundary:
-                flags |= Nature.MATERIAL_BOUNDARY
-            if lineset.select_edge_mark:
-                flags |= Nature.EDGE_MARK
-            if flags != Nature.NO_FEATURE:
-                edge_type_criteria.append(pyNatureUP1D(flags))
-        else:
-            if lineset.select_silhouette:
-                edge_type_criteria.append(pyNatureUP1D(Nature.SILHOUETTE))
-            if lineset.select_border:
-                edge_type_criteria.append(pyNatureUP1D(Nature.BORDER))
-            if lineset.select_crease:
-                edge_type_criteria.append(pyNatureUP1D(Nature.CREASE))
-            if lineset.select_ridge:
-                edge_type_criteria.append(pyNatureUP1D(Nature.RIDGE))
-            if lineset.select_valley:
-                edge_type_criteria.append(pyNatureUP1D(Nature.VALLEY))
-            if lineset.select_suggestive_contour:
-                edge_type_criteria.append(pyNatureUP1D(Nature.SUGGESTIVE_CONTOUR))
-            if lineset.select_material_boundary:
-                edge_type_criteria.append(pyNatureUP1D(Nature.MATERIAL_BOUNDARY))
-            if lineset.select_edge_mark:
-                edge_type_criteria.append(pyNatureUP1D(Nature.EDGE_MARK))
+        if lineset.select_silhouette:
+            upred = pyNatureUP1D(Nature.SILHOUETTE)
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_silhouette else upred)
+        if lineset.select_border:
+            upred = pyNatureUP1D(Nature.BORDER)
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_border else upred)
+        if lineset.select_crease:
+            upred = pyNatureUP1D(Nature.CREASE)
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_crease else upred)
+        if lineset.select_ridge:
+            upred = pyNatureUP1D(Nature.RIDGE)
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_ridge else upred)
+        if lineset.select_valley:
+            upred = pyNatureUP1D(Nature.VALLEY)
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_valley else upred)
+        if lineset.select_suggestive_contour:
+            upred = pyNatureUP1D(Nature.SUGGESTIVE_CONTOUR)
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_suggestive_contour else upred)
+        if lineset.select_material_boundary:
+            upred = pyNatureUP1D(Nature.MATERIAL_BOUNDARY)
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_material_boundary else upred)
+        if lineset.select_edge_mark:
+            upred = pyNatureUP1D(Nature.EDGE_MARK)
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_edge_mark else upred)
         if lineset.select_contour:
-            edge_type_criteria.append(ContourUP1D())
+            upred = ContourUP1D()
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_contour else upred)
         if lineset.select_external_contour:
-            edge_type_criteria.append(ExternalContourUP1D())
+            upred = ExternalContourUP1D()
+            edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_external_contour else upred)
         if lineset.edge_type_combination == "OR":
             upred = join_unary_predicates(edge_type_criteria, OrUP1D)
         else:

Modified: branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py	2011-10-27 17:39:15 UTC (rev 41320)
+++ branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py	2011-10-27 20:57:14 UTC (rev 41321)
@@ -261,6 +261,17 @@
             return freestyle.mode == "EDITOR" and freestyle.linesets.active
         return False
 
+    def draw_edge_type_buttons(self, box, lineset, edge_type):
+        # property names
+        select_edge_type = "select_" + edge_type
+        exclude_edge_type = "exclude_" + edge_type
+        # draw edge type buttons
+        row = box.row(align=True)
+        row.prop(lineset, select_edge_type)
+        sub = row.column()
+        sub.prop(lineset, exclude_edge_type, text="")
+        sub.enabled = getattr(lineset, select_edge_type)
+
     def draw(self, context):
         layout = self.layout
 
@@ -293,17 +304,18 @@
 
             row = col.row()
             sub = row.column()
-            sub.prop(lineset, "select_silhouette")
-            sub.prop(lineset, "select_border")
-            sub.prop(lineset, "select_crease")
-            sub.prop(lineset, "select_ridge")
-            sub.prop(lineset, "select_valley")
-            sub.prop(lineset, "select_suggestive_contour")
-            sub.prop(lineset, "select_material_boundary")
-            sub.prop(lineset, "select_edge_mark")
+            self.draw_edge_type_buttons(sub, lineset, "silhouette")
+            self.draw_edge_type_buttons(sub, lineset, "border")
+
+            self.draw_edge_type_buttons(sub, lineset, "crease")
+            self.draw_edge_type_buttons(sub, lineset, "ridge")
+            self.draw_edge_type_buttons(sub, lineset, "valley")
+            self.draw_edge_type_buttons(sub, lineset, "suggestive_contour")
+            self.draw_edge_type_buttons(sub, lineset, "material_boundary")
+            self.draw_edge_type_buttons(sub, lineset, "edge_mark")
             sub = row.column()
-            sub.prop(lineset, "select_contour")
-            sub.prop(lineset, "select_external_contour")
+            self.draw_edge_type_buttons(sub, lineset, "contour")
+            self.draw_edge_type_buttons(sub, lineset, "external_contour")
             col.separator() # XXX
 
         col.prop(lineset, "select_by_face_marks")

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2011-10-27 17:39:15 UTC (rev 41320)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2011-10-27 20:57:14 UTC (rev 41321)
@@ -160,6 +160,69 @@
 		return text;
 	}
 
+	struct edge_type_condition {
+		int edge_type, value;
+	};
+
+	// examines the conditions and returns true if the target edge type needs to be computed
+	static bool test_edge_type_conditions(struct edge_type_condition *conditions,
+		int num_edge_types, bool logical_and, int target, bool distinct)
+	{
+		int target_condition = 0;
+		int num_non_target_positive_conditions = 0;
+		int num_non_target_negative_conditions = 0;
+
+		for (int i = 0; i < num_edge_types; i++) {
+			if (conditions[i].edge_type == target)
+				target_condition = conditions[i].value;
+			else if (conditions[i].value > 0)
+				++num_non_target_positive_conditions;
+			else if (conditions[i].value < 0)
+				++num_non_target_negative_conditions;
+		}
+		if (distinct) {
+			// In this case, the 'target' edge type is assumed to appear on distinct edge
+			// of its own and never together with other edge types.
+			if (logical_and) {
+				if (num_non_target_positive_conditions > 0)
+					return false;
+				if (target_condition > 0)
+					return true;
+				if (target_condition < 0)
+					return false;
+				if (num_non_target_negative_conditions > 0)
+					return true;
+			} else {
+				if (target_condition > 0)
+					return true;
+				if (num_non_target_negative_conditions > 0)
+					return true;
+				if (target_condition < 0)
+					return false;
+				if (num_non_target_positive_conditions > 0)
+					return false;
+			}
+		} else {
+			// In this case, the 'target' edge type may appear together with other edge types.
+			if (target_condition > 0)
+				return true;
+			if (target_condition < 0)
+				return true;
+			if (logical_and) {
+				if (num_non_target_positive_conditions > 0)
+					return false;
+				if (num_non_target_negative_conditions > 0)
+					return true;
+			} else {
+				if (num_non_target_negative_conditions > 0)
+					return true;
+				if (num_non_target_positive_conditions > 0)
+					return false;
+			}
+		}
+		return true;
+	}
+
 	static void prepare(Render* re, SceneRenderLayer* srl ) {
 				
 		// load mesh
@@ -197,6 +260,18 @@
 			int use_ridges_and_valleys = 0;
 			int use_suggestive_contours = 0;
 			int use_material_boundaries = 0;
+			struct edge_type_condition conditions[] = {
+				{FREESTYLE_FE_SILHOUETTE, 0},
+				{FREESTYLE_FE_BORDER, 0},
+				{FREESTYLE_FE_CREASE, 0},
+				{FREESTYLE_FE_RIDGE, 0},
+				{FREESTYLE_FE_VALLEY, 0},
+				{FREESTYLE_FE_SUGGESTIVE_CONTOUR, 0},
+				{FREESTYLE_FE_MATERIAL_BOUNDARY, 0},
+				{FREESTYLE_FE_CONTOUR, 0},
+				{FREESTYLE_FE_EXTERNAL_CONTOUR, 0},
+				{FREESTYLE_FE_EDGE_MARK, 0}};
+			int num_edge_types = sizeof(conditions) / sizeof(struct edge_type_condition);
 			cout << "Linesets:"<< endl;
 			for (FreestyleLineSet *lineset = (FreestyleLineSet *)config->linesets.first; lineset; lineset = lineset->next) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list