|
|
|
@ -12,15 +12,37 @@ namespace Metamesh |
|
|
|
O, |
|
|
|
O, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class Constant |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public static float PHI = (1 + Mathf.Sqrt(5f)) / 2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Dictionary<int, Vector3> VertexMap => new Dictionary<int, Vector3> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
{ 0, new Vector3(0, PHI, -1) }, |
|
|
|
|
|
|
|
{ 1, new Vector3(-PHI, 1, 0) }, |
|
|
|
|
|
|
|
{ 2, new Vector3(-1, 0, -PHI) }, |
|
|
|
|
|
|
|
{ 3, new Vector3(1, 0, -PHI) }, |
|
|
|
|
|
|
|
{ 4, new Vector3(PHI, 1, 0) }, |
|
|
|
|
|
|
|
{ 5, new Vector3(0, PHI, 1) }, |
|
|
|
|
|
|
|
{ 6, new Vector3(-1, 0, PHI) }, |
|
|
|
|
|
|
|
{ 7, new Vector3(-PHI, -1, 0) }, |
|
|
|
|
|
|
|
{ 8, new Vector3(0, -PHI, -1) }, |
|
|
|
|
|
|
|
{ 9, new Vector3(PHI, -1, 0) }, |
|
|
|
|
|
|
|
{ 10, new Vector3(1, 0, PHI) }, |
|
|
|
|
|
|
|
{ 11, new Vector3(0, -PHI, 1) }, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class PrimaryIsoTriangle |
|
|
|
public class PrimaryIsoTriangle |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// ReSharper disable InconsistentNaming |
|
|
|
private int m; |
|
|
|
private int m; |
|
|
|
private int n; |
|
|
|
private int n; |
|
|
|
private List<Vector3> cartesian = new List<Vector3>(); |
|
|
|
private List<Vector3> cartesian = new List<Vector3>(); |
|
|
|
private List<Vector2Int> vertices = new List<Vector2Int>(); |
|
|
|
private List<Vector2Int> vertices = new List<Vector2Int>(); |
|
|
|
private List<int> max = new List<int>(); |
|
|
|
private List<int> max = new List<int>(); |
|
|
|
private List<int> min = new List<int>(); |
|
|
|
private List<int> min = new List<int>(); |
|
|
|
public Dictionary<string, int> vecToidx = new Dictionary<string, int>(); |
|
|
|
public Dictionary<string, int> vecToIdx = new Dictionary<string, int>(); |
|
|
|
private Dictionary<string, List<int>> vertByDist = new Dictionary<string, List<int>>(); |
|
|
|
private Dictionary<string, List<int>> vertByDist = new Dictionary<string, List<int>>(); |
|
|
|
public Dictionary<int, List<int>> closestTo = new Dictionary<int, List<int>>(); |
|
|
|
public Dictionary<int, List<int>> closestTo = new Dictionary<int, List<int>>(); |
|
|
|
|
|
|
|
|
|
|
|
@ -35,27 +57,12 @@ namespace Metamesh |
|
|
|
private float coav; |
|
|
|
private float coav; |
|
|
|
private float cobv; |
|
|
|
private float cobv; |
|
|
|
|
|
|
|
|
|
|
|
//float PHI = (1 + Mathf.Sqrt(5f)) / 2; |
|
|
|
static float PHI = (1 + Mathf.Sqrt(5f)) / 2; |
|
|
|
const float PHI = 1.618034f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PolyhedronData IDATA = new PolyhedronData( |
|
|
|
public PolyhedronData IDATA = new PolyhedronData( |
|
|
|
"icosahedron", |
|
|
|
"icosahedron", |
|
|
|
"Regular", |
|
|
|
"Regular", |
|
|
|
new Dictionary<int, Vector3> |
|
|
|
Constant.VertexMap, |
|
|
|
{ |
|
|
|
|
|
|
|
{ 0, new Vector3(0, PHI, -1) }, |
|
|
|
|
|
|
|
{ 1, new Vector3(-PHI, 1, 0) }, |
|
|
|
|
|
|
|
{ 2, new Vector3(-1, 0, -PHI) }, |
|
|
|
|
|
|
|
{ 3, new Vector3(1, 0, -PHI) }, |
|
|
|
|
|
|
|
{ 4, new Vector3(PHI, 1, 0) }, |
|
|
|
|
|
|
|
{ 5, new Vector3(0, PHI, 1) }, |
|
|
|
|
|
|
|
{ 6, new Vector3(-1, 0, PHI) }, |
|
|
|
|
|
|
|
{ 7, new Vector3(-PHI, -1, 0) }, |
|
|
|
|
|
|
|
{ 8, new Vector3(0, -PHI, -1) }, |
|
|
|
|
|
|
|
{ 9, new Vector3(PHI, -1, 0) }, |
|
|
|
|
|
|
|
{ 10, new Vector3(1, 0, PHI) }, |
|
|
|
|
|
|
|
{ 11, new Vector3(0, -PHI, 1) }, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new List<List<int>> |
|
|
|
new List<List<int>> |
|
|
|
{ |
|
|
|
{ |
|
|
|
new List<int> { 0, 2, 1 }, |
|
|
|
new List<int> { 0, 2, 1 }, |
|
|
|
@ -96,7 +103,7 @@ namespace Metamesh |
|
|
|
public void SetIndices() |
|
|
|
public void SetIndices() |
|
|
|
{ |
|
|
|
{ |
|
|
|
var indexCount = 12; // 12 vertices already assigned |
|
|
|
var indexCount = 12; // 12 vertices already assigned |
|
|
|
var vecToidx = new Dictionary<string, int>(); |
|
|
|
var vecToIdx = new Dictionary<string, int>(); |
|
|
|
var m = this.m; |
|
|
|
var m = this.m; |
|
|
|
var n = this.n; |
|
|
|
var n = this.n; |
|
|
|
var g = m; // hcf of m, n when n != 0 |
|
|
|
var g = m; // hcf of m, n when n != 0 |
|
|
|
@ -134,28 +141,28 @@ namespace Metamesh |
|
|
|
{ |
|
|
|
{ |
|
|
|
idx = f + "|" + isoId; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
idxR = fr + "|" + isoIdR; |
|
|
|
idxR = fr + "|" + isoIdR; |
|
|
|
if (!(vecToidx.ContainsKey(idx) || vecToidx.ContainsKey(idxR))) |
|
|
|
if (!(vecToIdx.ContainsKey(idx) || vecToIdx.ContainsKey(idxR))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vecToidx[idx] = indexCount; |
|
|
|
vecToIdx[idx] = indexCount; |
|
|
|
vecToidx[idxR] = indexCount; |
|
|
|
vecToIdx[idxR] = indexCount; |
|
|
|
indexCount++; |
|
|
|
indexCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (vecToidx.ContainsKey(idx) && !vecToidx.ContainsKey(idxR)) |
|
|
|
else if (vecToIdx.ContainsKey(idx) && !vecToIdx.ContainsKey(idxR)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vecToidx[idxR] = vecToidx[idx]; |
|
|
|
vecToIdx[idxR] = vecToIdx[idx]; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (vecToidx.ContainsKey(idxR) && !vecToidx.ContainsKey(idx)) |
|
|
|
else if (vecToIdx.ContainsKey(idxR) && !vecToIdx.ContainsKey(idx)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vecToidx[idx] = vecToidx[idxR]; |
|
|
|
vecToIdx[idx] = vecToIdx[idxR]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (vDist[isoId][0] > 2) |
|
|
|
if (vDist[isoId][0] > 2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
closestTo[vecToidx[idx]] = new List<int> { -vDist[isoId][0], vDist[isoId][1], vecToidx[idx] }; |
|
|
|
closestTo[vecToIdx[idx]] = new List<int> { -vDist[isoId][0], vDist[isoId][1], vecToIdx[idx] }; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
closestTo[vecToidx[idx]] = new List<int> { verts[vDist[isoId][0]], vDist[isoId][1], vecToidx[idx] }; |
|
|
|
closestTo[vecToIdx[idx]] = new List<int> { verts[vDist[isoId][0]], vDist[isoId][1], vecToIdx[idx] }; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -196,25 +203,25 @@ namespace Metamesh |
|
|
|
|
|
|
|
|
|
|
|
isoId = oVec.x + "|" + oVec.y; |
|
|
|
isoId = oVec.x + "|" + oVec.y; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
if (!vecToidx.ContainsKey(idx)) |
|
|
|
if (!vecToIdx.ContainsKey(idx)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vecToidx[idx] = O; |
|
|
|
vecToIdx[idx] = O; |
|
|
|
closestTo[O] = new List<int> { verts[vDist[isoId][0]], vDist[isoId][1] }; |
|
|
|
closestTo[O] = new List<int> { verts[vDist[isoId][0]], vDist[isoId][1] }; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isoId = aVec.x + "|" + aVec.y; |
|
|
|
isoId = aVec.x + "|" + aVec.y; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
if (!vecToidx.ContainsKey(idx)) |
|
|
|
if (!vecToIdx.ContainsKey(idx)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vecToidx[idx] = A; |
|
|
|
vecToIdx[idx] = A; |
|
|
|
closestTo[A] = new List<int> { verts[vDist[isoId][0]], vDist[isoId][1] }; |
|
|
|
closestTo[A] = new List<int> { verts[vDist[isoId][0]], vDist[isoId][1] }; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isoId = bVec.x + "|" + bVec.y; |
|
|
|
isoId = bVec.x + "|" + bVec.y; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
if (!vecToidx.ContainsKey(idx)) |
|
|
|
if (!vecToIdx.ContainsKey(idx)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vecToidx[idx] = B; |
|
|
|
vecToIdx[idx] = B; |
|
|
|
closestTo[B] = new List<int> { verts[vDist[isoId][0]], vDist[isoId][1] }; |
|
|
|
closestTo[B] = new List<int> { verts[vDist[isoId][0]], vDist[isoId][1] }; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -269,25 +276,25 @@ namespace Metamesh |
|
|
|
{ |
|
|
|
{ |
|
|
|
isoId = this.vertices[i].x + "|" + this.vertices[i].y; |
|
|
|
isoId = this.vertices[i].x + "|" + this.vertices[i].y; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
idx = f + "|" + isoId; |
|
|
|
if (!vecToidx.ContainsKey(idx)) |
|
|
|
if (!vecToIdx.ContainsKey(idx)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vecToidx[idx] = indexCount++; |
|
|
|
vecToIdx[idx] = indexCount++; |
|
|
|
if (vDist[isoId][0] > 2) |
|
|
|
if (vDist[isoId][0] > 2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
closestTo[vecToidx[idx]] = new List<int> |
|
|
|
closestTo[vecToIdx[idx]] = new List<int> |
|
|
|
{ -vDist[isoId][0], vDist[isoId][1], vecToidx[idx] }; |
|
|
|
{ -vDist[isoId][0], vDist[isoId][1], vecToIdx[idx] }; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
closestTo[vecToidx[idx]] = new List<int> |
|
|
|
closestTo[vecToIdx[idx]] = new List<int> |
|
|
|
{ verts[vDist[isoId][0]], vDist[isoId][1], vecToidx[idx] }; |
|
|
|
{ verts[vDist[isoId][0]], vDist[isoId][1], vecToIdx[idx] }; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.closestTo = closestTo; |
|
|
|
this.closestTo = closestTo; |
|
|
|
this.vecToidx = vecToidx; |
|
|
|
this.vecToIdx = vecToIdx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void CalcCoeffs() |
|
|
|
public void CalcCoeffs() |
|
|
|
@ -455,7 +462,7 @@ namespace Metamesh |
|
|
|
var tempVec = x * this.cartesian[i].x + y * this.cartesian[i].y + O; |
|
|
|
var tempVec = x * this.cartesian[i].x + y * this.cartesian[i].y + O; |
|
|
|
//mapped[i] = tempVec; |
|
|
|
//mapped[i] = tempVec; |
|
|
|
idx = faceNb + "|" + this.vertices[i].x + "|" + this.vertices[i].y; |
|
|
|
idx = faceNb + "|" + this.vertices[i].x + "|" + this.vertices[i].y; |
|
|
|
geodesicData.vertex[this.vecToidx[idx]] = tempVec; |
|
|
|
geodesicData.vertex[this.vecToIdx[idx]] = tempVec; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -668,7 +675,7 @@ namespace Metamesh |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (var i = 0; i < primTri.innerFacets.Count; i++) |
|
|
|
for (var i = 0; i < primTri.innerFacets.Count; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.face.Add(primTri.innerFacets[i].Select((el) => primTri.vecToidx[face + el]).ToList()); |
|
|
|
this.face.Add(primTri.innerFacets[i].Select((el) => primTri.vecToIdx[face + el]).ToList()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -690,7 +697,7 @@ namespace Metamesh |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.face.Add(Enumerable.Range(0, 3).Select(i => primTri.vecToidx[temp[i]]).ToList()); |
|
|
|
this.face.Add(Enumerable.Range(0, 3).Select(i => primTri.vecToIdx[temp[i]]).ToList()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -712,7 +719,7 @@ namespace Metamesh |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.face.Add(Enumerable.Range(0, 3).Select(i => primTri.vecToidx[temp[i]]).ToList()); |
|
|
|
this.face.Add(Enumerable.Range(0, 3).Select(i => primTri.vecToIdx[temp[i]]).ToList()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -734,7 +741,7 @@ namespace Metamesh |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.face.Add(Enumerable.Range(0, 3).Select(i => primTri.vecToidx[temp[i]]).ToList()); |
|
|
|
this.face.Add(Enumerable.Range(0, 3).Select(i => primTri.vecToIdx[temp[i]]).ToList()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -900,21 +907,7 @@ namespace Metamesh |
|
|
|
var geodesicData = new GeodesicData( |
|
|
|
var geodesicData = new GeodesicData( |
|
|
|
"Geodesic-m-n", |
|
|
|
"Geodesic-m-n", |
|
|
|
"Geodesic", |
|
|
|
"Geodesic", |
|
|
|
new Dictionary<int, Vector3>() |
|
|
|
Constant.VertexMap, |
|
|
|
{ |
|
|
|
|
|
|
|
{ 0, new Vector3(0, PHI, -1) }, |
|
|
|
|
|
|
|
{ 1, new Vector3(-PHI, 1, 0) }, |
|
|
|
|
|
|
|
{ 2, new Vector3(-1, 0, -PHI) }, |
|
|
|
|
|
|
|
{ 3, new Vector3(1, 0, -PHI) }, |
|
|
|
|
|
|
|
{ 4, new Vector3(PHI, 1, 0) }, |
|
|
|
|
|
|
|
{ 5, new Vector3(0, PHI, 1) }, |
|
|
|
|
|
|
|
{ 6, new Vector3(-1, 0, PHI) }, |
|
|
|
|
|
|
|
{ 7, new Vector3(-PHI, -1, 0) }, |
|
|
|
|
|
|
|
{ 8, new Vector3(0, -PHI, -1) }, |
|
|
|
|
|
|
|
{ 9, new Vector3(PHI, -1, 0) }, |
|
|
|
|
|
|
|
{ 10, new Vector3(1, 0, PHI) }, |
|
|
|
|
|
|
|
{ 11, new Vector3(0, -PHI, 1) }, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new List<List<int>>() |
|
|
|
new List<List<int>>() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|