-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeshAnalysis.cs
120 lines (118 loc) · 4.4 KB
/
MeshAnalysis.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Mola
{
/// <summary>
/// A collection of methods to analyze MolaMesh Face
/// </summary>
public class MeshAnalysis
{
/// <summary>
/// Get the area value of each face of a MolaMesh
/// </summary>
/// <param name="molaMesh">A MolaMesh to be analyzed</param>
/// <returns>A list of float values</returns>
public static List<float> FaceArea(MolaMesh molaMesh)
{
List<float> valueList = new List<float>();
for (int i = 0; i < molaMesh.FacesCount(); i++)
{
valueList.Add(molaMesh.FaceArea(i));
}
return valueList;
}
/// <summary>
/// Get the compactness value of each face of a MolaMesh
/// </summary>
/// <param name="molaMesh">A MolaMesh to be analyzed</param>
/// <returns>A list of float values</returns>
public static List<float> FaceCompactness(MolaMesh molaMesh)
{
List<float> valueList = new List<float>();
for (int i = 0; i < molaMesh.FacesCount(); i++)
{
valueList.Add(molaMesh.FaceCompactness(i));
}
return valueList;
}
/// <summary>
/// Get the index of each face of a MolaMesh
/// </summary>
/// <param name="molaMesh">A MolaMesh to be analyzed</param>
/// <returns>A list of int values</returns>
public static List<int> FaceIndex(MolaMesh molaMesh)
{
int fcount = molaMesh.FacesCount();
List<int> valueList = Enumerable.Range(0, fcount).ToList();
return valueList;
}
/// <summary>
/// Get the center position of each face of a MolaMesh
/// </summary>
/// <param name="molaMesh">A MolaMesh to be analyzed</param>
/// <returns>A list of Mola Vec3</returns>
public static List<Vec3> FaceLocation(MolaMesh molaMesh)
{
List<Vec3> valueList = new List<Vec3>();
for (int i = 0; i < molaMesh.FacesCount(); i++)
{
valueList.Add(molaMesh.FaceCenter(i));
}
return valueList;
}
/// <summary>
/// Get a boolean value for each face according to modulo
/// </summary>
/// <param name="molaMesh">A MolaMesh to be analyzed</param>
/// <param name="modulo">The modulo int number</param>
/// <param name="n">the desired index number within the modulo</param>
/// <returns>A list of boolean values</returns>
/// ### Example
/// ~~~~~~~~~~~~~~.cs
/// MolaMesh mesh = MeshFactory.CreateBox();
/// List<bool> values = MeshAnalysis.FaceModulo(mesh, 6, 0);
/// ~~~~~~~~~~~~~~
public static List<bool> FaceModulo(MolaMesh molaMesh, int modulo=5, int n=4)
{
List<bool> valueList = Enumerable.Repeat(false, molaMesh.FacesCount()).ToList();
for (int i = 0; i < molaMesh.FacesCount(); i++)
{
if (i % modulo == n)
{
valueList[i] = true;
}
}
return valueList;
}
/// <summary>
/// Get the normal vector of each face of a MolaMesh
/// </summary>
/// <param name="molaMesh">A MolaMesh to be analyzed</param>
/// <returns>A list of Mola Vec3</returns>
public static List<Vec3> FaceNormal(MolaMesh molaMesh)
{
List<Vec3> valueList = new List<Vec3>();
for (int i = 0; i < molaMesh.FacesCount(); i++)
{
valueList.Add(molaMesh.FaceNormal(i));
}
return valueList;
}
/// <summary>
/// Get the perimeter value of each face of a MolaMesh
/// </summary>
/// <param name="molaMesh">A MolaMesh to be analyzed</param>
/// <returns>A list of float values</returns>
public static List<float> FacePerimeter(MolaMesh molaMesh)
{
List<float> valueList = new List<float>();
for (int i = 0; i < molaMesh.FacesCount(); i++)
{
valueList.Add(molaMesh.FacePerimeter(i));
}
return valueList;
}
}
}