Beispiel #1
0
        // return same indices as GetEdgeV, but oriented based on attached triangle
        Index2i get_oriented_edgev(int eID, int tid_in, int tid_out)
        {
            Index2i edgev = Mesh.GetEdgeV(eID);
            int     a = edgev.a, b = edgev.b;
            Index3i tri = Mesh.GetTriangle(tid_in);
            int     ai  = IndexUtil.find_edge_index_in_tri(a, b, ref tri);

            return(new Index2i(tri[ai], tri[(ai + 1) % 3]));
        }
Beispiel #2
0
        // Modes: 0: centroids, 1: any vertex, 2: 2 vertices, 3: all vertices
        // ContainF should return true if 3D position is in set (eg inside box, etc)
        // If mode = 0, will be called with (centroid, tri_idx)
        // If mode = 1/2/3, will be called with (vtx_pos, vtx_idx)
        // AddF is called with triangle IDs that are in set
        public static void TrianglesContained(NGonsCore.geometry3Sharp.mesh.DMesh3 mesh, Func <Vector3D, int, bool> ContainF, Action <int> AddF, int nMode = 0)
        {
            BitArray inV = null;

            if (nMode != 0)
            {
                inV = new BitArray(mesh.MaxVertexID);
                foreach (int vid in mesh.VertexIndices())
                {
                    if (ContainF(mesh.GetVertex(vid), vid))
                    {
                        inV[vid] = true;
                    }
                }
            }

            foreach (int tid in mesh.TriangleIndices())
            {
                Index3i tri = mesh.GetTriangle(tid);

                bool bIn = false;
                if (nMode == 0)
                {
                    if (ContainF(mesh.GetTriCentroid(tid), tid))
                    {
                        bIn = true;
                    }
                }
                else
                {
                    int countIn = (inV[tri.a] ? 1 : 0) + (inV[tri.b] ? 1 : 0) + (inV[tri.c] ? 1 : 0);
                    bIn = (countIn >= nMode);
                }

                if (bIn)
                {
                    AddF(tid);
                }
            }
        }