Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/tesseract/src/ccstruct/polyblk.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /********************************************************************** | |
| 2 * File: polyblk.h (Formerly poly_block.h) | |
| 3 * Description: Polygonal blocks | |
| 4 * | |
| 5 * (C) Copyright 1993, Hewlett-Packard Ltd. | |
| 6 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
| 7 ** you may not use this file except in compliance with the License. | |
| 8 ** You may obtain a copy of the License at | |
| 9 ** http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 ** Unless required by applicable law or agreed to in writing, software | |
| 11 ** distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 ** See the License for the specific language governing permissions and | |
| 14 ** limitations under the License. | |
| 15 * | |
| 16 **********************************************************************/ | |
| 17 | |
| 18 #ifndef POLYBLK_H | |
| 19 #define POLYBLK_H | |
| 20 | |
| 21 #include "elst.h" | |
| 22 #include "points.h" | |
| 23 #include "rect.h" | |
| 24 #include "scrollview.h" | |
| 25 | |
| 26 #include <tesseract/publictypes.h> | |
| 27 | |
| 28 namespace tesseract { | |
| 29 | |
| 30 class TESS_API POLY_BLOCK { | |
| 31 public: | |
| 32 POLY_BLOCK() = default; | |
| 33 // Initialize from box coordinates. | |
| 34 POLY_BLOCK(const TBOX &tbox, PolyBlockType type); | |
| 35 POLY_BLOCK(ICOORDELT_LIST *points, PolyBlockType type); | |
| 36 ~POLY_BLOCK() = default; | |
| 37 | |
| 38 TBOX *bounding_box() { // access function | |
| 39 return &box; | |
| 40 } | |
| 41 | |
| 42 ICOORDELT_LIST *points() { // access function | |
| 43 return &vertices; | |
| 44 } | |
| 45 | |
| 46 void compute_bb(); | |
| 47 | |
| 48 PolyBlockType isA() const { | |
| 49 return type; | |
| 50 } | |
| 51 | |
| 52 bool IsText() const { | |
| 53 return PTIsTextType(type); | |
| 54 } | |
| 55 | |
| 56 // Rotate about the origin by the given rotation. (Analogous to | |
| 57 // multiplying by a complex number. | |
| 58 void rotate(FCOORD rotation); | |
| 59 // Reflect the coords of the polygon in the y-axis. (Flip the sign of x.) | |
| 60 void reflect_in_y_axis(); | |
| 61 // Move by adding shift to all coordinates. | |
| 62 void move(ICOORD shift); | |
| 63 | |
| 64 #ifndef GRAPHICS_DISABLED | |
| 65 | |
| 66 void plot(ScrollView *window, int32_t num); | |
| 67 | |
| 68 void fill(ScrollView *window, ScrollView::Color colour); | |
| 69 #endif // !GRAPHICS_DISABLED | |
| 70 | |
| 71 // Returns true if other is inside this. | |
| 72 bool contains(POLY_BLOCK *other); | |
| 73 | |
| 74 // Returns true if the polygons of other and this overlap. | |
| 75 bool overlap(POLY_BLOCK *other); | |
| 76 | |
| 77 // Returns the winding number of this around the test_pt. | |
| 78 // Positive for anticlockwise, negative for clockwise, and zero for | |
| 79 // test_pt outside this. | |
| 80 int16_t winding_number(const ICOORD &test_pt); | |
| 81 | |
| 82 #ifndef GRAPHICS_DISABLED | |
| 83 // Static utility functions to handle the PolyBlockType. | |
| 84 // Returns a color to draw the given type. | |
| 85 static ScrollView::Color ColorForPolyBlockType(PolyBlockType type); | |
| 86 #endif // !GRAPHICS_DISABLED | |
| 87 | |
| 88 private: | |
| 89 ICOORDELT_LIST vertices; // vertices | |
| 90 TBOX box; // bounding box | |
| 91 PolyBlockType type; // Type of this region. | |
| 92 }; | |
| 93 | |
| 94 // Class to iterate the scanlines of a polygon. | |
| 95 class PB_LINE_IT { | |
| 96 public: | |
| 97 PB_LINE_IT(POLY_BLOCK *blkptr) { | |
| 98 block = blkptr; | |
| 99 } | |
| 100 | |
| 101 void set_to_block(POLY_BLOCK *blkptr) { | |
| 102 block = blkptr; | |
| 103 } | |
| 104 | |
| 105 // Returns a list of runs of pixels for the given y coord. | |
| 106 // Each element of the returned list is the start (x) and extent(y) of | |
| 107 // a run inside the region. | |
| 108 // Delete the returned list after use. | |
| 109 ICOORDELT_LIST *get_line(TDimension y); | |
| 110 | |
| 111 private: | |
| 112 POLY_BLOCK *block; | |
| 113 }; | |
| 114 | |
| 115 } // namespace tesseract | |
| 116 | |
| 117 #endif |
