00001 /********************************************************************** 00002 * File: polyblob.h (Formerly blob.h) 00003 * Description: Code for PBLOB class. 00004 * Author: Ray Smith 00005 * Created: Wed Oct 23 15:17:41 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 POLYBLOB_H 00021 #define POLYBLOB_H 00022 00023 #include "poutline.h" 00024 #include "rect.h" 00025 #include "normalis.h" 00026 #include "stepblob.h" 00027 00028 const int kBlnXHeight = 128; // x-height for baseline normalisation 00029 const int kBlnBaselineOffset = 64; // offset for baseline normalization 00030 00031 class PBLOB : public ELIST_LINK { 00032 public: 00033 PBLOB() { 00034 } //empty constructor 00035 PBLOB( //constructor 00036 OUTLINE_LIST *outline_list); //in random order 00037 PBLOB( //constructor 00038 C_BLOB *cblob, //polygonal approx 00039 float xheight); 00040 00041 OUTLINE_LIST *out_list() { //get outline list 00042 return &outlines; 00043 } 00044 00045 TBOX bounding_box(); //compute bounding box 00046 float area(); //get area of blob 00047 00048 PBLOB *baseline_normalise( //normalise single blob 00049 ROW *row, //row it came from 00050 DENORM *denorm); //inverse mapping out 00051 void baseline_denormalise( //denormalise 00052 const DENORM *denorm); //antidote 00053 00054 void plot( //draw one 00055 ScrollView* window, //window to draw in 00056 ScrollView::Color blob_colour, //for outer bits 00057 ScrollView::Color child_colour); //for holes 00058 00059 void move( // reposition blob 00060 const FCOORD vec); // by FLOAT vector 00061 00062 void scale( // scale blob 00063 const float f); // by multiplier 00064 void scale( // scale blob 00065 const FCOORD vec); // by FLOAT vector 00066 void rotate(); // Rotate 90 deg anti 00067 void rotate(const FCOORD& rotation); // Rotate by given rotation. 00068 00069 void prep_serialise() { //set ptrs to counts 00070 outlines.prep_serialise (); 00071 } 00072 00073 void dump( //write external bits 00074 FILE *f) { 00075 outlines.dump (f); 00076 } 00077 00078 void de_dump( //read external bits 00079 FILE *f) { 00080 outlines.de_dump (f); 00081 } 00082 00083 //assignment 00084 make_serialise(PBLOB) 00085 00086 PBLOB& operator=(const PBLOB & source) { 00087 if (!outlines.empty ()) 00088 outlines.clear (); 00089 00090 outlines.deep_copy(&source.outlines, &OUTLINE::deep_copy); 00091 return *this; 00092 } 00093 00094 static PBLOB* deep_copy(const PBLOB* src) { 00095 PBLOB* blob = new PBLOB; 00096 *blob = *src; 00097 return blob; 00098 } 00099 00100 private: 00101 OUTLINE_LIST outlines; //master elements 00102 }; 00103 00104 ELISTIZEH_S (PBLOB) 00105 #endif