[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30178] branches/soc-2010-rohith291991: Cutting of mesh including singularities as well seems to be working.
Rohith B V
rohith291991 at gmail.com
Sat Jul 10 14:37:01 CEST 2010
Revision: 30178
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30178
Author: rohith291991
Date: 2010-07-10 14:37:01 +0200 (Sat, 10 Jul 2010)
Log Message:
-----------
Cutting of mesh including singularities as well seems to be working.
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/micode.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-10 11:38:40 UTC (rev 30177)
+++ branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h 2010-07-10 12:37:01 UTC (rev 30178)
@@ -14,6 +14,7 @@
#define CV_MARKED (1)
#define CV_SINGULARITY (1<<2)
#define CV_VISITED (1<<3)
+#define CV_LEAF (1<<4)
struct CFace;
struct CEdge;
@@ -27,6 +28,7 @@
int index; //Index of the vertex
int flag; //Flag for various purposes (if needed)
int numNeighbors; //Number of neighboring vertices
+int pvert; //Parent vertex in Dijsktra
float u; //u Parameter
float v; //v Parameter
float co[3]; //Coordinates of the vertex
Modified: branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp 2010-07-10 11:38:40 UTC (rev 30177)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp 2010-07-10 12:37:01 UTC (rev 30178)
@@ -579,14 +579,8 @@
}
-//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);
-
- }
+//Dijsktra from each non connected singularity vertex
for (int i=0;i<totvert;i++)
{
@@ -615,12 +609,14 @@
std::vector< std::vector <int> > currentVerts; //List of faces to expand for BFS/Dijkstra
int numCV=0; //Number of constrained faces
int j=0;
+ int numsing=0;
for(int i=0;i<mesh->numVerts;i++)
if(mesh->verts[i].flag & CV_SINGULARITY)
{
- mesh->verts[i].flag|= CV_VISITED;
+ mesh->verts[i].flag|= CV_MARKED;
numCV++;
+ numsing++;
}
currentVerts.resize(numCV);
@@ -635,6 +631,8 @@
//Iterative Dijsktra on primal from each singularity
terminate=1;
+int meet=-1;
+
while(terminate)
{
@@ -658,25 +656,177 @@
{
int nIndex=vert->neighbors[k];
- if(!(mesh->verts[nIndex].flag & CV_VISITED))
+ if(!(mesh->verts[nIndex].flag & CV_MARKED))
{
+
+ mesh->verts[nIndex].flag |= CV_MARKED;
+ mesh->verts[nIndex].pvert=index;
+
+ 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;
+ else
+ meet=nIndex;
+
+
}
+ }
+
+
+ }
+ currentVerts[i].resize(newVerts.size());
+
+ for(int l=0;l<newVerts.size();l++)
+ currentVerts[i][l]=newVerts[l];
+
+}
+ }
+
+
+terminate=1;
+while (terminate)
+ {
+
+ if( mesh->verts[meet].flag & CV_SINGULARITY )
+ {
+ break;
}
+ for(int k=0;k<mesh->verts[meet].numNeighbors;k++)
+ {
+ int e=mesh->verts[meet].edges[k];
+ if(mesh->verts[meet].pvert==e)
+ {
+ mesh->edges[e].flag &= !CE_MARKED;
+
+ meet=mesh->verts[meet].pvert;
+ break;
+ }
+
+
+ }
+
+ }
+
+
+
+
+//Remove all open paths execpt those from singularities
+
+for (int i=0;i<totvert;i++)
+ {
+
+ int psum=0;
+
+ for (int j=0;j<mesh->verts[i].numNeighbors;j++)
+ {
+
+ int e=mesh->verts[i].edges[j];
+ if(!(mesh->edges[e].flag & CE_MARKED))
+ psum++;
+ // if(mesh->edges[e].p!=0)
+ // printf("Edge: %d\n",e);
+
+ }
+
+ if(psum==1)
+ {
+
+ mesh->verts[i].flag|=CV_LEAF;
+ //printf("Vertex: %d\n",mesh->verts[i].index);
+
+ }
+ }
+
+ currentVerts.clear(); //List of faces to expand for BFS/Dijkstra
+numCV=0; //Number of constrained faces
+ j=0;
+
+
+
+ for(int i=0;i<mesh->numVerts;i++)
+ if(mesh->verts[i].flag & CV_LEAF)
+ {
+ mesh->verts[i].flag|= CV_VISITED;
+ numCV++;
+ }
+
+ currentVerts.resize(numCV);
+
+ for(int i=0;i<mesh->numVerts;i++)
+ if(mesh->verts[i].flag & CV_LEAF)
+ {
+ currentVerts[j].push_back(mesh->verts[i].index);
+ j++;
+ }
+
+//Iterative Dijsktra on primal from each leaf
+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]);
+
+ int esum=0;
+ int eind=-1;
+ int nind=-1;
+ int eIndex=0;
+ int nIndex=0;
+
+ if(!(mesh->verts[index].flag & CV_SINGULARITY))
+ {for(int k=0;k<vert->numNeighbors;k++)
+ {
+ eIndex=vert->edges[k];
+ nIndex=vert->neighbors[k];
+
+ if(!(mesh->edges[eIndex].flag & CE_MARKED))
+ {
+ esum++;
+ eind=eIndex;
+ nind=nIndex;
+
+
+ }
+ }
+ if(esum==1)
+ {
+
+ mesh->verts[nind].flag |=CV_VISITED;
+ mesh->edges[eind].flag |=CE_MARKED;
+ newVerts.push_back(nind);
+ }
+ }
+
+ }
+
currentVerts[i].resize(newVerts.size());
for(int l=0;l<newVerts.size();l++)
currentVerts[i][l]=newVerts[l];
+
+ }
+
}
-}
- }
+
+printf("numsing: %d\n",numsing);
+
return 1;
}
\ No newline at end of file
Modified: branches/soc-2010-rohith291991/intern/comiso/intern/micode.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/micode.cpp 2010-07-10 11:38:40 UTC (rev 30177)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/micode.cpp 2010-07-10 12:37:01 UTC (rev 30178)
@@ -1,4 +1,4 @@
-void compute_rotated_uv_vars(//rotates variable indices
+/*void compute_rotated_uv_vars(//rotates variable indices
int var, int rot, //u is 2*var, v is 2*var+1
int &uvar, int &vvar, //rotated variable indices
int &usign, int &vsign // states if the opposite of the variable has to be used
@@ -402,3 +402,4 @@
warp.post_process();
surface()->update();
}
+*/
\ No newline at end of file
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-10 11:38:40 UTC (rev 30177)
+++ branches/soc-2010-rohith291991/source/blender/modifiers/intern/MOD_quadrangulate.c 2010-07-10 12:37:01 UTC (rev 30178)
@@ -299,7 +299,7 @@
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;
}
More information about the Bf-blender-cvs
mailing list