~sahana-agasti-ocr/+junk/working_source

« back to all changes in this revision

Viewing changes to Projects/common/Header_files/stepblob.h

  • Committer: Thilanka
  • Date: 2010-07-14 07:34:15 UTC
  • Revision ID: thilanka@thilanka-laptop-20100714073415-1etpm1i0xtbrldus
This commit contains all the working source for sahana OCR till midterm evaluation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
 * File:        stepblob.h  (Formerly cblob.h)
 
3
 * Description: Code for C_BLOB class.
 
4
 * Author:              Ray Smith
 
5
 * Created:             Tue Oct 08 10:41:13 BST 1991
 
6
 *
 
7
 * (C) Copyright 1991, Hewlett-Packard Ltd.
 
8
 ** Licensed under the Apache License, Version 2.0 (the "License");
 
9
 ** you may not use this file except in compliance with the License.
 
10
 ** You may obtain a copy of the License at
 
11
 ** http://www.apache.org/licenses/LICENSE-2.0
 
12
 ** Unless required by applicable law or agreed to in writing, software
 
13
 ** distributed under the License is distributed on an "AS IS" BASIS,
 
14
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
 ** See the License for the specific language governing permissions and
 
16
 ** limitations under the License.
 
17
 *
 
18
 **********************************************************************/
 
19
 
 
20
#ifndef           STEPBLOB_H
 
21
#define           STEPBLOB_H
 
22
 
 
23
#include          "coutln.h"
 
24
#include          "rect.h"
 
25
 
 
26
class C_BLOB:public ELIST_LINK
 
27
{
 
28
  public:
 
29
    C_BLOB() {
 
30
    }
 
31
    explicit C_BLOB(C_OUTLINE_LIST *outline_list);
 
32
 
 
33
    // Build and return a fake blob containing a single fake outline with no
 
34
    // steps.
 
35
    static C_BLOB* FakeBlob(const TBOX& box);
 
36
 
 
37
    C_OUTLINE_LIST *out_list() {  //get outline list
 
38
      return &outlines;
 
39
    }
 
40
 
 
41
    TBOX bounding_box();  //compute bounding box
 
42
    inT32 area();  //compute area
 
43
    inT32 perimeter();  // Total perimeter of outlines and 1st level children.
 
44
    inT32 outer_area();  //compute area
 
45
    inT32 count_transitions(                   //count maxima
 
46
                            inT32 threshold);  //size threshold
 
47
 
 
48
    void move(const ICOORD vec);  // repostion blob by vector
 
49
    void rotate(const FCOORD& rotation);  // Rotate by given vector.
 
50
 
 
51
    void plot(                       //draw one
 
52
              ScrollView* window,         //window to draw in
 
53
              ScrollView::Color blob_colour,    //for outer bits
 
54
              ScrollView::Color child_colour);  //for holes
 
55
 
 
56
    void prep_serialise() {  //set ptrs to counts
 
57
      outlines.prep_serialise ();
 
58
    }
 
59
 
 
60
    void dump(  //write external bits
 
61
              FILE *f) {
 
62
      outlines.dump (f);
 
63
    }
 
64
 
 
65
    void de_dump(  //read external bits
 
66
                 FILE *f) {
 
67
      outlines.de_dump (f);
 
68
    }
 
69
 
 
70
                                 //assignment
 
71
    make_serialise(C_BLOB)
 
72
 
 
73
    C_BLOB& operator= (const C_BLOB & source) {
 
74
      if (!outlines.empty ())
 
75
        outlines.clear();
 
76
      outlines.deep_copy(&source.outlines, &C_OUTLINE::deep_copy);
 
77
      return *this;
 
78
    }
 
79
 
 
80
    static C_BLOB* deep_copy(const C_BLOB* src) {
 
81
      C_BLOB* blob = new C_BLOB;
 
82
      *blob = *src;
 
83
      return blob;
 
84
    }
 
85
 
 
86
  private:
 
87
    C_OUTLINE_LIST outlines;     //master elements
 
88
};
 
89
 
 
90
ELISTIZEH_S (C_BLOB)
 
91
#endif