[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3416] contrib/py/scripts/addons/ add_mesh_clusters:
Clemens Barth
barth at root-1.de
Mon May 28 17:14:16 CEST 2012
Revision: 3416
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3416
Author: blendphys
Date: 2012-05-28 15:14:15 +0000 (Mon, 28 May 2012)
Log Message:
-----------
1. Small correction in the menu entry
2. The code for calculating cluster shapes has been partially
changed for a faster calculation
Blendphys.
Modified Paths:
--------------
contrib/py/scripts/addons/add_mesh_clusters/__init__.py
contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py
Modified: contrib/py/scripts/addons/add_mesh_clusters/__init__.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_clusters/__init__.py 2012-05-28 14:11:55 UTC (rev 3415)
+++ contrib/py/scripts/addons/add_mesh_clusters/__init__.py 2012-05-28 15:14:15 UTC (rev 3416)
@@ -73,7 +73,7 @@
class CLASS_ImportCluster(bpy.types.Operator):
bl_idname = "mesh.cluster"
bl_label = "Atom cluster"
- bl_options = {'REGISTER', 'UNDO'}
+ bl_options = {'PRESET', 'UNDO'}
def execute(self, context):
@@ -257,8 +257,6 @@
add_mesh_cluster.DEF_atom_read_atom_data()
add_mesh_cluster.ATOM_CLUSTER_ALL_ATOMS[:] = []
- print(scn.shape)
-
if scn.shape in ["parabolid_ab", "parabolid_abc", "parabolid_square"]:
parameter1 = scn.parabol_height
parameter2 = scn.parabol_diameter
Modified: contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py 2012-05-28 14:11:55 UTC (rev 3415)
+++ contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py 2012-05-28 15:14:15 UTC (rev 3416)
@@ -199,15 +199,12 @@
# Some small vector routines
def vec_dist_point_plane(ne, gamma, v):
- a1 = ne * v - gamma
- a2 = ne.length
- s = abs(a1/a2)
- return s
+ return abs( (ne * v - gamma) / ne.length )
+
def vec_on_plane(n,atom,dist):
- scale = dist/n.length
- c = atom - n * scale
- return c.length
+
+ return (atom - n * (dist/n.length)).length
# -----------------------------------------------------------------------------
# Routines for shapes
@@ -217,10 +214,10 @@
regular = True
inner = True
- if(atom_pos.length > size/2.0):
+ if atom_pos.length > size/2.0:
regular = False
- if(atom_pos.length < ((size/2.0) - (size/2.0) * skin)):
+ if atom_pos.length < (size/2.0)*(1-skin):
inner = False
return (regular, inner)
@@ -260,6 +257,10 @@
def vec_in_pyramide_square(atom_pos, size, skin):
+ """
+ Please, leave all this! It tells the user the mathemetical way of
+ cutting out a pyramide with square base.
+
P1 = Vector((-size/2, 0.0, -size/4))
P2 = Vector((0.0, -size/2, -size/4))
P4 = Vector((size/2, 0.0, -size/4))
@@ -295,6 +296,22 @@
v52 = P2 - P4
n5 = v51.cross(v52)
g5 = -n5 * P2
+ """
+
+ # A much shorter way:
+ size2 = size * size
+ size3 = size2 * size
+ n1 = Vector((-1/4*size2, -1/4*size2, 1/4*size2))
+ g1 = -1/16 * size3
+ n2 = Vector(( 1/4*size2, 1/4*size2, 1/4*size2))
+ g2 = g1
+ n3 = Vector((-1/4*size2, 1/4*size2, 1/4*size2))
+ g3 = g1
+ n4 = Vector(( 1/4*size2, -1/4*size2, 1/4*size2))
+ g4 = g1
+ n5 = Vector(( 0.0, 0.0, -1/2*size2))
+ g5 = -1/8 * size3
+
distance_plane_1 = vec_dist_point_plane(n1, g1, atom_pos)
on_plane_1 = vec_on_plane(n1,atom_pos,distance_plane_1)
@@ -325,42 +342,20 @@
size = size * (1.0 - skin)
- P1 = Vector((-size/2, 0.0, -size/4))
- P2 = Vector((0.0, -size/2, -size/4))
- P4 = Vector((size/2, 0.0, -size/4))
- P5 = Vector((0.0, size/2, -size/4))
- P6 = Vector((0.0, 0.0, size/4))
-
- # First face
- v11 = P1 - P2
- v12 = P1 - P6
- n1 = v11.cross(v12)
- g1 = -n1 * P1
-
- # Second face
- v21 = P6 - P4
- v22 = P6 - P5
- n2 = v21.cross(v22)
- g2 = -n2 * P6
+ # As above
+ size2 = size * size
+ size3 = size2 * size
+ n1 = Vector((-1/4*size2, -1/4*size2, 1/4*size2))
+ g1 = -1/16 * size3
+ n2 = Vector(( 1/4*size2, 1/4*size2, 1/4*size2))
+ g2 = g1
+ n3 = Vector((-1/4*size2, 1/4*size2, 1/4*size2))
+ g3 = g1
+ n4 = Vector(( 1/4*size2, -1/4*size2, 1/4*size2))
+ g4 = g1
+ n5 = Vector(( 0.0, 0.0, -1/2*size2))
+ g5 = -1/8 * size3
- # Third face
- v31 = P1 - P5
- v32 = P1 - P6
- n3 = v32.cross(v31)
- g3 = -n3 * P1
-
- # Forth face
- v41 = P6 - P2
- v42 = P2 - P4
- n4 = v41.cross(v42)
- g4 = -n4 * P2
-
- # Fith base face
- v51 = P2 - P1
- v52 = P2 - P4
- n5 = v51.cross(v52)
- g5 = -n5 * P2
-
distance_plane_1 = vec_dist_point_plane(n1, g1, atom_pos)
on_plane_1 = vec_on_plane(n1,atom_pos,distance_plane_1)
distance_plane_2 = vec_dist_point_plane(n2, g2, atom_pos)
@@ -1059,6 +1054,8 @@
else:
z_displ = 0
+ print("Atom positions calculated")
+
return (atom_number_total, atom_number_drawn)
@@ -1133,6 +1130,8 @@
else:
z_displ = "even"
+ print("Atom positions calculated")
+
return (atom_number_total, atom_number_drawn)
@@ -1178,4 +1177,6 @@
if message[0] == True and message[1] == False:
atom_number_total += 1
+ print("Atom positions calculated")
+
return (atom_number_total, atom_number_drawn)
More information about the Bf-extensions-cvs
mailing list