[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30338] branches/soc-2010-rohith291991: Adding halfedge data structure.

Rohith B V rohith291991 at gmail.com
Wed Jul 14 21:59:46 CEST 2010


Revision: 30338
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30338
Author:   rohith291991
Date:     2010-07-14 21:59:32 +0200 (Wed, 14 Jul 2010)

Log Message:
-----------
Adding halfedge data structure. Does not compile.

Modified Paths:
--------------
    branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h
    branches/soc-2010-rohith291991/intern/comiso/extern/uv.h
    branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp
    branches/soc-2010-rohith291991/intern/comiso/intern/uv.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-14 19:01:40 UTC (rev 30337)
+++ branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h	2010-07-14 19:59:32 UTC (rev 30338)
@@ -19,12 +19,16 @@
 struct CFace;
 struct CEdge;
 struct CVert;
+struct HEdge;
+struct HFace;
+struct HVert;
 
 typedef struct CVert
 {
 
 int * neighbors; //Indices of all neighboring vertices
 int * edges; //Indices of the edges, corresponding to neighbors
+int vvar; //Vertex duplications
 int index; //Index of the vertex
 int flag; //Flag for various purposes (if needed)
 int numNeighbors; //Number of neighboring vertices
@@ -59,6 +63,7 @@
 
 int * neighbors; //Indices of all neighboring faces
 int * edges; //Indices of the edges, corresponding to neighbors
+int vvar[3]; //Vertex variable
 int index; //Index of the face
 int group; //Group index of the face
 int flag; //Flag for various purposes
@@ -80,6 +85,70 @@
 
 }CMesh;
 
+ 
+typedef struct HEdge
+    {
+
+        Hvert* vertex;   // vertex at the end of the half-edge
+        Hedge* opposite;   // oppositely oriented adjacent half-edge 
+        Hface* face;   // face the half-edge borders
+        Hedge* next;   // next half-edge around the face
+		Hedge* previous;   // next half-edge around the face
+
+		double uflux;//Flux of u through edge from face[0] to face[1]
+		double vflux;//Flux of v through edge from face[0] to face[1]
+		//Optimization variables
+		int usign; 
+		int vsign;
+		int uvar;
+		int vvar;
+		int tvar;
+		int test;
+		double kappa;//Correction angle between two adjacent faces
+		int index; //Index of the edge
+		int p;// Period Jump for v1-v2. For v2-v1 it is -p
+		int flag; //Flag for various purposes (eg. Cut graph)
+		//int v[2]; // Indices of vertices
+    
+    }HEdge;
+
+typedef struct HVert
+    {
+        double co[3]; //coordinates of the vertex
+        Hedge* edge; //halfedge associated with the vertex (chosen as right)
+
+		int index; //Index of the vertex
+		int flag; //Flag for various purposes (if needed)
+		double u; //u Parameter
+		double v; //v Parameter
+		            
+    }HVert;
+
+typedef struct HFace
+    {
+	Hedge* edge; //halfedge associated with the face (random)
+
+	double normal[3]; //normal (for direction purposes)
+	int index; //Index of the face
+	//int group; //Group index of the face
+	int flag; //Flag for various purposes
+	double theta; //Angle that the principle direction field makes with the edge represented by v1-v2
+	double ut[3]; //Direction of u field
+	double vt[3]; //Direction of v field
+		            
+    }HFace;
+
+typedef struct HMesh
+{
+
+HVert* verts; //Vertex data
+HEdge * edges; //Edge data
+HFace * faces; //Face data
+int numFaces,numEdges,numVerts; // Self explanatory
+
+}HMesh;
+
+ 
 #ifdef __cplusplus
 extern "C"  {
 #endif

Modified: branches/soc-2010-rohith291991/intern/comiso/extern/uv.h
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/extern/uv.h	2010-07-14 19:01:40 UTC (rev 30337)
+++ branches/soc-2010-rohith291991/intern/comiso/extern/uv.h	2010-07-14 19:59:32 UTC (rev 30338)
@@ -3,14 +3,15 @@
 
 #include "CMesh.h"
 
-#ifdef __cplusplus
-extern "C"  {
-#endif
+#ifdef __cplusplus
+extern "C"  {
+#endif
 
 void mi_quad_param(CMesh *mesh,double n_quads);
-
-#ifdef __cplusplus
- }
-#endif
-
+void copyHC(HMesh hm, CMesh cm);
+
+#ifdef __cplusplus
+ }
+#endif
+
 #endif
\ No newline at end of file

Modified: branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp	2010-07-14 19:01:40 UTC (rev 30337)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp	2010-07-14 19:59:32 UTC (rev 30338)
@@ -747,11 +747,14 @@
 
 
 	for(int i=0;i<mesh->numVerts;i++)
+		{
+		mesh->verts[i].flag &= !CV_VISITED;
 		if(mesh->verts[i].flag & CV_LEAF)
 			{
 			mesh->verts[i].flag|= CV_VISITED;
 			numCV++;
 			}
+		}
 
 	currentVerts.resize(numCV);
 

Modified: branches/soc-2010-rohith291991/intern/comiso/intern/uv.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/uv.cpp	2010-07-14 19:01:40 UTC (rev 30337)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/uv.cpp	2010-07-14 19:59:32 UTC (rev 30338)
@@ -21,7 +21,7 @@
 
 
 
-void compute_edge_flux(CMesh *mesh, bool curl_correction = false) { //with optional curl correction
+void compute_edge_flux(HMesh *mesh, bool curl_correction = false) { //with optional curl correction
   
 	int a;
 CVect solution;
@@ -221,8 +221,137 @@
     }
   }*/
 }
+extern "C"
+void copyHC(HMesh hm, CMesh cm)
+	{
+
+	int totedge,totface,totvert;
+	totvert=cm.numVerts;
+	totedge=cm.numEdges;
+	totface=cm.numFaces;
+
+		int i=0;
+		hm.numEdges=totedge*2;
+			hm.numFaces=totface;
+			hm.numVerts=totvert;
+			hm.edges=MEM_mallocN((sizeof(HEdge)*(totedge*2)),"edges");
+			hm.verts=MEM_mallocN((sizeof(HVert)*(totvert)),"verts");
+			hm.faces=MEM_mallocN((sizeof(HFace)*(totface)),"faces");
+
+			for(i=0;i<hm.numFaces;i++)
+				{
+				hm.faces[i].edge=NULL;
+				hm.faces[i].index=i;
+				hm.faces[i].flag;=cm.faces[i].flag; 
+				hm.faces[i].theta=cm.faces[i].theta;
+				}
+
+			for(i=0;i<totedge;i++)
+				{
+				hm.edges[2*i].index=2*i;
+				hm.edges[2*i+1].index=2*i+1;
+				hm.edges[2*i].flag=cm.edges[i].flag; 
+				hm.edges[2*i+1].flag=cm.edges[i].flag; 
+				hm.edges[2*i].kappa=cm.edges[i].kappa; 
+				hm.edges[2*i+1].kappa=-cm.edges[i].kappa; 
+				hm.edges[2*i].p=cm.edges[i].p; 
+				hm.edges[2*i+1].p=cm.edges[i].p; 
+					
+				}
+
+			for(i=0;i<hm.numEdges;i++)
+				{
+				hm.edges[i].prev=NULL;
+				hm.edges[i].next=NULL;
+				hm.edges[i].vertex=NULL;
+				hm.edges[i].opposite=NULL;
+				hm.edges[i].face=NULL;
+				
+				hm.edges[i].uflux=0;
+				hm.edges[i].vflux=0;
+				hm.edges[i].usign=1;
+				hm.edges[i].vsign=1;
+			hm.edges[i].uvar=-1;
+			hm.edges[i].vvar=-1;
+			hm.edges[i].tvar=-1;
+			hm.edges[i].test=-1;
+				}
+
+for(i=0;i<totvert;i++)
+	{
+	
+		hm.verts[i].co[0]=cm.verts[i].co[0];
+		hm.verts[i].co[1]=cm.verts[i].co[1];
+		hm.verts[i].co[2]=cm.verts[i].co[2];
+		hm.verts[i].index=i;
+		hm.verts[i].flag=cm.verts[i].flag;
+		hm.verts[i].u=0;
+		hm.verts[i].v=0;
+	
+	}
+
+for (int j=0;j<totface;j++)
+	{
+	
+	int v[3];
+	int e[3];
+	v[0]=cm.faces[j].v[0];
+	v[1]=cm.faces[j].v[1];
+	v[2]=cm.faces[j].v[2];
+
+	for (int t=0; t<3;t++)
+		{
+		if((cm.faces[j].v[2]==cm[cm.edges[t]].v[0]] && cm.faces[j].v[1]==cm[cm.edges[t]].v[0]] )|| 
+			(cm.faces[j].v[1]==cm[cm.edges[t]].v[1]] && cm.faces[j].v[2]==cm[cm.edges[t]].v[0]] ))
+			{
+			e[0]=cm.edges[t].index;
+			}
+		else if((cm.faces[j].v[1]==cm[cm.edges[t]].v[0]] && cm.faces[j].v[0]==cm[cm.edges[t]].v[0]] )|| 
+			(cm.faces[j].v[0]==cm[cm.edges[t]].v[1]] && cm.faces[j].v[1]==cm[cm.edges[t]].v[0]] ))
+			{
+			e[1]=cm.edges[t].index;
+			}
+		else if((cm.faces[j].v[0]==cm[cm.edges[t]].v[0]] && cm.faces[j].v[2]==cm[cm.edges[t]].v[0]] )|| 
+			(cm.faces[j].v[2]==cm[cm.edges[t]].v[1]] && cm.faces[j].v[0]==cm[cm.edges[t]].v[0]] ))
+			{
+			e[2]=cm.edges[t].index;
+			}
+		}
+	
+	hm.faces[j].edge=&hm.edges[3*j];
+
+	for(int t=0;t<3;t++)
+		{
+		hm.edges[3*j+t].face=&hm.faces[j];
+		hm.edges[3*j+t].prev=&hm.edges[3*j+(t+2)%3];
+		hm.edges[3*j+t].next=&hm.edges[3*j+(t+1)%3];	
+		hm.edges[3*j+t].flag=cm.edges[e[t]].flag;
+		hm.edges[3*j+t].vertex=&hm.verts[cm.faces[j].v[2-t]];
+		hm.verts[cm.faces[j].v[2-t]].edge=&hm.edges[3*j+t].vertex;
+
+		int sign=1;
+		if(cm.faces[j].index!=cm.edges[e[t]].faces[0])
+			sign=-1;
+
+		hm.edges[3*j+t].p=sign*cm.edges[e[t]].p;
+		hm.edges[3*j+t].kappa=sign*cm.edges[e[t]].kappa;
+
+
+		}
+
+	
+
+	
+	}
+
+
+
+	
+	
+	}
+
 extern "C" 
-void mi_quad_param(CMesh *mesh,double n_quads){
+void mi_quad_param(HMesh *mesh,double n_quads){
   
 	//Old stuff
 	//Map* map = surface();
@@ -258,7 +387,22 @@
   std::cout<<h<<"\n";
   double hh = h * h ;
 
+for(int i=0;i<totface;i++)
+	{
+	
+	mesh->faces[i].vvar[0]=-1;
+	mesh->faces[i].vvar[1]=-1;
+	mesh->faces[i].vvar[2]=-1;
+	
+	}
 
+for(int i=0;i<totvert;i++)
+	{
+	mesh->verts[i].vvar=-1;
+	
+	}
+
+
   //Old Stuff
 
   //Attributes from previous computations:
@@ -297,13 +441,85 @@
   //Duplicate the vertex according to the cut graph
   int nvar = 0 ;
 
+
+ for (int i=0;i<totface;i++)
+	 {
+	 bool singular;
+	 bool visited;
+	 int v[3];
+	 v[0]=mesh->faces[i].v[0];
+	 v[1]=mesh->faces[i].v[1];
+	 v[2]=mesh->faces[i].v[2];
+
+for(int t=0;t<3;t++)
+	{
+	singular= mesh->verts[v[t]].flag & CV_SINGULARITY;
+	visited= mesh->verts[v[t]].flag & CV_VISITED;
+	 /*if(mesh->verts[v[t]].vvar==-1)
+			mesh->verts[v[t]]=nvar;*/
+    if(visited)
+		 {
+		 printf("visited\n");
+		 if(mesh->verts[v[t]].vvar==-1)
+			 {
+			 mesh->verts[v[t]].vvar=nvar;
+			 mesh->faces[i].vvar[t]=nvar;
+			 if(singular)
+				 {
+				 ids_to_round.push_back(2*nvar) ;
+			 ids_to_round.push_back(2*nvar+1) ;
+				 }
+			 nvar++;			 
+			 }
+		 else{
+			 //nvar++;
+			   if(singular)
+				 {
+				 ids_to_round.push_back(2*nvar) ;
+			 ids_to_round.push_back(2*nvar+1) ;
+				 }
+        	  mesh->faces[i].vvar[t]=nvar;
+			  nvar++;
+			 }
+		 
+		 }
+	 else
+		 {
+		 if(mesh->verts[v[t]].vvar==-1)
+			 {
+			 mesh->verts[v[t]].vvar=nvar;
+			 mesh->faces[i].vvar[t]=nvar;
+			 if(singular)
+				 {
+				 ids_to_round.push_back(2*nvar) ;
+			 ids_to_round.push_back(2*nvar+1) ;
+				 }
+			 nvar++;
+			 }
+		 else
+			 {
+			 if(singular)
+				 {
+				 ids_to_round.push_back(2*nvar) ;
+			 ids_to_round.push_back(2*nvar+1) ;
+				 }
+			   mesh->faces[i].vvar[t]=mesh->verts[v[t]].vvar;
+			 
+			 }
+		  }
+	
+	}
+	 
+	 }
+
+  /*
  for(int i=0;i<totvert;i++) {
     bool singular = mesh->verts[i].flag & CV_SINGULARITY;
     //Map::Halfedge* hi = vi->halfedge() ;
     //go to the previous seam edge if any
 	int start=-1;
 	for(int j=0;j<mesh->verts[i].numNeighbors;j++)
-		{
+	{
 		if(!(mesh->edges[mesh->verts[i].edges[j]].flag & CE_MARKED))
 			{
 			start=j;
@@ -332,22 +548,15 @@
 	if(singular) ids_to_round.push_back(2*nvar+1) ;
 
       }
-      mesh->edges[mesh->verts[i].edges[j]].vvar[0] = nvar;
+	 int t=0;
+	  if(mesh->edges[mesh->verts[i].edges[j]].v[0]!=i)
+		  t=1;
+      mesh->edges[mesh->verts[i].edges[j]].vvar[t] = nvar;
 
-	   if(!(mesh->edges[mesh->verts[i].edges[j]].flag & CE_MARKED))
-		 {//we justed crossed a cut, different from the original one (if any)
-	//the vertex must be duplicated
-	++nvar ;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list