public static double AreaT(DMesh3 mesh, IEnumerable <int> triangleIndices) { double area = 0; foreach (int tid in triangleIndices) { area += mesh.GetTriArea(tid); } return(area); }
/// <summary> /// Compute area of one-ring of mesh vertex by summing triangle areas. /// If bDisjoint = true, we multiple each triangle area by 1/3 /// </summary> public static double VertexOneRingArea(DMesh3 mesh, int vid, bool bDisjoint = true) { double sum = 0; double mul = (bDisjoint) ? (1.0 / 3.0) : 1.0; foreach (int tid in mesh.VtxTrianglesItr(vid)) { sum += mesh.GetTriArea(tid) * mul; } return(sum); }
void build() { foreach (int tid in Mesh.TriangleIndices()) { double w = (UseAreaWeighting) ? Mesh.GetTriArea(tid) : 1.0; Vector3d n = Mesh.GetTriNormal(tid); Vector3i up = new Vector3i((int)(n.x * IntScale), (int)(n.y * IntScale), (int)(n.z * IntScale)); if (Histogram.ContainsKey(up)) { Histogram[up] += w; } else { Histogram[up] = w; } } }
internal double TriangleArea(g3.DMesh3 mesh) { return(mesh.GetTriArea(meshIndex)); }
private void Remove(TriangleRemoval rem = TriangleRemoval.contained) { #if ACAD var lastColor = 0; #endif DMeshAABBTree3 spatial = new DMeshAABBTree3(CutMesh, true); spatial.WindingNumber(Vector3d.Zero); SafeListBuilder <int> containedT = new SafeListBuilder <int>(); SafeListBuilder <int> removeAnywayT = new SafeListBuilder <int>(); // if the windinging number for the centroid point candidate triangles // is one or more (or close for safety), then it's inside the volume of cutMesh // gParallel.ForEach(Target.TriangleIndices(), (tid) => { if (Target.GetTriArea(tid) < VertexSnapTol) { removeAnywayT.SafeAdd(tid); return; // parallel: equivalent to continue. } Vector3d v = Target.GetTriCentroid(tid); if (AttemptPlanarRemoval) { // slightly offset the point to be evaluated. // var nrm = Target.GetTriNormal(tid); v -= nrm * 5 * VertexSnapTol; } var winding = spatial.WindingNumber(v); bool IsInternal = winding > 0.9; #if ACAD // temporarily here for debug purposes var wantColor = IsInternal ? 1 : 2; if (lastColor != wantColor) { Debug.WriteLine($"-LAYER set L{wantColor}"); Debug.WriteLine($""); lastColor = wantColor; } Triangle3d tri = new Triangle3d(); Target.GetTriVertices(tid, ref tri.V0, ref tri.V1, ref tri.V2); Debug.WriteLine($"3DPOLY {tri.V0.CommaDelimited} {tri.V1.CommaDelimited} {tri.V2.CommaDelimited} {tri.V0.CommaDelimited} {v.CommaDelimited} "); #endif if (IsInternal) { containedT.SafeAdd(tid); } }); if (rem == TriangleRemoval.contained) { MeshEditor.RemoveTriangles(Target, containedT.Result); } else if (rem == TriangleRemoval.external) { var ext = Target.TriangleIndices().Except(containedT.Result); MeshEditor.RemoveTriangles(Target, ext); } MeshEditor.RemoveTriangles(Target, removeAnywayT.Result); // [RMS] construct set of on-cut vertices? This is not // necessarily all boundary vertices... CutVertices = new List <int>(); foreach (int vid in SegmentInsertVertices) { if (Target.IsVertex(vid)) { CutVertices.Add(vid); } } }