[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38382] branches/soc-2011-avocado/blender/ source/blender/editors/mesh/autoseam_tools.c: Fix in stretch minimization process and implementation of average strecth calculation and maximum stretch calculation for a mesh .
shuvro sarker
shuvro05 at gmail.com
Thu Jul 14 06:17:38 CEST 2011
Revision: 38382
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38382
Author: shuvro
Date: 2011-07-14 04:17:37 +0000 (Thu, 14 Jul 2011)
Log Message:
-----------
Fix in stretch minimization process and implementation of average strecth calculation and maximum stretch calculation for a mesh.
Modified Paths:
--------------
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c
Modified: branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c
===================================================================
--- branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c 2011-07-14 03:28:31 UTC (rev 38381)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c 2011-07-14 04:17:37 UTC (rev 38382)
@@ -34,6 +34,7 @@
+
/* ------------------------ Code from Andrea ------------------------ */
static void autoseam_clear_seam(BMesh *bm)
{
@@ -315,7 +316,7 @@
}
-float stretch_of_mesh(bContext *C)
+float total_stretch_of_mesh(bContext *C)
{
int i;
Scene *scene= CTX_data_scene(C);
@@ -339,7 +340,35 @@
return total_stretch;
}
+float average_stretch_of_mesh(bContext *C)
+{
+ Object *obedit= CTX_data_edit_object(C);
+ BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
+ return (float)(total_stretch_of_mesh(C)/em->tottri);
+ }
+float maximum_stretch_of_mesh(bContext *C)
+{
+ int i;
+ float max_stretch = -FLT_MAX;
+ float temp;
+ Scene *scene= CTX_data_scene(C);
+ Object *obedit= CTX_data_edit_object(C);
+ BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
+ BMesh *bm = em->bm;
+
+ ED_unwrap_lscm(scene, obedit, TRUE);
+
+ for (i=0; i < em->tottri; i++) {
+ temp = stretch_of_triangulated_face(em->looptris[i], bm);
+ if(temp > max_stretch){
+ max_stretch = temp;
+ }
+ }
+
+ return max_stretch;
+}
+
int generate_seam_recursive(BMesh *bm, AUTOSEAM_Adjacency adj, AUTOSEAM_Adjacency adj_big, int recursion_depth, bContext *C, float stretch)
{
int s;
@@ -352,16 +381,37 @@
AUTOSEAM_Adjacency adj_plus;
AUTOSEAM_Adjacency adj_minus;
+
if(stretch < 0.0){
- stretch = stretch_of_mesh(C);
+ //stretch = stretch_of_mesh(C);
+ stretch = FLT_MAX;
}
+ /* This is for total_stretch */
else{
- float temp = stretch_of_mesh(C);
+ float temp = total_stretch_of_mesh(C);
/* stretch is increasing, so stop here*/
if(temp > stretch) return 0;
else stretch = temp;
}
+ /* This is for average stretch */
+// else{
+// float temp = average_stretch_of_mesh(C);
+// /* stretch is increasing, so stop here*/
+// if(temp > stretch) return 0;
+// else stretch = temp;
+// }
+//
+// /* This is for maximum stretch of the mesh */
+// else{
+// float temp = maximum_stretch_of_mesh(C);
+// /* stretch is increasing, so stop here*/
+// if(temp > stretch) return 0;
+// else stretch = temp;
+// }
+
+
+
if(!recursion_depth) {
autoseam_delete_adjacency(adj);
return 0;
More information about the Bf-blender-cvs
mailing list