[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1766] trunk/py/scripts/addons/ mesh_bsurfaces.py: SVN maintenance.
gsr b3d
gsr.b3d at infernal-iceberg.com
Sat Apr 2 01:08:36 CEST 2011
Revision: 1766
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1766
Author: gsrb3d
Date: 2011-04-01 23:08:36 +0000 (Fri, 01 Apr 2011)
Log Message:
-----------
SVN maintenance.
Modified Paths:
--------------
trunk/py/scripts/addons/mesh_bsurfaces.py
Property Changed:
----------------
trunk/py/scripts/addons/mesh_bsurfaces.py
Modified: trunk/py/scripts/addons/mesh_bsurfaces.py
===================================================================
--- trunk/py/scripts/addons/mesh_bsurfaces.py 2011-04-01 17:16:26 UTC (rev 1765)
+++ trunk/py/scripts/addons/mesh_bsurfaces.py 2011-04-01 23:08:36 UTC (rev 1766)
@@ -1,858 +1,858 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-bl_addon_info = {
- "name": "Bsurfaces GPL Edition",
- "author": "Eclectiel",
- "version": (0,9),
- "blender": (2, 5, 7),
- "api": 35733,
- "location": "View3D > EditMode > ToolShelf",
- "description": "Draw meshes and re-topologies with Grease Pencil",
- "warning": "Beta",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
- "Scripts/Mesh/Surface_Sketch",
- "tracker_url": "https://projects.blender.org/tracker/index.php?"\
- "func=detail&aid=26642&group_id=153&atid=469",
- "category": "Mesh"}
-
-
-import bpy
-import math
-
-from math import *
-
-
-class VIEW3D_PT_tools_SURF_SKETCH(bpy.types.Panel):
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'TOOLS'
-
- bl_context = "mesh_edit"
- bl_label = "Surface Sketching"
-
- @classmethod
- def poll(cls, context):
- return context.active_object
-
- def draw(self, context):
- layout = self.layout
-
- scn = context.scene
- ob = context.object
-
- col = layout.column(align=True)
- row = layout.row()
- row.separator()
- col.operator("gpencil.surfsk_add_surface", text="Add Surface")
- col.prop(scn, "SURFSK_edges_U")
- col.prop(scn, "SURFSK_edges_V")
- row.separator()
- col.prop(scn, "SURFSK_keep_strokes")
- col.separator()
- row.separator()
- col.operator("gpencil.surfsk_strokes_to_curves", text="Strokes to curves")
-
-
-
-class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
- bl_idname = "gpencil.surfsk_add_surface"
- bl_label = "Surface Sketching"
- bl_description = "Generates a surface from grease pencil strokes or from curves."
- bl_options = {'REGISTER', 'UNDO'}
-
-
- ##### Get an ordered list of a chain of vertices.
- def get_ordered_verts(self, ob, all_selected_edges_idx, all_selected_verts_idx, first_vert_idx, middle_vertex_idx):
- # Order selected vertexes.
- verts_ordered = []
- verts_ordered.append(self.main_object.data.vertices[first_vert_idx])
- prev_v = first_vert_idx
- prev_ed = None
- finish_while = False
- while True:
- edges_non_matched = 0
- for i in all_selected_edges_idx:
- if ob.data.edges[i] != prev_ed and ob.data.edges[i].vertices[0] == prev_v and ob.data.edges[i].vertices[1] in all_selected_verts_idx:
- verts_ordered.append(self.main_object.data.vertices[ob.data.edges[i].vertices[1]])
- prev_v = ob.data.edges[i].vertices[1]
- prev_ed = ob.data.edges[i]
- elif ob.data.edges[i] != prev_ed and ob.data.edges[i].vertices[1] == prev_v and ob.data.edges[i].vertices[0] in all_selected_verts_idx:
- verts_ordered.append(self.main_object.data.vertices[ob.data.edges[i].vertices[0]])
- prev_v = ob.data.edges[i].vertices[0]
- prev_ed = ob.data.edges[i]
- else:
- edges_non_matched += 1
-
- if edges_non_matched == len(all_selected_edges_idx):
- finish_while = True
-
- if finish_while:
- break
-
- if middle_vertex_idx != None:
- verts_ordered.append(self.main_object.data.vertices[middle_vertex_idx])
- verts_ordered.reverse()
-
- return verts_ordered
-
-
- #### Calculates length of a chain of points.
- def get_chain_length(self, object, verts_ordered):
- matrix = object.matrix_world
-
- edges_lengths = []
- edges_lengths_sum = 0
- for i in range(0, len(verts_ordered)):
- if i == 0:
- prev_v_co = verts_ordered[i].co * matrix
- else:
- v_co = verts_ordered[i].co * matrix
-
- v_difs = [prev_v_co[0] - v_co[0], prev_v_co[1] - v_co[1], prev_v_co[2] - v_co[2]]
- edge_length = abs(sqrt(v_difs[0] * v_difs[0] + v_difs[1] * v_difs[1] + v_difs[2] * v_difs[2]))
-
- edges_lengths.append(edge_length)
- edges_lengths_sum += edge_length
-
- prev_v_co = v_co
-
-
- return edges_lengths, edges_lengths_sum
-
-
- #### Calculates the proportion of the edges of a chain of edges, relative to the full chain length.
- def get_edges_proportions(self, edges_lengths, edges_lengths_sum, use_boundaries, fixed_edges_num):
- edges_proportions = []
- if use_boundaries:
- verts_count = 1
- for l in edges_lengths:
- edges_proportions.append(l / edges_lengths_sum)
- verts_count += 1
- else:
- verts_count = 1
- for n in range(0, fixed_edges_num):
- edges_proportions.append(1 / fixed_edges_num)
- verts_count += 1
-
- return edges_proportions
-
-
- #### Calculates the angle between two pairs of points in space.
- def orientation_difference(self, points_A_co, points_B_co): # each parameter should be a list with two elements, and each element should be a x,y,z coordinate.
- vec_A = points_A_co[0] - points_A_co[1]
- vec_B = points_B_co[0] - points_B_co[1]
-
- angle = vec_A.angle(vec_B)
-
- if angle > 0.5 * math.pi:
- angle = abs(angle - math.pi)
-
- return angle
-
-
- #### Calculate distance between two points
- def pts_distance(self, p1_co, p2_co):
- p_difs = [p1_co[0] - p2_co[0], p1_co[1] - p2_co[1], p1_co[2] - p2_co[2]]
- distance = abs(sqrt(p_difs[0] * p_difs[0] + p_difs[1] * p_difs[1] + p_difs[2] * p_difs[2]))
-
- return distance
-
-
- def execute(self, context):
- #### Selected edges.
- all_selected_edges_idx = []
- all_selected_verts = []
- all_verts_idx = []
- for ed in self.main_object.data.edges:
- if ed.select:
- all_selected_edges_idx.append(ed.index)
-
- # Selected vertexes.
- if not ed.vertices[0] in all_selected_verts:
- all_selected_verts.append(self.main_object.data.vertices[ed.vertices[0]])
- if not ed.vertices[1] in all_selected_verts:
- all_selected_verts.append(self.main_object.data.vertices[ed.vertices[1]])
-
- # All verts (both from each edge) to determine later which are at the tips (those not repeated twice).
- all_verts_idx.append(ed.vertices[0])
- all_verts_idx.append(ed.vertices[1])
-
-
- #### Identify the tips and "middle-vertex" that separates U from V, if there is one.
- all_chains_tips_idx = []
- for v_idx in all_verts_idx:
- if all_verts_idx.count(v_idx) < 2:
- all_chains_tips_idx.append(v_idx)
-
- edges_connected_to_tips = []
- for ed in self.main_object.data.edges:
- if (ed.vertices[0] in all_chains_tips_idx or ed.vertices[1] in all_chains_tips_idx) and not (ed.vertices[0] in all_verts_idx and ed.vertices[1] in all_verts_idx):
- edges_connected_to_tips.append(ed)
-
- middle_vertex_idx = None
- tips_to_discard_idx = []
- for ed_tips in edges_connected_to_tips:
- for ed_tips_b in edges_connected_to_tips:
- if (ed_tips != ed_tips_b):
- if ed_tips.vertices[0] in all_verts_idx and (((ed_tips.vertices[1] == ed_tips_b.vertices[0]) or ed_tips.vertices[1] == ed_tips_b.vertices[1])):
- middle_vertex_idx = ed_tips.vertices[1]
- tips_to_discard_idx.append(ed_tips.vertices[0])
- elif ed_tips.vertices[1] in all_verts_idx and (((ed_tips.vertices[0] == ed_tips_b.vertices[0]) or ed_tips.vertices[0] == ed_tips_b.vertices[1])):
- middle_vertex_idx = ed_tips.vertices[0]
- tips_to_discard_idx.append(ed_tips.vertices[1])
-
-
- #### List with pairs of verts that belong to the tips of each selection chain (row).
- verts_tips_same_chain_idx = []
- if len(all_chains_tips_idx) >= 2:
- checked_v = []
- for i in range(0, len(all_chains_tips_idx)):
- if all_chains_tips_idx[i] not in checked_v:
- v_chain = self.get_ordered_verts(self.main_object, all_selected_edges_idx, all_verts_idx, all_chains_tips_idx[i], middle_vertex_idx)
-
- verts_tips_same_chain_idx.append([v_chain[0].index, v_chain[len(v_chain) - 1].index])
-
- checked_v.append(v_chain[0].index)
- checked_v.append(v_chain[len(v_chain) - 1].index)
-
-
- #### Selection tips (vertices)
- verts_tips_parsed_idx = []
- if len(all_chains_tips_idx) >= 2:
- for spec_v_idx in all_chains_tips_idx:
- if (spec_v_idx not in tips_to_discard_idx):
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list