I am writing an algorithm in Visual Studio that draws a sphere through the corners of a triangle. How do I convert the corners of a MeshFace into Point3ds? When I do face.A, that just gives an index of the point, not the coordinates.
Hello,
Like this?
meshVertices.gh (4.5 KB)
Thank you!
I can also use verticies.Point3dAt(Faces[0].A);
?
General case:
M.Vertices.CombineIdentical(true, true);
Mesh[] pieces = M.SplitDisjointPieces();
DataTree<Point3d> VT = new DataTree<Point3d>();
for(int p = 0; p < pieces.Length;p++){
Mesh m = pieces[p];
var MTV = m.TopologyVertices;
var MF = m.Faces;
for(int i = 0; i < MF.Count;i++){
int[] vIdx = MTV.IndicesFromFace(i);
foreach(int idx in vIdx) VT.Add(MTV[idx], new GH_Path(p, i));
}
}
BTW: TopoVertices yields Vertices on per Mesh basis. Vertices yields vertices on a per MeshFace basis (Indexing IS NOT the same - but there’s RC Methods from-to).
This doesn’t seem to be working for me
foreach (Mesh t in inputCells)
{
MeshFaceList faces = t.Faces;
var vs = t.Vertices;
for (int i = 0; i < faces.Count; i++)
{
var firstPoint = vs[t.Faces[i].A];
var secondPoint = vs[t.Faces[i].B];
var thirdPoint = vs[t.Faces[i].C];
Debug.Assert(firstPoint.GetType() == typeof(Point3d), "point is not a Point3d");
I also tried with a foreach loop
foreach (Mesh t in inputCells)
{
var vs = t.Vertices;
foreach (var face in t.Faces)
{
var firstPoint = vs[face.A];
var secondPoint = vs[face.B];
var thirdPoint = vs[face.C];
Debug.Assert(firstPoint.GetType() == typeof(Point3d), "point is not a Point3d");
I think I missed the point that Verticies per mesh are not the same as MeshFace verticies.
Is it because the mesh vertices are Point3f and not Point3d?
Point3d
MeshVertexList_Item
Point3f
There is also a constructor for point3d that takes point3f as an argument.
Yes, I was able to convert it into a Point3d with the constructor. I had never heard of Point3f!
I always thought Point3d meant a 3-dimensional point. I think it actually means a point with double floating point precision. and Point3f means single floating-point precision.