From c03ffda45a51dd31e5820de5e0e00972735e93fd Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 16 Mar 2021 19:27:12 +0100 Subject: [PATCH] Replace more GenericVector by std::vector for src/ccstruct Signed-off-by: Stefan Weil --- src/ccstruct/blobs.cpp | 21 ++++++++++----------- src/ccstruct/blobs.h | 8 ++++---- src/ccstruct/normalis.cpp | 8 ++++---- src/ccstruct/normalis.h | 6 +++--- src/classify/intfx.cpp | 4 ++-- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/ccstruct/blobs.cpp b/src/ccstruct/blobs.cpp index 178ff930b..b1958f922 100644 --- a/src/ccstruct/blobs.cpp +++ b/src/ccstruct/blobs.cpp @@ -542,11 +542,10 @@ void TBLOB::GetPreciseBoundingBox(TBOX *precise_box) const { // x-coord starting at box.left(). // Eg x_coords[0] is a collection of the x-coords of edges at y=bottom. // Eg x_coords[1] is a collection of the x-coords of edges at y=bottom + 1. -void TBLOB::GetEdgeCoords(const TBOX &box, GenericVector> *x_coords, - GenericVector> *y_coords) const { - GenericVector empty; - x_coords->init_to_size(box.height(), empty); - y_coords->init_to_size(box.width(), empty); +void TBLOB::GetEdgeCoords(const TBOX &box, std::vector> *x_coords, + std::vector> *y_coords) const { + x_coords->resize(box.height()); + y_coords->resize(box.width()); CollectEdges(box, nullptr, nullptr, x_coords, y_coords); // Sort the output vectors. for (int i = 0; i < x_coords->size(); ++i) @@ -585,8 +584,8 @@ static void SegmentLLSQ(const FCOORD &pt1, const FCOORD &pt2, LLSQ *accumulator) // are clipped to ([0,x_limit], [0,y_limit]). // See GetEdgeCoords above for a description of x_coords, y_coords. static void SegmentCoords(const FCOORD &pt1, const FCOORD &pt2, int x_limit, int y_limit, - GenericVector> *x_coords, - GenericVector> *y_coords) { + std::vector> *x_coords, + std::vector> *y_coords) { FCOORD step(pt2); step -= pt1; int start = ClipToRange(IntCastRounded(std::min(pt1.x(), pt2.x())), 0, x_limit); @@ -639,8 +638,8 @@ static void SegmentBBox(const FCOORD &pt1, const FCOORD &pt2, TBOX *bbox) { // indices into x_coords, y_coords are offset by box.botleft(). static void CollectEdgesOfRun(const EDGEPT *startpt, const EDGEPT *lastpt, const DENORM &denorm, const TBOX &box, TBOX *bounding_box, LLSQ *accumulator, - GenericVector> *x_coords, - GenericVector> *y_coords) { + std::vector> *x_coords, + std::vector> *y_coords) { const C_OUTLINE *outline = startpt->src_outline; int x_limit = box.width() - 1; int y_limit = box.height() - 1; @@ -727,8 +726,8 @@ static void CollectEdgesOfRun(const EDGEPT *startpt, const EDGEPT *lastpt, const // normalization. // For a description of x_coords, y_coords, see GetEdgeCoords above. void TBLOB::CollectEdges(const TBOX &box, TBOX *bounding_box, LLSQ *llsq, - GenericVector> *x_coords, - GenericVector> *y_coords) const { + std::vector> *x_coords, + std::vector> *y_coords) const { // Iterate the outlines. for (const TESSLINE *ol = outlines; ol != nullptr; ol = ol->next) { // Iterate the polygon. diff --git a/src/ccstruct/blobs.h b/src/ccstruct/blobs.h index 683129fca..8ca2d0701 100644 --- a/src/ccstruct/blobs.h +++ b/src/ccstruct/blobs.h @@ -391,8 +391,8 @@ struct TBLOB { // x-coord starting at box.left(). // Eg x_coords[0] is a collection of the x-coords of edges at y=bottom. // Eg x_coords[1] is a collection of the x-coords of edges at y=bottom + 1. - void GetEdgeCoords(const TBOX &box, GenericVector> *x_coords, - GenericVector> *y_coords) const; + void GetEdgeCoords(const TBOX &box, std::vector> *x_coords, + std::vector> *y_coords) const; TESSLINE *outlines; // List of outlines in blob. @@ -403,8 +403,8 @@ private: // TODO(rays) Someday the data members will be private too. // normalization. // For a description of x_coords, y_coords, see GetEdgeCoords above. void CollectEdges(const TBOX &box, TBOX *bounding_box, LLSQ *llsq, - GenericVector> *x_coords, - GenericVector> *y_coords) const; + std::vector> *x_coords, + std::vector> *y_coords) const; private: // DENORM indicating the transformations that this blob has undergone so far. diff --git a/src/ccstruct/normalis.cpp b/src/ccstruct/normalis.cpp index 919c29495..37186e255 100644 --- a/src/ccstruct/normalis.cpp +++ b/src/ccstruct/normalis.cpp @@ -153,8 +153,8 @@ void DENORM::SetupNormalization(const BLOCK *block, const FCOORD *rotation, // pre-initialized to be the same size as box. Each element will contain the // minimum of x and y run-length as shown above. static void ComputeRunlengthImage(const TBOX &box, - const GenericVector> &x_coords, - const GenericVector> &y_coords, + const std::vector> &x_coords, + const std::vector> &y_coords, GENERIC_2D_ARRAY *minruns) { int width = box.width(); int height = box.height(); @@ -264,8 +264,8 @@ static void ComputeEdgeDensityProfiles(const TBOX &box, const GENERIC_2D_ARRAY> &x_coords, - const GenericVector> &y_coords) { + const std::vector> &x_coords, + const std::vector> &y_coords) { Clear(); predecessor_ = predecessor; // x_map_ and y_map_ store a mapping from input x and y coordinate to output diff --git a/src/ccstruct/normalis.h b/src/ccstruct/normalis.h index 8f44eed56..67d0b5991 100644 --- a/src/ccstruct/normalis.h +++ b/src/ccstruct/normalis.h @@ -2,7 +2,6 @@ * File: normalis.h (Formerly denorm.h) * Description: Code for the DENORM class. * Author: Ray Smith - * Created: Thu Apr 23 09:22:43 BST 1992 * * (C) Copyright 1992, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,6 +19,7 @@ #ifndef NORMALIS_H #define NORMALIS_H +#include #include struct Pix; @@ -193,8 +193,8 @@ public: // The second-level vectors must all be sorted in ascending order. void SetupNonLinear(const DENORM *predecessor, const TBOX &box, float target_width, float target_height, float final_xshift, float final_yshift, - const GenericVector> &x_coords, - const GenericVector> &y_coords); + const std::vector> &x_coords, + const std::vector> &y_coords); // Transforms the given coords one step forward to normalized space, without // using any block rotation or predecessor. diff --git a/src/classify/intfx.cpp b/src/classify/intfx.cpp index fc4a436f0..fe512de45 100644 --- a/src/classify/intfx.cpp +++ b/src/classify/intfx.cpp @@ -144,8 +144,8 @@ void Classify::SetupBLCNDenorms(const TBLOB &blob, bool nonlinear_norm, DENORM * 128.0f, 128.0f); // Setup the denorm for character normalization. if (nonlinear_norm) { - GenericVector> x_coords; - GenericVector> y_coords; + std::vector> x_coords; + std::vector> y_coords; TBOX box; blob.GetPreciseBoundingBox(&box); box.pad(1, 1);