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

Rohith B V rohith291991 at gmail.com
Wed Jun 23 20:28:34 CEST 2010


Revision: 29659
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29659
Author:   rohith291991
Date:     2010-06-23 20:28:34 +0200 (Wed, 23 Jun 2010)

Log Message:
-----------
Additions to CMesh. Does not compile.

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

Modified: branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp	2010-06-23 17:40:17 UTC (rev 29658)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp	2010-06-23 18:28:34 UTC (rev 29659)
@@ -118,6 +118,7 @@
 // Uses CoMiSo
 
 int a;
+CVect solution;
 Comiso solver;
 int totedge,totface,totvert;
 totvert=mesh->numVerts;
@@ -126,32 +127,88 @@
 
 solver.m=totface+totedge;
 solver.n=totface+totedge+1;
-solver.mnnz=(solver.n*4);
+solver.mnnz=(solver.n*8);
 
-solver.mdata=MEM_mallocN(sizeof(MValue)*solver.mnnz, "matData");
+solver.mdata=(MValue *)MEM_mallocN(sizeof(MValue)*solver.mnnz, "mdata");
 
 int t=0;
-for(int i=0;i<solver.m;i++)
+
+//TODO set solver.mdata
+//the variables are stored as all thetas followed by all period jumps
+
+
+//TODO makes constraints on face theta's and edge p's
+//call generateConstraints(CMesh* mesh) 
+
+
+for(int i=0;i<totface;i++)
 	{
-	for(int j=0;j<solver.n;j++)
+    
+	int n=mesh->faces[i].numNeighbors;
+
+		solver.mdata[t].i=i;
+		solver.mdata[t].j=i;
+		solver.mdata[t].value=2*n;
+		t++;
+
+    double totkappa=0;
+
+	for(int j=0;j<n;j++)
 		{
+				
+		solver.mdata[t].i=i;
+		solver.mdata[t].j=mesh->faces[i].neighbors[j];
+		solver.mdata[t].value=-2;
+		t++;
 
-		t=0;
+		//TODO totkappa+= something (calculate)
+
+		//TODO for each edge
+		//solver.mdata[t].i=i
+		//solver.mdata[t].j=totface+index of edge
+		//use *edges
+		//solver.mdata[t].value=+ or - pij * 3.1415926; depending on match
+		//t++;
 		
+
+		}
+
 	solver.mdata[t].i=i;
-	solver.mdata[t].j=j;
-	solver.mdata[t].value=1; //get value here
+	solver.mdata[t].j=solver.n-1;
+	solver.mdata[t].value=-2*totkappa;
 	t++;
 
-		}
+	}
+
+for (int i=0;i<solver.n-totface;i++)
+	{
 	
+	solver.mdata[t].i=i;
+	solver.mdata[t].j=totface+mesh->edges[i].index;
+	solver.mdata[t].value=3.1415926*3.1415926*0.5*mesh->edges[i].p;
+	t++;
+
+	solver.mdata[t].i=i;
+	solver.mdata[t].j=0;// <-- dummy, change to index of face 1
+	solver.mdata[t].value=3.1415926;//<--- dummy, change to actual face 1's theta *3.1415926
+	t++;
+
+	solver.mdata[t].i=i;
+	solver.mdata[t].j=0;// <-- dummy, change to index of face 2
+	solver.mdata[t].value=3.1415926;//<--- dummy, change to actual face 2's theta * -3.1415926
+	t++;
+
+	solver.mdata[t].i=i;
+	solver.mdata[t].j=solver.n-1;
+	solver.mdata[t].value=0; //<--- dummy, change to kappa of edge * -3.1415926
+	t++;
+
 	}
-//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");
+solver.rdata=(int *)MEM_mallocN(sizeof(int)*totedge, "rdata");
 
 for(a=0;a<totedge;a++)
 	{
@@ -159,13 +216,72 @@
 	}
 
 //TODO set constraint data
-//solver.c=
-//solver.cnnz=
-//solver.cdata=
 
-//MISolve(solver,1e-7,10000,20);
+t=0;
 
+for(int i=0;i<totface;i++)
+	{
+	
+	if(mesh->faces[i].flag &CF_CONSTRAINED)
+		{
+		t++;
+		}
+	}
 
+for(int i=0;i<totedge;i++)
+	{
+	
+	if(mesh->edges[i].flag & CE_MARKED)
+		{
+		t++;		
+		}
+
+	}
+
+solver.c=t;
+solver.cnnz=2*solver.c;
+solver.cdata=(MValue *)MEM_mallocN(sizeof(MValue)*solver.cnnz, "cdata");
+
+t=0;
+for(int i=0;i<totface;i++)
+	{
+	
+	if(mesh->faces[i].flag & CF_CONSTRAINED)
+		{
+		solver.cdata[t].i = i;
+		solver.cdata[t].j = solver.n-1;
+		solver.cdata[t].value = mesh->faces[i].theta;
+		t++;
+		}
+	}
+
+for(int i=0;i<totedge;i++)
+	{
+	
+	if(mesh->edges[i].flag & CE_MARKED)
+		{
+		solver.cdata[t].i = i + totface;
+		solver.cdata[t].j = solver.n-1;
+		solver.cdata[t].value = mesh->edges[i].p;
+		t++;
+		}
+	}
+
+solution = MISolve(solver,1e-7,10000,20);
+
+for(int i=0;i<totface;i++)
+	{
+	mesh->faces[i].theta=solution.data[i];
+	
+	}
+
+for(int i=0;i<totedge;i++)
+	{
+	
+	mesh->edges[i].p=solution.data[i+totface];
+
+	}
+
 if(0)
 {
 return 0;

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-23 17:40:17 UTC (rev 29658)
+++ branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c	2010-06-23 18:28:34 UTC (rev 29659)
@@ -63,7 +63,6 @@
   
 	Comiso solver;
 	CMesh cm;
-	CVect solution;
 	QuadrangulateModifierData *dmd = (QuadrangulateModifierData*) md;
 	DerivedMesh *dm = derivedData, *result = NULL;
 	MVert *mvert;





More information about the Bf-blender-cvs mailing list