2007-03-08 04:03:40 +08:00
|
|
|
/**********************************************************************
|
|
|
|
* File: poutline.h (Formerly outline.h)
|
|
|
|
* Description: OUTLINE class definition.
|
|
|
|
* Author: Ray Smith
|
|
|
|
* Created: Wed Oct 23 10:42:40 BST 1991
|
|
|
|
*
|
|
|
|
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef POUTLINE_H
|
|
|
|
#define POUTLINE_H
|
|
|
|
|
2008-02-01 08:36:18 +08:00
|
|
|
#include "scrollview.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
#include "polyvert.h"
|
|
|
|
#include "rect.h"
|
|
|
|
#include "blckerr.h"
|
|
|
|
|
|
|
|
#define INTERSECTING MAX_INT16//no winding number
|
|
|
|
|
|
|
|
class OUTLINE; //forward declaration
|
|
|
|
|
|
|
|
ELISTIZEH_S (OUTLINE)
|
|
|
|
class OUTLINE:public ELIST_LINK
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OUTLINE() { //empty constructor
|
|
|
|
}
|
|
|
|
OUTLINE( //constructor
|
|
|
|
const ICOORD &startpt, //start point
|
2008-04-22 08:41:37 +08:00
|
|
|
inT8 *compactloop, //from Tess format
|
2007-03-08 04:03:40 +08:00
|
|
|
BOOL8 reverse, //reverse it
|
|
|
|
ICOORD bot_left, //bounding box
|
|
|
|
ICOORD top_right);
|
|
|
|
OUTLINE( //constructor
|
|
|
|
POLYPT_IT *poly_it); //from list of pts
|
|
|
|
|
|
|
|
OUTLINE_LIST *child() { //get child list
|
|
|
|
return &children;
|
|
|
|
}
|
|
|
|
|
|
|
|
//access function
|
2008-04-22 08:41:37 +08:00
|
|
|
const TBOX &bounding_box() const {
|
2007-03-08 04:03:40 +08:00
|
|
|
return box;
|
|
|
|
}
|
|
|
|
void compute_bb(); //set bounding box
|
|
|
|
|
|
|
|
//get start position
|
2008-04-22 08:41:37 +08:00
|
|
|
const ICOORD &start_pos() const {
|
2007-03-08 04:03:40 +08:00
|
|
|
return start;
|
|
|
|
}
|
|
|
|
float area(); //return area
|
|
|
|
POLYPT_LIST *polypts() { //get poly
|
|
|
|
return &outline;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL8 operator< ( //containment test
|
|
|
|
OUTLINE & other);
|
|
|
|
BOOL8 operator> ( //containment test
|
|
|
|
OUTLINE & other) {
|
|
|
|
return other < *this; //use the < to do it
|
|
|
|
}
|
2008-04-22 08:41:37 +08:00
|
|
|
inT16 winding_number( //get winding number
|
2007-03-08 04:03:40 +08:00
|
|
|
const FCOORD &testpt); //around this point
|
|
|
|
void reverse(); //reverse it
|
|
|
|
|
|
|
|
void move( // reposition outline
|
|
|
|
const FCOORD vec); // by FLOAT vector
|
|
|
|
|
|
|
|
void scale( // scale outline
|
|
|
|
const float f); // by multiplier
|
|
|
|
void scale( // scale outline
|
|
|
|
const FCOORD vec); // by FLOAT vector
|
|
|
|
|
2008-12-31 02:15:44 +08:00
|
|
|
void rotate( // rotate outline
|
|
|
|
const FCOORD vector); // by fcoord
|
|
|
|
|
2007-03-08 04:03:40 +08:00
|
|
|
void plot( //draw one
|
2008-02-01 08:36:18 +08:00
|
|
|
ScrollView* window, //window to draw in
|
|
|
|
ScrollView::Color colour); //colour to draw it
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
void prep_serialise() { //set ptrs to counts
|
|
|
|
outline.prep_serialise ();
|
|
|
|
children.prep_serialise ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dump( //write external bits
|
|
|
|
FILE *f) {
|
|
|
|
outline.dump (f);
|
|
|
|
children.dump (f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void de_dump( //read external bits
|
|
|
|
FILE *f) {
|
|
|
|
outline.de_dump (f);
|
|
|
|
children.de_dump (f);
|
|
|
|
}
|
|
|
|
|
|
|
|
//assignment
|
2008-12-31 02:15:44 +08:00
|
|
|
make_serialise(OUTLINE)
|
|
|
|
|
|
|
|
OUTLINE& operator=(const OUTLINE& source);
|
|
|
|
|
|
|
|
static OUTLINE* deep_copy(const OUTLINE* src) {
|
|
|
|
OUTLINE* outline = new OUTLINE;
|
|
|
|
*outline = *src;
|
|
|
|
return outline;
|
|
|
|
}
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
private:
|
2008-04-22 08:41:37 +08:00
|
|
|
TBOX box; //boudning box
|
2007-03-08 04:03:40 +08:00
|
|
|
ICOORD start; //start coord
|
|
|
|
POLYPT_LIST outline; //outline points
|
|
|
|
OUTLINE_LIST children; //child elements
|
|
|
|
};
|
|
|
|
#endif
|