Modified: Tutte weights initialization for inner border vertices with valency-2. However such vertices can affect optimization.

This commit is contained in:
Hardik Jain 2020-03-28 16:26:56 +01:00 committed by hrdkjain@cordelia-ubuntu
parent c3da7a2201
commit ee9fcee717
1 changed files with 44 additions and 38 deletions

View File

@ -234,7 +234,16 @@ protected:
neighborsCounter++;
}
// compute angles
if (neighborsCounter < 2)
return ERROR_NON_TRIANGULAR_MESH;
if(neighborsCounter==2 && mesh.is_border(vertex)) {
std::cout << "Encountered inner border with valency-2 vertex (" << vertex << "), initializing with Tutte weights, this can affect optimization" << std::endl;
// Tutte weights
for(int k=0; k<neighborsCounter; k++)
NeighborList_[k].weight = 1.0;
}
else {
for(int n=0; n<neighborsCounter; n++) {
int n_prev = (n==0 ? neighborsCounter-1 : n-1);
double theta = angle(NeighborList_[n].vector,NeighborList_[n_prev].vector);
@ -254,10 +263,6 @@ protected:
for(int n=0; n<neighborsCounter; n++)
NeighborList_[n].uv = Point_2(NeighborList_[n].length*cos(NeighborList_[n].angle), NeighborList_[n].length*sin(NeighborList_[n].angle));
if (neighborsCounter < 2)
return ERROR_NON_TRIANGULAR_MESH;
for(int j=0; j<neighborsCounter; j++)
{
/* Given the j-th neighbour of node i,
@ -284,6 +289,7 @@ protected:
}
}
}
}
// Scale the weights so that they sum to 1.
// double ratio = 1.0 / (double)n;
double sum = 0;