[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29534] branches/soc-2010-rohith291991: Small number of changes.

Rohith B V rohith291991 at gmail.com
Fri Jun 18 00:20:14 CEST 2010


Revision: 29534
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29534
Author:   rohith291991
Date:     2010-06-18 00:20:14 +0200 (Fri, 18 Jun 2010)

Log Message:
-----------
Small number of changes. Some hacks in the drawing code to draw the cut graph of the mesh. Some errors in the BFS code were fixed.

Modified Paths:
--------------
    branches/soc-2010-rohith291991/intern/comiso/SConscript
    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/blenkernel/intern/cdderivedmesh.c
    branches/soc-2010-rohith291991/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c

Modified: branches/soc-2010-rohith291991/intern/comiso/SConscript
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/SConscript	2010-06-17 22:06:18 UTC (rev 29533)
+++ branches/soc-2010-rohith291991/intern/comiso/SConscript	2010-06-17 22:20:14 UTC (rev 29534)
@@ -6,7 +6,7 @@
 sources = env.Glob('intern/*.cpp')
 
 incs = ''
-incs+=" ../../extern/Eigen2/Eigen"
+incs+=" #/intern/guardedalloc ../../extern/Eigen2/Eigen"
 
 defs=''
 

Modified: branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h	2010-06-17 22:06:18 UTC (rev 29533)
+++ branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h	2010-06-17 22:20:14 UTC (rev 29534)
@@ -40,6 +40,7 @@
 typedef struct CFace{
 
 int * neighbors; //Indices of all neighboring faces
+int * edges; //Indices of the edges, corresponding to neighbors
 int index; //Index of the face
 int group; //Group index of the face
 int flag; //Flag for various purposes

Modified: branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp	2010-06-17 22:06:18 UTC (rev 29533)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp	2010-06-17 22:20:14 UTC (rev 29534)
@@ -1,121 +1,156 @@
 #include "../extern/CMesh.h"
 #include <vector>
+#include "MEM_guardedalloc.h"
 
-int generateVoronoiCells(CMesh* mesh)
-{
-
-	std::vector<std::vector <int>> currentFaces; //List of faces to expand for BFS/Dijkstra
-	int numCF=0; //Number of constrained faces
-	int j=0;
-
-	for(int i=0;i<mesh->numFaces;i++)
-		if(mesh->faces[i].flag & CF_CONSTRAINED)
-			{
-			mesh->faces[i].flag|= CF_VISITED;
-			mesh->faces[i].group=mesh->faces[i].index;	
-			numCF++;
-			}
-
-	currentFaces.resize(numCF);
-
-	for(int i=0;i<mesh->numFaces;i++)
-		if(mesh->faces[i].flag & CF_CONSTRAINED)
-		{
-			currentFaces[j].push_back(mesh->faces[i].index);
-			j++;
-		}
-
-//Iterative BFS
-int terminate=1;
-
-while(terminate)
-{
-
-	terminate=0;
-
-	for(int i=0;i<numCF;i++)
-	{
-
-		std::vector<int> newFaces;
-		newFaces.resize(0);
-
-		for(int j=0;j<currentFaces[i].size();j++)
-		{
-
-			terminate++;
-
-			int index=currentFaces[i][j];
-			CFace *face=&(mesh->faces[index]);
-			
-			for(int k=0;k<face->numNeighbors;k++)
-			{
-	
-				int nIndex=face->neighbors[k];
-				
-				if(!(mesh->faces[nIndex].flag & CF_VISITED))
-				{
-
-				mesh->faces[nIndex].flag |= CF_VISITED;
-				mesh->faces[nIndex].group=face->group;
-				newFaces.push_back(nIndex);
-
-				//Mark common vertices
-				for(int l=0;l<4;l++)
-					for(int k=0;k<4;k++)
-						if( (mesh->faces[index].v[l] == mesh->faces[nIndex].v[k])
-						&& mesh->faces[index].v[k]!=-1)
-							mesh->verts[mesh->faces[index].v[l]].flag |= CV_MARKED;
-
-				}
-
-			}
-			
-		}
-
-		currentFaces[i].resize(newFaces.size());
-
-		for(int l=0;l<newFaces.size();l++)
-			currentFaces[i][l]=newFaces[l];
-
-	}
-}
-
-// Mark visited edges
-// Remaining edges are in cut graph
-
-for(int i=0;i<mesh->numEdges;i++)
-{
-	int v1=mesh->edges[i].v[0];
-	int v2=mesh->edges[i].v[1];
-
-	if(mesh->verts[v1].flag & CV_MARKED
-	&& mesh->verts[v2].flag & CV_MARKED )
-		{
-		mesh->edges[i].flag |= CE_MARKED;
-		mesh->edges[i].p=0;
-		}
-
-}
-
-//Dummy error condition
-if(0)
-{
-return 0;
-}
-
-return 1;
-}
-
-//TODO
-// Uses CoMiSo
-
-int generateDirectionField(CMesh* mesh)
-{
-
-if(0)
-{
-return 0;
-}
-
-return 1;
-}
+int generateVoronoiCells(CMesh* mesh)
+{
+
+	std::vector< std::vector <int> > currentFaces; //List of faces to expand for BFS/Dijkstra
+	int numCF=0; //Number of constrained faces
+	int j=0;
+
+	for(int i=0;i<mesh->numFaces;i++)
+		if(mesh->faces[i].flag & CF_CONSTRAINED)
+			{
+			mesh->faces[i].flag|= CF_VISITED;
+			mesh->faces[i].group=mesh->faces[i].index;	
+			numCF++;
+			}
+
+	currentFaces.resize(numCF);
+
+	for(int i=0;i<mesh->numFaces;i++)
+		if(mesh->faces[i].flag & CF_CONSTRAINED)
+		{
+			currentFaces[j].push_back(mesh->faces[i].index);
+			j++;
+		}
+
+//Iterative BFS
+int terminate=1;
+
+while(terminate)
+{
+
+	terminate=0;
+
+	for(int i=0;i<numCF;i++)
+	{
+
+		std::vector<int> newFaces;
+		newFaces.resize(0);
+
+		for(int j=0;j<currentFaces[i].size();j++)
+		{
+
+			terminate++;
+
+			int index=currentFaces[i][j];
+			CFace *face=&(mesh->faces[index]);
+			
+			for(int k=0;k<face->numNeighbors;k++)
+			{
+	
+				int nIndex=face->neighbors[k];
+				
+				if(!(mesh->faces[nIndex].flag & CF_VISITED)||(mesh->faces[nIndex].group==face->group))
+				{
+
+				if(!(mesh->faces[nIndex].flag & CF_VISITED))
+				newFaces.push_back(nIndex);
+
+				mesh->faces[nIndex].flag |= CF_VISITED;
+				mesh->faces[nIndex].group=face->group;
+
+				int v[2];
+                int cv=0;
+				//Mark common vertices
+				for(int l=0;l<4;l++)
+					for(int k=0;k<4;k++)
+						if( (mesh->faces[index].v[l] == mesh->faces[nIndex].v[k])
+						&& mesh->faces[index].v[k]!=-1)
+							{
+							v[cv]=mesh->faces[index].v[l]; 
+							cv++;
+							}
+
+				for(int l=0;l<mesh->numEdges;l++)
+				{
+					if(mesh->edges[l].v[0]==v[0]&&mesh->edges[l].v[1]==v[1]
+					   || mesh->edges[l].v[0]==v[1]&&mesh->edges[l].v[1]==v[0] )
+						{
+							mesh->edges[l].flag |= CE_MARKED;
+							mesh->edges[l].p=0;	
+						}
+					
+				}
+
+
+				}
+
+			}
+			
+		}
+
+		currentFaces[i].resize(newFaces.size());
+
+		for(int l=0;l<newFaces.size();l++)
+			currentFaces[i][l]=newFaces[l];
+
+	}
+}
+
+//TODO Mark faces of edges and egdes of faces
+
+//Dummy error condition
+if(0)
+{
+return 0;
+}
+
+return 1;
+}
+
+int generateDirectionField(CMesh* mesh)
+{
+
+//TODO
+// Uses CoMiSo
+
+int a;
+Comiso solver;
+int totedge,totface,totvert;
+totvert=mesh->numVerts;
+totedge=mesh->numEdges;
+totface=mesh->numFaces;
+
+solver.m=totface+totedge+1;
+solver.n=totface+totedge;
+solver.mnnz=(solver.n*4);
+//TODO set solver.mdata
+//the variables are stored as all thetas followed by all period jumps
+
+//set period jumps to be rounded
+solver.nr=totedge;
+solver.rdata=(int *)MEM_mallocN(sizeof(int)*totedge, "roundData");
+
+for(a=0;a<totedge;a++)
+	{
+    solver.rdata[a]=a+totface;	
+	}
+
+//TODO set constraint data
+//solver.c=
+//solver.cnnz=
+//solver.cdata=
+
+//MISolve(solver,1e-7,10000,20);
+
+
+if(0)
+{
+return 0;
+}
+
+return 1;
+}

Modified: branches/soc-2010-rohith291991/intern/comiso/intern/comiso.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/comiso.cpp	2010-06-17 22:06:18 UTC (rev 29533)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/comiso.cpp	2010-06-17 22:20:14 UTC (rev 29534)
@@ -50,7 +50,6 @@
 	b=_A.col(dimn-1);
 	_b.resize(dimn-1);
 
-
 	MatrixXd tA=_A;
 
 	_A.resize( dimn-1, dimn-1);

Modified: branches/soc-2010-rohith291991/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2010-rohith291991/source/blender/blenkernel/intern/cdderivedmesh.c	2010-06-17 22:06:18 UTC (rev 29533)
+++ branches/soc-2010-rohith291991/source/blender/blenkernel/intern/cdderivedmesh.c	2010-06-17 22:20:14 UTC (rev 29534)
@@ -318,8 +318,14 @@
 		DEBUG_VBO( "Using legacy code. cdDM_drawEdges\n" );
 		glBegin(GL_LINES);
 		for(i = 0; i < dm->numEdgeData; i++, medge++) {
-			if((drawAllEdges || (medge->flag&ME_EDGEDRAW))
-			   && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
+			//if((drawAllEdges || (medge->flag&ME_EDGEDRAW))
+			  // && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) 
+			if(medge->flag & ME_SHARP)
+				glColor3f(1,0,0);
+			else
+				glColor3f(0,0,0);
+				{
+				  // glColor3f(1,0,0);
 				glVertex3fv(mvert[medge->v1].co);
 				glVertex3fv(mvert[medge->v2].co);
 			}
@@ -475,7 +481,7 @@
 						glNormal3fv(nor);
 					}
 				}
-
+			
 				PASSVERT(mface->v1);
 				PASSVERT(mface->v2);
 				PASSVERT(mface->v3);
@@ -1275,6 +1281,7 @@
 			orig = i;
 
 		if(!setDrawOptions || setDrawOptions(userData, orig)) {
+			glColor3f(1,0,0);
 			glVertex3fv(vert[edge->v1].co);
 			glVertex3fv(vert[edge->v2].co);
 		}

Modified: branches/soc-2010-rohith291991/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2010-rohith291991/source/blender/editors/space_view3d/drawobject.c	2010-06-17 22:06:18 UTC (rev 29533)
+++ branches/soc-2010-rohith291991/source/blender/editors/space_view3d/drawobject.c	2010-06-17 22:20:14 UTC (rev 29534)
@@ -2553,7 +2553,7 @@
 			glEnable(GL_LINE_STIPPLE);
 			glLineStipple(1, 0x8888);
 
-			dm->drawEdges(dm, 1, 0);
+			dm->drawEdges(dm, 1, 1);
 
 			bglPolygonOffset(rv3d->dist, 0.0);
 			glDepthMask(1);

Modified: branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c
===================================================================
--- branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c	2010-06-17 22:06:18 UTC (rev 29533)
+++ branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c	2010-06-17 22:20:14 UTC (rev 29534)
@@ -155,7 +155,7 @@
 		cm.faces[a].neighbors = NULL;
 		cm.faces[a].numNeighbors = 0;
 		cm.faces[a].index = a;
-		cm.faces[a].group = 0;
+		cm.faces[a].group = -1;
 		cm.faces[a].flag = 0;
 		cm.faces[a].theta = 0;
 		
@@ -183,7 +183,7 @@
 			  if(count>=2)
 			   {
 				   if(cm.faces[i].neighbors==NULL)
-					    cm.faces[i].neighbors=MEM_mallocN((sizeof(int)*(++cm.faces[i].numNeighbors)),"neighbors");
+					   cm.faces[i].neighbors=MEM_mallocN((sizeof(int)*(++cm.faces[i].numNeighbors)),"neighbors");
 				   else
 						cm.faces[i].neighbors=MEM_reallocN(cm.faces[i].neighbors,(sizeof(int)*(++cm.faces[i].numNeighbors)));
 
@@ -203,6 +203,8 @@
 
 			for(i=0;i<totface;i++)
 			{
+
+			 cm.faces[i].edges=MEM_mallocN((sizeof(int)*(cm.faces[i].numNeighbors)),"edges");
 				
 				printf("Face Index: %d\n",cm.faces[i].index);
 				printf("Neighbors: ");
@@ -216,6 +218,9 @@
 
 			cm.faces[3].flag |= CF_CONSTRAINED;
 			cm.faces[10].flag |= CF_CONSTRAINED;
+			cm.faces[25].flag |= CF_CONSTRAINED;
+			cm.faces[50].flag |= CF_CONSTRAINED;
+			cm.faces[73].flag |= CF_CONSTRAINED;
 			
 			generateVoronoiCells(&cm);
 
@@ -227,7 +232,12 @@
 
 			for(a=0;a<totedge;a++)
 				if(!(cm.edges[a].flag &	CE_MARKED))
+					{
 					printf("Edge not marked: %d\n",cm.edges[a].index);
+					medge[a].flag |=ME_SHARP;
+					}
+
+			generateDirectionField(&cm);
 			

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list