[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31413] branches/soc-2010-rohith291991: Automatic constraint generation.
Rohith B V
rohith291991 at gmail.com
Tue Aug 17 14:14:46 CEST 2010
Revision: 31413
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31413
Author: rohith291991
Date: 2010-08-17 14:14:46 +0200 (Tue, 17 Aug 2010)
Log Message:
-----------
Automatic constraint generation.
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/map_curvature.cpp
branches/soc-2010-rohith291991/intern/comiso/intern/map_curvature.h
branches/soc-2010-rohith291991/intern/comiso/intern/normal_cycle.cpp
branches/soc-2010-rohith291991/intern/comiso/intern/uv.cpp
branches/soc-2010-rohith291991/source/blender/makesdna/DNA_modifier_types.h
branches/soc-2010-rohith291991/source/blender/makesrna/intern/rna_modifier.c
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-08-17 11:10:48 UTC (rev 31412)
+++ branches/soc-2010-rohith291991/intern/comiso/extern/CMesh.h 2010-08-17 12:14:46 UTC (rev 31413)
@@ -149,7 +149,8 @@
extern "C" {
#endif
- int generateVoronoiCells(CMesh * mesh);
+ void setConnectivity(CMesh *mesh);
+ int generateVoronoiCells(CMesh *mesh,HMesh *hm,double h,double bs,double factor);
int generateDirectionField(CMesh *mesh);
int generateParametrization(CMesh *mesh,double h);
Modified: branches/soc-2010-rohith291991/intern/comiso/extern/uv.h
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/extern/uv.h 2010-08-17 11:10:48 UTC (rev 31412)
+++ branches/soc-2010-rohith291991/intern/comiso/extern/uv.h 2010-08-17 12:14:46 UTC (rev 31413)
@@ -8,7 +8,7 @@
#endif
//Solve for parametrization
- void mi_quad_param(HMesh *hm);
+ void mi_quad_param(HMesh *hm, double h);
//Copy mesh
void copyHC(HMesh *hm, CMesh *cm);
CMesh* extractMesh(HMesh *hm);
Modified: branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp 2010-08-17 11:10:48 UTC (rev 31412)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/CMesh.cpp 2010-08-17 12:14:46 UTC (rev 31413)
@@ -3,16 +3,25 @@
#include <math.h>
#include <float.h>
#include "MEM_guardedalloc.h"
+#include "map_curvature.h"
#include "normal_cycle.h"
#include "Geometry"
-int generateVoronoiCells(CMesh* mesh)
+int generateVoronoiCells(CMesh* mesh,HMesh *hm, double h,double bs,double factor)
{
std::vector< std::vector <int> > currentFaces; //List of faces to expand for BFS/Dijkstra
int numCF=0; //Number of constrained faces
int j=0;
+ double radius=h;
+ double meanLimit=0.1/bs;
+
+ OGF::MapCurvature curvature;
+ curvature.set(hm , mesh, (radius*factor) , 0.8 , radius*(1-factor) , meanLimit) ;
+ curvature.compute_curvature_tensor_on_facets();
+
+
//Setup for BFS
for(int i=0;i<mesh->numFaces;i++)
if(mesh->faces[i].flag & CF_CONSTRAINED)
@@ -31,6 +40,9 @@
j++;
}
+ //TODO makes constraints on face theta's
+
+
//Iterative BFS over dual from each constrained face
int terminate=1;
@@ -162,6 +174,147 @@
return 1;
}
+ void setConnectivity(CMesh *mesh)
+{
+
+
+ std::vector< std::vector <int> > currentFaces; //List of faces to expand for BFS/Dijkstra
+ int numCF=0; //Number of constrained faces
+
+ mesh->faces[0].flag|=CF_VISITED;
+ numCF++;
+ currentFaces.resize(numCF);
+ currentFaces[0].push_back(mesh->faces[0].index);
+
+ //Iterative BFS over dual from each constrained face
+ 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]))
+ {
+ face->edges[k]=mesh->edges[l].index;
+ mesh->edges[l].faces[0]=index;
+ mesh->edges[l].faces[1]=nIndex;
+ mesh->edges[l].flag |= CE_MARKED;
+ mesh->edges[l].p=0;
+
+ }
+
+ else if((mesh->edges[l].v[0]==v[1]&&mesh->edges[l].v[1]==v[0] ))
+ {
+ face->edges[k]=mesh->edges[l].index;
+ mesh->edges[l].faces[1]=index;
+ mesh->edges[l].faces[0]=nIndex;
+ mesh->edges[l].flag |= CE_MARKED;
+ mesh->edges[l].p=0;
+
+ }
+ }
+
+ }
+ else
+ {
+
+ 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]))
+ {
+ face->edges[k]=mesh->edges[l].index;
+ mesh->edges[l].faces[0]=index;
+ mesh->edges[l].faces[1]=nIndex;
+
+ }
+
+ else if((mesh->edges[l].v[0]==v[1]&&mesh->edges[l].v[1]==v[0] ))
+ {
+ face->edges[k]=mesh->edges[l].index;
+ mesh->edges[l].faces[1]=index;
+ mesh->edges[l].faces[0]=nIndex;
+
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ currentFaces[i].resize(newFaces.size());
+
+ for(int l=0;l<newFaces.size();l++)
+ currentFaces[i][l]=newFaces[l];
+
+ }
+ }
+for(int i=0;i<mesh->numFaces;i++)
+ {
+ mesh->faces[i].flag=0;
+ }
+
+ }
int generateDirectionField(CMesh* mesh)
{
@@ -182,8 +335,8 @@
int t=0;
int count=0;
- //TODO makes constraints on face theta's
- //call generateConstraints(CMesh* mesh)
+
+
//Setup faces part of A matrix, and calculate kappa for each edge
for(int i=0;i<totface;i++)
@@ -281,7 +434,7 @@
if((ev[0]+2)%3!=ev[1])
{
signe=-1;
- printf("TEST1\n");
+
}
@@ -312,7 +465,7 @@
if(normal[0].dot(e[2].cross(e[1]))<0)
{sign=-1;
- printf("TEST2\n");}
+ }
angle=angle*sign;
int sign2=1;
@@ -323,7 +476,7 @@
{
count++;
sign2=-1;
- printf("TEST3\n");
+
}
angle=angle*sign2;
@@ -339,8 +492,7 @@
double newk=mesh->edges[mesh->faces[i].edges[j]].kappa ;
if(fabs(newk+oldk)<10e-7)
- {printf("new kappa%lf\n",newk);
- printf("old kappa%lf\n\n",oldk);}
+ {}
solver.mdata[t].i=i;
Modified: branches/soc-2010-rohith291991/intern/comiso/intern/map_curvature.cpp
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/intern/map_curvature.cpp 2010-08-17 11:10:48 UTC (rev 31412)
+++ branches/soc-2010-rohith291991/intern/comiso/intern/map_curvature.cpp 2010-08-17 12:14:46 UTC (rev 31413)
@@ -1,335 +1,495 @@
-/*
- * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
- * Copyright (C) 2000-2003 Bruno Levy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will bein useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * If you modify this software, you should include a notice giving the
- * name of the person performing the modification, the date of modification,
- * and the reason for such modification.
- *
- * Contact: Bruno Levy
- *
- * levy at loria.fr
- *
- * ISA Project
- * LORIA, INRIA Lorraine,
- * Campus Scientifique, BP 239
- * 54506 VANDOEUVRE LES NANCY CEDEX
- * FRANCE
- *
- * Note that the GNU General Public License does not permit incorporating
- * the Software into proprietary programs.
- */
-/*
-#include "common.h"
-#include "map_curvature.h"
-//TODO
-//#include <OGF/cells/map/geometry.h>
-#include "normal_cycle.h"
-//#include <OGF/basic/debug/progress.h>
-
-#include <set>
-#include <stack>
-
-namespace OGF {
-
- MapCurvature::MapCurvature() : mesh_(mesh), radius_(0.001) {
- anisotropic_ = false ;
- nb_anisotropic_iters_ = 3 ;
- anisotropic_factor_ = 1.5 ;
- }
-
- void MapCurvature::compute_curvature_tensor() {
- double a = 1.0 / (3.1415926 * radius_*radius_) ;
- // ProgressLogger progress(map_->size_of_vertices()) ;
- for(int i=0;i<mesh_.numVerts;i++)
- {
-
-
- NormalCycle ncycle ;
- if(radius_ > 0) {
- if(anisotropic_) {
- compute_curvature_tensor_anisotropic(
- i,radius_,nb_anisotropic_iters_,anisotropic_factor_,ncycle) ;
- } else {
- compute_curvature_tensor(i,radius_,ncycle) ;
- }
- } else {
- std::cerr << "one ring" << std::endl ;
- compute_curvature_tensor_one_ring(i, ncycle) ;
- }
-
-
- mesh_.Kmin_[i] = a* ncycle.kmin() * ncycle.Kmin() ;
-
-
-
- mesh_.Kmax_[i] = a * ncycle.kmax() * ncycle.Kmax() ;
-
-
-
- mesh_.N_[i] = a * ncycle.n() * ncycle.N() ;
-
-
-
- mesh_.kmin_[i] = ncycle.kmin() ;
-
-
-
- mesh_.kmax_[i] = ncycle.kmax() ;
-
-
- mesh_.n_[i] = ncycle.n() ;
-
- }
- }
-
- void MapCurvature::compute_curvature_tensor_on_facets() {
- double a = (radius_ > 0.0) ? (1.0 / (3.1415926 * radius_*radius_)) : 1.0 ;
-// MapFacetAttribute<Vector3d> Kmin(map_, "K1") ;
- // MapFacetAttribute<Vector3d> Kmax(map_, "K2") ;
- //ProgressLogger progress(map_->size_of_facets()) ;
- for(int i=0;i<mesh_.numFaces;i++) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list