[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30123] branches/soc-2010-rohith291991: Additions to cmesh.

Rohith B V rohith291991 at gmail.com
Thu Jul 8 18:52:12 CEST 2010


Revision: 30123
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30123
Author:   rohith291991
Date:     2010-07-08 18:52:12 +0200 (Thu, 08 Jul 2010)

Log Message:
-----------
Additions to cmesh. Includes (non working) Dijkstra from singularity vertices.

Modified Paths:
--------------
    branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h
    branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp
    branches/soc-2010-rohith291991/intern/comiso/intern/comiso.cpp
    branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c

Modified: branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h	2010-07-08 16:51:06 UTC (rev 30122)
+++ branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h	2010-07-08 16:52:12 UTC (rev 30123)
@@ -13,6 +13,7 @@
 //flags for CVert
 #define CV_MARKED (1)
 #define CV_SINGULARITY (1<<2)
+#define CV_VISITED (1<<3)
 
 struct CFace;
 struct CEdge;

Modified: branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp	2010-07-08 16:51:06 UTC (rev 30122)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp	2010-07-08 16:52:12 UTC (rev 30123)
@@ -366,8 +366,10 @@
 for(int i=0;i<totedge;i++)
 	{
 	
-	mesh->edges[i].p=solution.data[i+totface];
+	mesh->edges[i].p=(int)solution.data[i+totface];
 
+	printf("%d   %lf\n",mesh->edges[i].p,solution.data[i+totface]);
+
 	}
 
 
@@ -513,7 +515,7 @@
 								mesh->edges[l].faces[0]=index;
 								mesh->edges[l].faces[1]=nIndex;
 								mesh->edges[l].flag |= CE_MARKED;
-								mesh->edges[l].p=0;	
+								
 
 							}
 							
@@ -523,8 +525,7 @@
 								mesh->edges[l].faces[1]=index;
 								mesh->edges[l].faces[0]=nIndex;
 								mesh->edges[l].flag |= CE_MARKED;
-								mesh->edges[l].p=0;	
-
+							
 							}
 					
 				}
@@ -569,7 +570,7 @@
 
 				}
 			
-		}
+			}
 
 		currentFaces[i].resize(newFaces.size());
 
@@ -580,6 +581,13 @@
 
 //BFS from each singularity vertex
 
+for (int i=0;i<totedge;i++)
+	{
+	//if(mesh->edges[i].p!=0)
+		printf("i: %d p: %d\n",i,mesh->edges[i].p);
+		
+	}
+
 for (int i=0;i<totvert;i++)
 	{
 	
@@ -590,8 +598,8 @@
 		
 		int e=mesh->verts[i].edges[j];
 		psum+=mesh->edges[e].p;
-		//if(mesh->edges[e].p!=0)
-		printf("Edge: %d\n",e);	
+	//	if(mesh->edges[e].p!=0)
+	//	printf("Edge: %d\n",e);	
 
 		}
 
@@ -599,15 +607,78 @@
 		{
 		
 		mesh->verts[i].flag|=CV_SINGULARITY;
-		printf("Vertex: %d\n",mesh->verts[i].index);
+		//printf("Vertex: %d\n",mesh->verts[i].index);
 
+		}
+	}
 
+std::vector< std::vector <int> > currentVerts; //List of faces to expand for BFS/Dijkstra
+int numCV=0; //Number of constrained faces
+	int j=0;
+
+	for(int i=0;i<mesh->numVerts;i++)
+		if(mesh->verts[i].flag & CV_SINGULARITY)
+			{
+			mesh->verts[i].flag|= CV_VISITED;
+			numCV++;
+			}
+
+	currentVerts.resize(numCV);
+
+	for(int i=0;i<mesh->numVerts;i++)
+		if(mesh->verts[i].flag & CV_SINGULARITY)
+		{
+			currentVerts[j].push_back(mesh->verts[i].index);
+			j++;
 		}
 
+//Iterative Dijsktra on primal from each singularity
+terminate=1;
 
-	}
+while(terminate)
+	{
 
+	terminate=0;
 
+	for(int i=0;i<numCV;i++)
+	{
 
+		std::vector<int> newVerts;
+		newVerts.resize(0);
+
+		for(int j=0;j<currentVerts[i].size();j++)
+		{
+
+			terminate++;
+
+			int index=currentVerts[i][j];
+			CVert *vert=&(mesh->verts[index]);
+			
+			for(int k=0;k<vert->numNeighbors;k++)
+			{
+	
+				int nIndex=vert->neighbors[k];
+			
+				if(!(mesh->verts[nIndex].flag & CV_VISITED))
+				{
+
+				if(!(mesh->verts[nIndex].flag & CV_VISITED))
+				newVerts.push_back(nIndex);
+
+					mesh->verts[nIndex].flag &= !CV_VISITED;
+					
+				mesh->edges[mesh->verts[index].edges[k]].flag|=CE_MARKED;
+				}
+						
+		}
+
+		currentVerts[i].resize(newVerts.size());
+
+		for(int l=0;l<newVerts.size();l++)
+			currentVerts[i][l]=newVerts[l];
+
+	}
+}
+	}
 return 1;
 }
\ No newline at end of file

Modified: branches/soc-2010-rohith291991/intern/comiso/intern/comiso.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/comiso.cpp	2010-07-08 16:51:06 UTC (rev 30122)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/comiso.cpp	2010-07-08 16:52:12 UTC (rev 30123)
@@ -45,12 +45,7 @@
 	b=_B.col(dimn-1);
 	_b.resize(dimm);
 	
-	for(i=0;i<dimm;i++)
-		{
-		_b[i]=b[i]; 
-		std::cout<<_b[i]<<"\n";
-
-		}
+	
 	}
 
 /// function to print the equations corresponding to the matrices of an equation system

Modified: branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c
===================================================================
--- branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c	2010-07-08 16:51:06 UTC (rev 30122)
+++ branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c	2010-07-08 16:52:12 UTC (rev 30123)
@@ -218,13 +218,13 @@
 
 			 cm.faces[i].edges=MEM_mallocN((sizeof(int)*(cm.faces[i].numNeighbors)),"edges");
 				
-				printf("Face Index: %d\n",cm.faces[i].index);
+		/*		printf("Face Index: %d\n",cm.faces[i].index);
 				printf("Neighbors: ");
 				
 				for(j=0;j<cm.faces[i].numNeighbors;j++)
 					printf("%d ",cm.faces[i].neighbors[j]);
 				
-				printf("\n");
+				printf("\n");*/
 
 			}
 
@@ -269,18 +269,18 @@
 			cm.faces[3].theta=1.3;
 			cm.faces[10].flag |= CF_CONSTRAINED;
 			cm.faces[10].theta=2.35;
-			cm.faces[25].flag |= CF_CONSTRAINED;
+		/*	cm.faces[25].flag |= CF_CONSTRAINED;
  			cm.faces[25].theta=6.3;
 			cm.faces[50].flag |= CF_CONSTRAINED;
 			cm.faces[50].theta=3.346;
 			cm.faces[73].flag |= CF_CONSTRAINED;
-			cm.faces[73].theta=0.335;
+			cm.faces[73].theta=0.335;*/
 			
 			generateVoronoiCells(&cm);
 
 			
-			for(a=0;a<totface;a++)
-				printf("Group no: %d\n",cm.faces[a].group);
+		/*	for(a=0;a<totface;a++)
+				printf("Group no: %d\n",cm.faces[a].group);*/
 				
 
 			//TODO Get efficient and correct way to mark edges of cut graph





More information about the Bf-blender-cvs mailing list