Beispiel #1
0
        protected int count_boundary_edges(DMesh3 mesh)
        {
            int boundary_edge_count = 0;

            foreach (int eid in mesh.BoundaryEdgeIndices())
            {
                boundary_edge_count++;
            }
            return(boundary_edge_count);
        }
Beispiel #2
0
 public MeshBoundaryEdgeMidpoints(DMesh3 mesh)
 {
     Mesh = mesh;
     // [RMS] we could count boundary edges really fast by iterating by +4's in
     //  the mesh edge buffer... (also have to check that edge is valid though!)
     num_boundary_edges = 0;
     foreach (int eid in mesh.BoundaryEdgeIndices())
     {
         num_boundary_edges++;
     }
 }
Beispiel #3
0
 protected virtual void Precompute()
 {
     HaveBoundary       = false;
     IsBoundaryVtxCache = new bool[mesh.MaxVertexID];
     foreach (int eid in mesh.BoundaryEdgeIndices())
     {
         Index2i ev = mesh.GetEdgeV(eid);
         IsBoundaryVtxCache[ev.a] = true;
         IsBoundaryVtxCache[ev.b] = true;
         HaveBoundary             = true;
     }
 }
Beispiel #4
0
        int find_nearest_edge(DMesh3 mesh, Vector3d v, HashSet <int> vertices)
        {
            int    near_eid = DMesh3.InvalidID;
            double nearSqr  = VertexSnapTol * VertexSnapTol;

            foreach (int eid in mesh.BoundaryEdgeIndices())
            {
                Index2i ev = mesh.GetEdgeV(eid);
                if (vertices.Contains(ev.a) == false || vertices.Contains(ev.b) == false)
                {
                    continue;
                }
                Segment3d seg  = new Segment3d(mesh.GetVertex(ev.a), mesh.GetVertex(ev.b));
                double    dSqr = seg.DistanceSquared(v);
                if (dSqr < nearSqr)
                {
                    near_eid = eid;
                    nearSqr  = dSqr;
                }
            }
            return(near_eid);
        }
Beispiel #5
0
        protected bool check_for_cracks(DMesh3 mesh, out int boundary_edge_count, double crack_tol = MathUtil.ZeroTolerancef)
        {
            boundary_edge_count = 0;
            var boundary_verts = new MeshVertexSelection(mesh);

            foreach (int eid in mesh.BoundaryEdgeIndices())
            {
                Index2i ev = mesh.GetEdgeV(eid);
                boundary_verts.Select(ev.a); boundary_verts.Select(ev.b);
                boundary_edge_count++;
            }
            if (boundary_verts.Count == 0)
            {
                return(false);
            }

            AxisAlignedBox3d bounds = mesh.CachedBounds;
            var borderV             = new PointHashGrid3d <int>(bounds.MaxDim / 128, -1);

            foreach (int vid in boundary_verts)
            {
                Vector3d v      = mesh.GetVertex(vid);
                var      result = borderV.FindNearestInRadius(v, crack_tol, (existing_vid) =>
                {
                    return(v.Distance(mesh.GetVertex(existing_vid)));
                });
                if (result.Key != -1)
                {
                    return(true);                               // we found a crack vertex!
                }

                borderV.InsertPoint(vid, v);
            }

            // found no cracks
            return(false);
        }
Beispiel #6
0
 // iterators allow us to work with gaps in index space
 public IEnumerable <int> VertexIndices()
 {
     return(Mesh.BoundaryEdgeIndices());
 }