ccstruct/genblob.cpp

Go to the documentation of this file.
00001 
00020 #include "mfcpch.h"
00021 #include          "stepblob.h"
00022 #include          "polyblob.h"
00023 #include          "genblob.h"
00024 
00031 int blob_comparator(                     //sort blobs
00032                     const void *blob1p,  //ptr to ptr to blob1
00033                     const void *blob2p   //ptr to ptr to blob2
00034                    ) {
00035   PBLOB *blob1 = *(PBLOB **) blob1p;
00036   PBLOB *blob2 = *(PBLOB **) blob2p;
00037 
00038   return blob1->bounding_box ().left () - blob2->bounding_box ().left ();
00039 }
00040 
00041 
00048 int c_blob_comparator(                     //sort blobs
00049                       const void *blob1p,  //ptr to ptr to blob1
00050                       const void *blob2p   //ptr to ptr to blob2
00051                      ) {
00052   C_BLOB *blob1 = *(C_BLOB **) blob1p;
00053   C_BLOB *blob2 = *(C_BLOB **) blob2p;
00054 
00055   return blob1->bounding_box ().left () - blob2->bounding_box ().left ();
00056 }
00057 
00058 
00064 BOX gblob_bounding_box(                 //Get bounding box
00065                        PBLOB *blob,     //generic blob
00066                        BOOL8 polygonal  //is blob polygonal?
00067                       ) {
00068   if (polygonal)
00069     return blob->bounding_box ();
00070   else
00071     return ((C_BLOB *) blob)->bounding_box ();
00072 }
00073 
00074 
00080 void gblob_sort_list(                        //Sort a gblob list
00081                      PBLOB_LIST *blob_list,  //generic blob list
00082                      BOOL8 polygonal         //is list polygonal?
00083                     ) {
00084   PBLOB_IT b_it;
00085   C_BLOB_IT c_it;
00086 
00087   if (polygonal) {
00088     b_it.set_to_list (blob_list);
00089     b_it.sort (blob_comparator);
00090   }
00091   else {
00092     c_it.set_to_list ((C_BLOB_LIST *) blob_list);
00093     c_it.sort (c_blob_comparator);
00094   }
00095 }
00096 
00097 
00103 OUTLINE_LIST *gblob_out_list(                 //Get outline list
00104                              PBLOB *blob,     //generic blob
00105                              BOOL8 polygonal  //is blob polygonal?
00106                             ) {
00107   if (polygonal)
00108     return blob->out_list ();
00109   else
00110     return (OUTLINE_LIST *) ((C_BLOB *) blob)->out_list ();
00111 }
00112 
00113 
00119 BOX goutline_bounding_box(                   //Get bounding box
00120                           OUTLINE *outline,  //generic outline
00121                           BOOL8 polygonal    //is outline polygonal?
00122                          ) {
00123   if (polygonal)
00124     return outline->bounding_box ();
00125   else
00126     return ((C_OUTLINE *) outline)->bounding_box ();
00127 }

Generated on Wed Feb 28 19:49:08 2007 for Tesseract by  doxygen 1.5.1