Ejemplo n.º 1
0
        // ccbord.c (1522, 1)
        // ccbaGenerateSinglePath(ccba) as int
        // ccbaGenerateSinglePath(CCBORDA *) as l_ok
        ///  <summary>
        /// (1) Generates a single border in local pixel coordinates.
        /// For each c.c., if there is just an outer border, copy it.
        /// If there are also hole borders, for each hole border,
        /// determine the smallest horizontal or vertical
        /// distance from the border to the outside of the c.c.,
        /// and find a path through the c.c. for this cut.
        /// We do this in a way that guarantees a pixel from the
        /// hole border is the starting point of the path, and
        /// we must verify that the path intersects the outer
        /// border (if it intersects it, then it ends on it).
        /// One can imagine pathological cases, but they may not
        /// occur in images of text characters and un-textured
        /// line graphics.<para/>
        ///
        /// (2) Once it is verified that the path through the c.c.
        /// intersects both the hole and outer borders, we
        /// generate the full single path for all borders in the
        /// c.c.  Starting at the start point on the outer
        /// border, when we hit a line on a cut, we take
        /// the cut, do the hold border, and return on the cut
        /// to the outer border.  We compose a pta of the
        /// outer border pts that are on cut paths, and for
        /// every point on the outer border (as we go around),
        /// we check against this pta.  When we find a matching
        /// point in the pta, we do its cut path and hole border.
        /// The single path is saved in the ccb.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaGenerateSinglePath/*"/>
        ///  <param name="ccba">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int ccbaGenerateSinglePath(
            CCBorda ccba)
        {
            if (ccba == null)
            {
                throw new ArgumentNullException("ccba cannot be Nothing");
            }

            int _Result = Natives.ccbaGenerateSinglePath(ccba.Pointer);

            return(_Result);
        }
Ejemplo n.º 2
0
        // ccbord.c (1405, 1)
        // ccbaGenerateSPGlobalLocs(ccba, ptsflag) as int
        // ccbaGenerateSPGlobalLocs(CCBORDA *, l_int32) as l_ok
        ///  <summary>
        /// (1) This calculates the splocal rep if not yet made.<para/>
        ///
        /// (2) It uses the local pixel values in splocal, the single
        /// path pta, which are all relative to each c.c., to find
        /// the corresponding global pixel locations, and stores
        /// them in the spglobal pta.<para/>
        ///
        /// (3) This lists only the turning points: it both makes a
        /// valid svg file and is typically about half the size
        /// when all border points are listed.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaGenerateSPGlobalLocs/*"/>
        ///  <param name="ccba">[in] - </param>
        ///  <param name="ptsflag">[in] - CCB_SAVE_ALL_PTS or CCB_SAVE_TURNING_PTS</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int ccbaGenerateSPGlobalLocs(
            CCBorda ccba,
            int ptsflag)
        {
            if (ccba == null)
            {
                throw new ArgumentNullException("ccba cannot be Nothing");
            }

            int _Result = Natives.ccbaGenerateSPGlobalLocs(ccba.Pointer, ptsflag);

            return(_Result);
        }
Ejemplo n.º 3
0
        // ccbord.c (1305, 1)
        // ccbaStepChainsToPixCoords(ccba, coordtype) as int
        // ccbaStepChainsToPixCoords(CCBORDA *, l_int32) as l_ok
        ///  <summary>
        /// (1) This uses the step chain data in each ccb to determine
        /// the pixel locations, either global or local,
        /// and stores them in the appropriate ptaa,
        /// either global or local.  For the latter, the
        /// pixel locations are relative to the c.c.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaStepChainsToPixCoords/*"/>
        ///  <param name="ccba">[in] - with step chains numaa of borders</param>
        ///  <param name="coordtype">[in] - CCB_GLOBAL_COORDS or CCB_LOCAL_COORDS</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int ccbaStepChainsToPixCoords(
            CCBorda ccba,
            int coordtype)
        {
            if (ccba == null)
            {
                throw new ArgumentNullException("ccba cannot be Nothing");
            }

            int _Result = Natives.ccbaStepChainsToPixCoords(ccba.Pointer, coordtype);

            return(_Result);
        }
Ejemplo n.º 4
0
        // ccbord.c (2097, 1)
        // ccbaDisplayImage2(ccba) as Pix
        // ccbaDisplayImage2(CCBORDA *) as PIX *
        ///  <summary>
        /// (1) Uses local chain ptaa, which gives each border pixel in
        /// local coordinates, so the actual pixel positions must
        /// be computed using all offsets.<para/>
        ///
        /// (2) Treats exterior and hole borders on equivalent
        /// footing, and does all calculations on a pix
        /// that spans the c.c. with a 1 pixel added boundary.<para/>
        ///
        /// (3) This uses topological properties (Method 2) to do scan
        /// conversion to raster<para/>
        ///
        /// (4) The algorithm is described at the top of this file (Method 2).
        /// It is preferred to Method 1 because it is between 1.2x and 2x
        /// faster than Method 1.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaDisplayImage2/*"/>
        ///  <param name="ccba">[in] - </param>
        ///   <returns>pix of image, or NULL on error</returns>
        public static Pix ccbaDisplayImage2(
            CCBorda ccba)
        {
            if (ccba == null)
            {
                throw new ArgumentNullException("ccba cannot be Nothing");
            }

            IntPtr _Result = Natives.ccbaDisplayImage2(ccba.Pointer);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pix(_Result));
        }
Ejemplo n.º 5
0
        // ccbord.c (2195, 1)
        // ccbaWrite(filename, ccba) as int
        // ccbaWrite(const char *, CCBORDA *) as l_ok
        ///  <summary>
        /// ccbaWrite()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaWrite/*"/>
        ///  <param name="filename">[in] - </param>
        ///  <param name="ccba">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int ccbaWrite(
            String filename,
            CCBorda ccba)
        {
            if (filename == null)
            {
                throw new ArgumentNullException("filename cannot be Nothing");
            }

            if (ccba == null)
            {
                throw new ArgumentNullException("ccba cannot be Nothing");
            }

            int _Result = Natives.ccbaWrite(filename, ccba.Pointer);

            return(_Result);
        }
Ejemplo n.º 6
0
        // ccbord.c (535, 1)
        // ccbaGetCcb(ccba, index) as CCBord
        // ccbaGetCcb(CCBORDA *, l_int32) as CCBORD *
        ///  <summary>
        /// (1) This returns a clone of the ccb it must be destroyed
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaGetCcb/*"/>
        ///  <param name="ccba">[in] - </param>
        ///  <param name="index">[in] - </param>
        ///   <returns>ccb, or NULL on error</returns>
        public static CCBord ccbaGetCcb(
            CCBorda ccba,
            int index)
        {
            if (ccba == null)
            {
                throw new ArgumentNullException("ccba cannot be Nothing");
            }

            IntPtr _Result = Natives.ccbaGetCcb(ccba.Pointer, index);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new CCBord(_Result));
        }
Ejemplo n.º 7
0
        // ccbord.c (454, 1)
        // ccbaAddCcb(ccba, ccb) as int
        // ccbaAddCcb(CCBORDA *, CCBORD *) as l_ok
        ///  <summary>
        /// ccbaAddCcb()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaAddCcb/*"/>
        ///  <param name="ccba">[in] - </param>
        ///  <param name="ccb">[in] - to be added by insertion</param>
        ///   <returns>0 if OK 1 on error</returns>
        public static int ccbaAddCcb(
            CCBorda ccba,
            CCBord ccb)
        {
            if (ccba == null)
            {
                throw new ArgumentNullException("ccba cannot be Nothing");
            }

            if (ccb == null)
            {
                throw new ArgumentNullException("ccb cannot be Nothing");
            }

            int _Result = Natives.ccbaAddCcb(ccba.Pointer, ccb.Pointer);

            return(_Result);
        }
Ejemplo n.º 8
0
        // ccbord.c (2247, 1)
        // ccbaWriteStream(fp, ccba) as int
        // ccbaWriteStream(FILE *, CCBORDA *) as l_ok
        ///  <summary>
        /// ccbaWriteStream()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaWriteStream/*"/>
        ///  <param name="fp">[in] - file stream</param>
        ///  <param name="ccba">[in] - </param>
        ///   <returns>0 if OK 1 on error Format: \code ccba: %7d cc\n num. c.c.) (ascii)   (18B pix width 4B pix height 4B [for i = 1, ncc] ulx  4B uly  4B w    4B       -- not req'd for reconstruction h    4B       -- not req'd for reconstruction number of borders 4B [for j = 1, nb] startx  4B starty  4B [for k = 1, nb] 2 steps 1B end in z8 or 88  1B \endcode</returns>
        public static int ccbaWriteStream(
            FILE fp,
            CCBorda ccba)
        {
            if (fp == null)
            {
                throw new ArgumentNullException("fp cannot be Nothing");
            }

            if (ccba == null)
            {
                throw new ArgumentNullException("ccba cannot be Nothing");
            }

            int _Result = Natives.ccbaWriteStream(fp.Pointer, ccba.Pointer);

            return(_Result);
        }
Ejemplo n.º 9
0
        // ccbord.c (332, 1)
        // ccbaDestroy(pccba) as Object
        // ccbaDestroy(CCBORDA **) as void
        ///  <summary>
        /// ccbaDestroy()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ccbaDestroy/*"/>
        ///  <param name="pccba">[in,out] - to be nulled</param>
        public static void ccbaDestroy(
            ref CCBorda pccba)
        {
            IntPtr pccbaPtr = IntPtr.Zero;  if (pccba != null)

            {
                pccbaPtr = pccba.Pointer;
            }

            Natives.ccbaDestroy(ref pccbaPtr);
            if (pccbaPtr == IntPtr.Zero)
            {
                pccba = null;
            }
            else
            {
                pccba = new CCBorda(pccbaPtr);
            };
        }