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 class C_BLOB:public ELIST_LINK 00027 { 00028 public: 00029 C_BLOB() { 00030 } 00031 explicit C_BLOB(C_OUTLINE_LIST *outline_list); 00032 00033 // Build and return a fake blob containing a single fake outline with no 00034 // steps. 00035 static C_BLOB* FakeBlob(const TBOX& box); 00036 00037 C_OUTLINE_LIST *out_list() { //get outline list 00038 return &outlines; 00039 } 00040 00041 TBOX bounding_box(); //compute bounding box 00042 inT32 area(); //compute area 00043 inT32 perimeter(); // Total perimeter of outlines and 1st level children. 00044 inT32 outer_area(); //compute area 00045 inT32 count_transitions( //count maxima 00046 inT32 threshold); //size threshold 00047 00048 void move(const ICOORD vec); // repostion blob by vector 00049 void rotate(const FCOORD& rotation); // Rotate by given vector. 00050 00051 void plot( //draw one 00052 ScrollView* window, //window to draw in 00053 ScrollView::Color blob_colour, //for outer bits 00054 ScrollView::Color child_colour); //for holes 00055 00056 void prep_serialise() { //set ptrs to counts 00057 outlines.prep_serialise (); 00058 } 00059 00060 void dump( //write external bits 00061 FILE *f) { 00062 outlines.dump (f); 00063 } 00064 00065 void de_dump( //read external bits 00066 FILE *f) { 00067 outlines.de_dump (f); 00068 } 00069 00070 //assignment 00071 make_serialise(C_BLOB) 00072 00073 C_BLOB& operator= (const C_BLOB & source) { 00074 if (!outlines.empty ()) 00075 outlines.clear(); 00076 outlines.deep_copy(&source.outlines, &C_OUTLINE::deep_copy); 00077 return *this; 00078 } 00079 00080 static C_BLOB* deep_copy(const C_BLOB* src) { 00081 C_BLOB* blob = new C_BLOB; 00082 *blob = *src; 00083 return blob; 00084 } 00085 00086 private: 00087 C_OUTLINE_LIST outlines; //master elements 00088 }; 00089 00090 ELISTIZEH_S (C_BLOB) 00091 #endif