示例#1
0
        /// <summary>
        /// Similar to cvSubdiv2DGetEdge
        /// </summary>
        /// <param name="type">The next edge type</param>
        /// <returns>The next edge</returns>
        public MCvSubdiv2DEdge cvSubdiv2DGetEdge(CvEnum.CV_NEXT_EDGE_TYPE type)
        {
            Int64         edgeInt64 = edge.ToInt64();
            IntPtr        ptr       = (IntPtr)(edgeInt64 & -4);
            MCvQuadEdge2D qe        = (MCvQuadEdge2D)Marshal.PtrToStructure(ptr, typeof(MCvQuadEdge2D));
            Int64         edgePtr   = qe.next[(edgeInt64 + (int)type) & 3].edge.ToInt64();

            edgePtr = (edgePtr & -4) + ((edgePtr + ((int)type >> 4)) & 3);

            return(new MCvSubdiv2DEdge(new IntPtr(edgePtr)));
        }
示例#2
0
        /// <summary>
        /// similar to cvSubdiv2DEdgeDst
        /// </summary>
        /// <returns></returns>
        public MCvSubdiv2DPoint cvSubdiv2DEdgeDst()
        {
            Int64 edgeInt64 = edge.ToInt64();

            IntPtr        ptr      = (IntPtr)(edgeInt64 & -4);
            MCvQuadEdge2D qe       = (MCvQuadEdge2D)Marshal.PtrToStructure(ptr, typeof(MCvQuadEdge2D));
            IntPtr        pointPtr = qe.pt[(edgeInt64 + 2) & 3];

            if (pointPtr == IntPtr.Zero)
            {
                MCvSubdiv2DPoint pt = new MCvSubdiv2DPoint();
                pt.flags = -1;
                return(pt); // return an invalid point
            }
            else
            {
                return((MCvSubdiv2DPoint)Marshal.PtrToStructure(pointPtr, typeof(MCvSubdiv2DPoint)));
            }
        }
示例#3
0
        /// <summary>
        /// similar to cvSubdiv2DEdgeOrg
        /// </summary>
        /// <returns></returns>
        public MCvSubdiv2DPoint cvSubdiv2DEdgeOrg()
        {
            Int64 edgeInt64 = edge.ToInt64();

            IntPtr        ptr      = (IntPtr)(edgeInt64 & -4); //the last 2 bits are set to zero
            MCvQuadEdge2D qe       = (MCvQuadEdge2D)Marshal.PtrToStructure(ptr, typeof(MCvQuadEdge2D));
            IntPtr        pointPtr = qe.pt[edgeInt64 & 3];     //use only the last 2 bit as index

            if (pointPtr == IntPtr.Zero)
            {
                MCvSubdiv2DPoint pt = new MCvSubdiv2DPoint();
                pt.flags = -1;
                return(pt); // return an invalid point
            }
            else
            {
                return((MCvSubdiv2DPoint)Marshal.PtrToStructure(pointPtr, typeof(MCvSubdiv2DPoint)));
            }
        }