Exemplo n.º 1
0
        // returns true for both internal and mesh boundary edges
        // tid_in and tid_out are triangles 'in' and 'out' of set, respectively
        bool edge_is_boundary(int eid, ref int tid_in, ref int tid_out)
        {
            if (edges.Contains(eid) == false)
            {
                return(false);
            }

            tid_in = tid_out = NGonsCore.geometry3Sharp.mesh.DMesh3.InvalidID;
            Index2i et = Mesh.GetEdgeT(eid);

            if (et.b == NGonsCore.geometry3Sharp.mesh.DMesh3.InvalidID)           // boundary edge!
            {
                tid_in  = et.a;
                tid_out = et.b;
                return(true);
            }

            bool in0 = triangles[et.a];
            bool in1 = triangles[et.b];

            if (in0 != in1)
            {
                tid_in  = (in0) ? et.a : et.b;
                tid_out = (in0) ? et.b : et.a;
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public MeshRegionBoundaryLoops(NGonsCore.geometry3Sharp.mesh.DMesh3 mesh, int[] RegionTris, bool bAutoCompute = true)
        {
            this.Mesh = mesh;

            // make flag set for included triangles
            triangles = new IndexFlagSet(mesh.MaxTriangleID, RegionTris.Length);
            for (int i = 0; i < RegionTris.Length; ++i)
            {
                triangles[RegionTris[i]] = true;
            }

            // make flag set for included edges
            // NOTE: this currently processes non-boundary-edges twice. Could
            // avoid w/ another IndexFlagSet, but the check is inexpensive...
            edges = new IndexFlagSet(mesh.MaxEdgeID, RegionTris.Length);
            for (int i = 0; i < RegionTris.Length; ++i)
            {
                int     tid = RegionTris[i];
                Index3i te  = Mesh.GetTriEdges(tid);
                for (int j = 0; j < 3; ++j)
                {
                    int eid = te[j];
                    if (!edges.Contains(eid))
                    {
                        Index2i et = mesh.GetEdgeT(eid);
                        if (et.b == NGonsCore.geometry3Sharp.mesh.DMesh3.InvalidID || triangles[et.a] != triangles[et.b])
                        {
                            edges.Add(eid);
                        }
                    }
                }
            }


            if (bAutoCompute)
            {
                Compute();
            }
        }