00001 /********************************************************************** 00002 * File: poutline.h (Formerly outline.h) 00003 * Description: OUTLINE class definition. 00004 * Author: Ray Smith 00005 * Created: Wed Oct 23 10:42:40 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 POUTLINE_H 00021 #define POUTLINE_H 00022 00023 #include "scrollview.h" 00024 #include "polyvert.h" 00025 #include "rect.h" 00026 #include "blckerr.h" 00027 00028 #define INTERSECTING MAX_INT16//no winding number 00029 00030 class OUTLINE; //forward declaration 00031 00032 ELISTIZEH_S (OUTLINE) 00033 class OUTLINE:public ELIST_LINK 00034 { 00035 public: 00036 OUTLINE() { //empty constructor 00037 } 00038 OUTLINE( //constructor 00039 const ICOORD &startpt, //start point 00040 inT8 *compactloop, //from Tess format 00041 BOOL8 reverse, //reverse it 00042 ICOORD bot_left, //bounding box 00043 ICOORD top_right); 00044 OUTLINE( //constructor 00045 POLYPT_IT *poly_it); //from list of pts 00046 00047 OUTLINE_LIST *child() { //get child list 00048 return &children; 00049 } 00050 00051 //access function 00052 const TBOX &bounding_box() const { 00053 return box; 00054 } 00055 void compute_bb(); //set bounding box 00056 00057 //get start position 00058 const ICOORD &start_pos() const { 00059 return start; 00060 } 00061 float area(); //return area 00062 POLYPT_LIST *polypts() { //get poly 00063 return &outline; 00064 } 00065 00066 BOOL8 operator< ( //containment test 00067 OUTLINE & other); 00068 BOOL8 operator> ( //containment test 00069 OUTLINE & other) { 00070 return other < *this; //use the < to do it 00071 } 00072 inT16 winding_number( //get winding number 00073 const FCOORD &testpt); //around this point 00074 void reverse(); //reverse it 00075 00076 void move( // reposition outline 00077 const FCOORD vec); // by FLOAT vector 00078 00079 void scale( // scale outline 00080 const float f); // by multiplier 00081 void scale( // scale outline 00082 const FCOORD vec); // by FLOAT vector 00083 00084 void rotate( // rotate outline 00085 const FCOORD vector); // by fcoord 00086 00087 void plot( //draw one 00088 ScrollView* window, //window to draw in 00089 ScrollView::Color colour); //colour to draw it 00090 00091 void prep_serialise() { //set ptrs to counts 00092 outline.prep_serialise (); 00093 children.prep_serialise (); 00094 } 00095 00096 void dump( //write external bits 00097 FILE *f) { 00098 outline.dump (f); 00099 children.dump (f); 00100 } 00101 00102 void de_dump( //read external bits 00103 FILE *f) { 00104 outline.de_dump (f); 00105 children.de_dump (f); 00106 } 00107 00108 //assignment 00109 make_serialise(OUTLINE) 00110 00111 OUTLINE& operator=(const OUTLINE& source); 00112 00113 static OUTLINE* deep_copy(const OUTLINE* src) { 00114 OUTLINE* outline = new OUTLINE; 00115 *outline = *src; 00116 return outline; 00117 } 00118 00119 private: 00120 TBOX box; //boudning box 00121 ICOORD start; //start coord 00122 POLYPT_LIST outline; //outline points 00123 OUTLINE_LIST children; //child elements 00124 }; 00125 #endif