[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37270] branches/soc-2011-avocado/blender: An operator is added to compute the eigenvalues of the dual graph of a selected mesh in edit mode .
shuvro sarker
shuvro05 at gmail.com
Mon Jun 6 21:50:35 CEST 2011
Revision: 37270
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37270
Author: shuvro
Date: 2011-06-06 19:50:35 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
An operator is added to compute the eigenvalues of the dual graph of a selected mesh in edit mode. The operator is also added in the User Interface.
Modified Paths:
--------------
branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d.py
branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c
branches/soc-2011-avocado/blender/source/blender/editors/mesh/bmesh_tools.c
branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_intern.h
branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_ops.c
Modified: branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d.py 2011-06-06 19:44:28 UTC (rev 37269)
+++ branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d.py 2011-06-06 19:50:35 UTC (rev 37270)
@@ -1591,6 +1591,9 @@
layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
layout.separator()
+
+ layout.operator("mesh.gen_seam")
+ layout.separator()
layout.operator("mesh.mark_sharp")
layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
Modified: branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-06 19:44:28 UTC (rev 37269)
+++ branches/soc-2011-avocado/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-06 19:50:35 UTC (rev 37270)
@@ -151,6 +151,7 @@
col.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map"
col.operator("mesh.mark_seam")
col.operator("mesh.mark_seam", text="Clear Seam").clear = True
+ col.operator("mesh.gen_seam")
col = layout.column(align=True)
col.label(text="Shading:")
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-06-06 19:44:28 UTC (rev 37269)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c 2011-06-06 19:50:35 UTC (rev 37270)
@@ -10,8 +10,121 @@
#include "autoseam_C_API.h"
#include <stdio.h>
#include <stdlib.h>
+#include "WM_types.h"
+#include "RNA_types.h"
+#include "RNA_define.h"
+#include "RNA_access.h"
+#include "DNA_object_types.h"
+
+#include "BKE_material.h"
+#include "BKE_context.h"
+#include "BKE_customdata.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_cdderivedmesh.h"
+#include "BKE_depsgraph.h"
+#include "BKE_global.h"
+//#include "BKE_library.h"
+#include "BKE_mesh.h"
+#include "BKE_object.h"
+#include "BKE_bmesh.h"
+#include "BKE_report.h"
+#include "BKE_tessmesh.h"
+//#include "BKE_texture.h"
+#include "BKE_main.h"
+
+#include "ED_screen.h"
+
+
+static int compute_dual_graph(BMesh *bm)
+{
+ BMEdge *eed;
+ BMIter iter, iter2;
+ BMLoop *l;
+ //int count = 0;
+
+
+ // float dummy_dual_graph[10][10];
+ int i,face_index[2];
+
+ //float dummy_dual_graph[10][10];
+ int k,m;
+
+ float **dummy_dual_graph = (float **) malloc(10* sizeof(float *));
+
+ for(k = 0; k < 10; k++ ){
+ dummy_dual_graph[k] = (float *) malloc(10 * sizeof(float));
+ }
+
+ for(k = 0; k < 10; k++){
+ for(m = 0; m < 10; m++){
+ dummy_dual_graph[k][m] = 0.0f;
+ }
+ }
+
+
+ for(eed = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, bm ); eed; eed= BMIter_Step(&iter))
+ {
+ /* if not boundary edge */
+ if(!BM_Boundary_Edge(eed)){
+
+ printf("index : %d\n", eed->head.index);
+ i = 0;
+
+ BM_ITER(l, &iter2, bm, BM_LOOPS_OF_EDGE, eed) {
+
+ face_index[i++] = l->f->head.index;
+ }
+ printf("%d %d", face_index[0], face_index[1]);
+ dummy_dual_graph[face_index[0]][face_index[1]] = 1;
+ }
+ else
+ {
+ printf("visiting boundary edge.\n");
+ }
+ }
+
+ calculate_eigen(dummy_dual_graph, 10);
+
+ free(dummy_dual_graph);
+ return 0;
+}
+
+
+static int editbmesh_gen_seam(bContext *C, wmOperator *op)
+{
+ Object *obedit= CTX_data_edit_object(C);
+ //Mesh *me= ((Mesh *)obedit->data);
+ BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
+ BMesh *bm = em->bm;
+ //BMEdge *eed;
+ //BMIter iter;
+
+ compute_dual_graph(bm);
+ printf("exec is working ...\n");
+ return 0;
+}
+
+
+void MESH_OT_gen_seam(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Generate Seam";
+ ot->idname= "MESH_OT_gen_seam";
+ ot->description= "generate seams automatically for a selected mesh.";
+
+ /* api callbacks */
+ ot->exec= editbmesh_gen_seam;
+ ot->poll= ED_operator_editmesh;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "dummy", 0, "Dummy", "");
+}
+
+
void BKE_use_autoseam()
{
float vec_in[3] = { 1.0f, 0.0f, 1.0f };
Modified: branches/soc-2011-avocado/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/soc-2011-avocado/blender/source/blender/editors/mesh/bmesh_tools.c 2011-06-06 19:44:28 UTC (rev 37269)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/bmesh_tools.c 2011-06-06 19:50:35 UTC (rev 37270)
@@ -101,7 +101,7 @@
#include "bmesh.h"
#include "editbmesh_bvh.h"
-#include "autoseam_tools.h"
+//#include "autoseam_tools.h"
@@ -1233,62 +1233,6 @@
}
-
-static int compute_dual_graph(BMesh *bm)
-{
- BMEdge *eed;
- BMIter iter, iter2;
- BMLoop *l;
- //int count = 0;
-
-
-// float dummy_dual_graph[10][10];
- int i,face_index[2];
-
- //float dummy_dual_graph[10][10];
- int k,m;
-
- float **dummy_dual_graph = (float **) malloc(10* sizeof(float *));
-
- for(k = 0; k < 10; k++ ){
- dummy_dual_graph[k] = (float *) malloc(10 * sizeof(float));
- }
-
- for(k = 0; k < 10; k++){
- for(m = 0; m < 10; m++){
- dummy_dual_graph[k][m] = 0.0f;
- }
- }
-
-
- for(eed = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, bm ); eed; eed= BMIter_Step(&iter))
- {
- /* if not boundary edge */
- if(!BM_Boundary_Edge(eed)){
-
- printf("index : %d\n", eed->head.index);
- i = 0;
-
- BM_ITER(l, &iter2, bm, BM_LOOPS_OF_EDGE, eed) {
-
- face_index[i++] = l->f->head.index;
- }
- printf("%d %d", face_index[0], face_index[1]);
- dummy_dual_graph[face_index[0]][face_index[1]] = 1;
- }
- else
- {
- printf("visiting boundary edge.\n");
- }
- }
-
- calculate_eigen(dummy_dual_graph, 10);
-
- free(dummy_dual_graph);
- return 0;
-}
-
-
/* ************************* SEAMS AND EDGES **************** */
static int editbmesh_mark_seam(bContext *C, wmOperator *op)
@@ -1324,8 +1268,8 @@
}
/* just as a demo to show call to autoseam */
- BKE_use_autoseam();
- compute_dual_graph(bm);
+ //BKE_use_autoseam();
+ //compute_dual_graph(bm);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
Modified: branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_intern.h
===================================================================
--- branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_intern.h 2011-06-06 19:44:28 UTC (rev 37269)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_intern.h 2011-06-06 19:50:35 UTC (rev 37270)
@@ -225,6 +225,7 @@
void MESH_OT_select_random(struct wmOperatorType *ot);
void MESH_OT_loop_multi_select(struct wmOperatorType *ot);
void MESH_OT_mark_seam(struct wmOperatorType *ot);
+void MESH_OT_gen_seam(struct wmOperatorType *ot);
void MESH_OT_mark_sharp(struct wmOperatorType *ot);
void MESH_OT_vertices_smooth(struct wmOperatorType *ot);
void MESH_OT_noise(struct wmOperatorType *ot);
Modified: branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_ops.c
===================================================================
--- branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_ops.c 2011-06-06 19:44:28 UTC (rev 37269)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/mesh_ops.c 2011-06-06 19:50:35 UTC (rev 37270)
@@ -130,6 +130,7 @@
WM_operatortype_append(MESH_OT_select_similar);
WM_operatortype_append(MESH_OT_loop_multi_select);
WM_operatortype_append(MESH_OT_mark_seam);
+ WM_operatortype_append(MESH_OT_gen_seam);
WM_operatortype_append(MESH_OT_mark_sharp);
WM_operatortype_append(MESH_OT_vertices_smooth);
WM_operatortype_append(MESH_OT_noise);
More information about the Bf-blender-cvs
mailing list