Tesseract 3.01
/data/source/tesseract-ocr/ccstruct/stepblob.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        stepblob.h  (Formerly cblob.h)
00003  * Description: Code for C_BLOB class.
00004  * Author:              Ray Smith
00005  * Created:             Tue Oct 08 10:41:13 BST 1991
00006  *
00007  * (C) Copyright 1991, Hewlett-Packard Ltd.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef           STEPBLOB_H
00021 #define           STEPBLOB_H
00022 
00023 #include          "coutln.h"
00024 #include          "rect.h"
00025 
00026 struct Pix;
00027 
00028 class C_BLOB:public ELIST_LINK
00029 {
00030   public:
00031     C_BLOB() {
00032     }
00033     explicit C_BLOB(C_OUTLINE_LIST *outline_list);
00034     // Simpler constructor to build a blob from a single outline that has
00035     // already been fully initialized.
00036     explicit C_BLOB(C_OUTLINE* outline);
00037 
00038     // Build and return a fake blob containing a single fake outline with no
00039     // steps.
00040     static C_BLOB* FakeBlob(const TBOX& box);
00041 
00042     C_OUTLINE_LIST *out_list() {  //get outline list
00043       return &outlines;
00044     }
00045 
00046     TBOX bounding_box();  //compute bounding box
00047     inT32 area();  //compute area
00048     inT32 perimeter();  // Total perimeter of outlines and 1st level children.
00049     inT32 outer_area();  //compute area
00050     inT32 count_transitions(                   //count maxima
00051                             inT32 threshold);  //size threshold
00052 
00053     void move(const ICOORD vec);  // repostion blob by vector
00054     void rotate(const FCOORD& rotation);  // Rotate by given vector.
00055 
00056     // Returns a Pix rendering of the blob. pixDestroy after use.
00057     Pix* render();
00058 
00059     void plot(                       //draw one
00060               ScrollView* window,         //window to draw in
00061               ScrollView::Color blob_colour,    //for outer bits
00062               ScrollView::Color child_colour);  //for holes
00063 
00064     C_BLOB& operator= (const C_BLOB & source) {
00065       if (!outlines.empty ())
00066         outlines.clear();
00067       outlines.deep_copy(&source.outlines, &C_OUTLINE::deep_copy);
00068       return *this;
00069     }
00070 
00071     static C_BLOB* deep_copy(const C_BLOB* src) {
00072       C_BLOB* blob = new C_BLOB;
00073       *blob = *src;
00074       return blob;
00075     }
00076 
00077   private:
00078     C_OUTLINE_LIST outlines;     //master elements
00079 };
00080 
00081 ELISTIZEH (C_BLOB)
00082 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines