diff --git a/src/ccstruct/Makefile.am b/src/ccstruct/Makefile.am index ed4e6fd751..dddd1de28f 100644 --- a/src/ccstruct/Makefile.am +++ b/src/ccstruct/Makefile.am @@ -16,7 +16,6 @@ noinst_HEADERS = \ ccstruct.h coutln.h crakedge.h \ debugpixa.h detlinefit.h dppoint.h fontinfo.h \ imagedata.h \ - ipoints.h \ linlsq.h matrix.h mod128.h normalis.h \ ocrblock.h ocrpara.h ocrrow.h otsuthr.h \ pageres.h params_training_featdef.h \ diff --git a/src/ccstruct/blobbox.cpp b/src/ccstruct/blobbox.cpp index 106921c0c7..71a3a9988a 100644 --- a/src/ccstruct/blobbox.cpp +++ b/src/ccstruct/blobbox.cpp @@ -31,7 +31,7 @@ #include "environ.h" // for l_uint32 #include "helpers.h" // for UpdateRange, IntCastRounded #include "host.h" // for NearlyEqual, TRUE -#include "ipoints.h" // for operator+=, ICOORD::rotate +#include "points.h" // for operator+=, ICOORD::rotate struct Pix; diff --git a/src/ccstruct/coutln.h b/src/ccstruct/coutln.h index 6de78283f9..4cb4fc9eff 100644 --- a/src/ccstruct/coutln.h +++ b/src/ccstruct/coutln.h @@ -23,7 +23,6 @@ #include // for int16_t, int32_t #include "bits16.h" // for BITS16 #include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK -#include "ipoints.h" // for operator+= #include "mod128.h" // for DIR128, DIRBITS #include "platform.h" // for DLLSYM #include "points.h" // for ICOORD, FCOORD diff --git a/src/ccstruct/ipoints.h b/src/ccstruct/ipoints.h deleted file mode 100644 index d5fbd30282..0000000000 --- a/src/ccstruct/ipoints.h +++ /dev/null @@ -1,485 +0,0 @@ -/********************************************************************** - * File: ipoints.h (Formerly icoords.h) - * Description: Inline functions for coords.h. - * Author: Ray Smith - * Created: Fri Jun 21 15:14:21 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 IPOINTS_H -#define IPOINTS_H - -#include -#include "points.h" // ICOORD - -/********************************************************************** - * operator! - * - * Rotate an ICOORD 90 degrees anticlockwise. - **********************************************************************/ - -inline ICOORD -operator! ( //rotate 90 deg anti -const ICOORD & src //thing to rotate -) { - ICOORD result; //output - - result.xcoord = -src.ycoord; - result.ycoord = src.xcoord; - return result; -} - - -/********************************************************************** - * operator- - * - * Unary minus of an ICOORD. - **********************************************************************/ - -inline ICOORD -operator- ( //unary minus -const ICOORD & src //thing to minus -) { - ICOORD result; //output - - result.xcoord = -src.xcoord; - result.ycoord = -src.ycoord; - return result; -} - - -/********************************************************************** - * operator+ - * - * Add 2 ICOORDS. - **********************************************************************/ - -inline ICOORD -operator+ ( //sum vectors -const ICOORD & op1, //operands -const ICOORD & op2) { - ICOORD sum; //result - - sum.xcoord = op1.xcoord + op2.xcoord; - sum.ycoord = op1.ycoord + op2.ycoord; - return sum; -} - - -/********************************************************************** - * operator+= - * - * Add 2 ICOORDS. - **********************************************************************/ - -inline ICOORD & -operator+= ( //sum vectors -ICOORD & op1, //operands -const ICOORD & op2) { - op1.xcoord += op2.xcoord; - op1.ycoord += op2.ycoord; - return op1; -} - - -/********************************************************************** - * operator- - * - * Subtract 2 ICOORDS. - **********************************************************************/ - -inline ICOORD -operator- ( //subtract vectors -const ICOORD & op1, //operands -const ICOORD & op2) { - ICOORD sum; //result - - sum.xcoord = op1.xcoord - op2.xcoord; - sum.ycoord = op1.ycoord - op2.ycoord; - return sum; -} - - -/********************************************************************** - * operator-= - * - * Subtract 2 ICOORDS. - **********************************************************************/ - -inline ICOORD & -operator-= ( //sum vectors -ICOORD & op1, //operands -const ICOORD & op2) { - op1.xcoord -= op2.xcoord; - op1.ycoord -= op2.ycoord; - return op1; -} - - -/********************************************************************** - * operator% - * - * Scalar product of 2 ICOORDS. - **********************************************************************/ - -inline int32_t -operator% ( //scalar product -const ICOORD & op1, //operands -const ICOORD & op2) { - return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord; -} - - -/********************************************************************** - * operator* - * - * Cross product of 2 ICOORDS. - **********************************************************************/ - -inline int32_t operator *( //cross product - const ICOORD &op1, //operands - const ICOORD &op2) { - return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord; -} - - -/********************************************************************** - * operator* - * - * Scalar multiply of an ICOORD. - **********************************************************************/ - -inline ICOORD operator *( //scalar multiply - const ICOORD &op1, //operands - int16_t scale) { - ICOORD result; //output - - result.xcoord = op1.xcoord * scale; - result.ycoord = op1.ycoord * scale; - return result; -} - - -inline ICOORD operator *( //scalar multiply - int16_t scale, - const ICOORD &op1 //operands - ) { - ICOORD result; //output - - result.xcoord = op1.xcoord * scale; - result.ycoord = op1.ycoord * scale; - return result; -} - - -/********************************************************************** - * operator*= - * - * Scalar multiply of an ICOORD. - **********************************************************************/ - -inline ICOORD & -operator*= ( //scalar multiply -ICOORD & op1, //operands -int16_t scale) { - op1.xcoord *= scale; - op1.ycoord *= scale; - return op1; -} - - -/********************************************************************** - * operator/ - * - * Scalar divide of an ICOORD. - **********************************************************************/ - -inline ICOORD -operator/ ( //scalar divide -const ICOORD & op1, //operands -int16_t scale) { - ICOORD result; //output - - result.xcoord = op1.xcoord / scale; - result.ycoord = op1.ycoord / scale; - return result; -} - - -/********************************************************************** - * operator/= - * - * Scalar divide of an ICOORD. - **********************************************************************/ - -inline ICOORD & -operator/= ( //scalar divide -ICOORD & op1, //operands -int16_t scale) { - op1.xcoord /= scale; - op1.ycoord /= scale; - return op1; -} - - -/********************************************************************** - * ICOORD::rotate - * - * Rotate an ICOORD by the given (normalized) (cos,sin) vector. - **********************************************************************/ - -inline void ICOORD::rotate( //rotate by vector - const FCOORD& vec) { - int16_t tmp; - - tmp = (int16_t) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5); - ycoord = (int16_t) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5); - xcoord = tmp; -} - - -/********************************************************************** - * operator! - * - * Rotate an FCOORD 90 degrees anticlockwise. - **********************************************************************/ - -inline FCOORD -operator! ( //rotate 90 deg anti -const FCOORD & src //thing to rotate -) { - FCOORD result; //output - - result.xcoord = -src.ycoord; - result.ycoord = src.xcoord; - return result; -} - - -/********************************************************************** - * operator- - * - * Unary minus of an FCOORD. - **********************************************************************/ - -inline FCOORD -operator- ( //unary minus -const FCOORD & src //thing to minus -) { - FCOORD result; //output - - result.xcoord = -src.xcoord; - result.ycoord = -src.ycoord; - return result; -} - - -/********************************************************************** - * operator+ - * - * Add 2 FCOORDS. - **********************************************************************/ - -inline FCOORD -operator+ ( //sum vectors -const FCOORD & op1, //operands -const FCOORD & op2) { - FCOORD sum; //result - - sum.xcoord = op1.xcoord + op2.xcoord; - sum.ycoord = op1.ycoord + op2.ycoord; - return sum; -} - - -/********************************************************************** - * operator+= - * - * Add 2 FCOORDS. - **********************************************************************/ - -inline FCOORD & -operator+= ( //sum vectors -FCOORD & op1, //operands -const FCOORD & op2) { - op1.xcoord += op2.xcoord; - op1.ycoord += op2.ycoord; - return op1; -} - - -/********************************************************************** - * operator- - * - * Subtract 2 FCOORDS. - **********************************************************************/ - -inline FCOORD -operator- ( //subtract vectors -const FCOORD & op1, //operands -const FCOORD & op2) { - FCOORD sum; //result - - sum.xcoord = op1.xcoord - op2.xcoord; - sum.ycoord = op1.ycoord - op2.ycoord; - return sum; -} - - -/********************************************************************** - * operator-= - * - * Subtract 2 FCOORDS. - **********************************************************************/ - -inline FCOORD & -operator-= ( //sum vectors -FCOORD & op1, //operands -const FCOORD & op2) { - op1.xcoord -= op2.xcoord; - op1.ycoord -= op2.ycoord; - return op1; -} - - -/********************************************************************** - * operator% - * - * Scalar product of 2 FCOORDS. - **********************************************************************/ - -inline float -operator% ( //scalar product -const FCOORD & op1, //operands -const FCOORD & op2) { - return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord; -} - - -/********************************************************************** - * operator* - * - * Cross product of 2 FCOORDS. - **********************************************************************/ - -inline float operator *( //cross product - const FCOORD &op1, //operands - const FCOORD &op2) { - return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord; -} - - -/********************************************************************** - * operator* - * - * Scalar multiply of an FCOORD. - **********************************************************************/ - -inline FCOORD operator *( //scalar multiply - const FCOORD &op1, //operands - float scale) { - FCOORD result; //output - - result.xcoord = op1.xcoord * scale; - result.ycoord = op1.ycoord * scale; - return result; -} - - -inline FCOORD operator *( //scalar multiply - float scale, - const FCOORD &op1 //operands - ) { - FCOORD result; //output - - result.xcoord = op1.xcoord * scale; - result.ycoord = op1.ycoord * scale; - return result; -} - - -/********************************************************************** - * operator*= - * - * Scalar multiply of an FCOORD. - **********************************************************************/ - -inline FCOORD & -operator*= ( //scalar multiply -FCOORD & op1, //operands -float scale) { - op1.xcoord *= scale; - op1.ycoord *= scale; - return op1; -} - - -/********************************************************************** - * operator/ - * - * Scalar divide of an FCOORD. - **********************************************************************/ - -inline FCOORD -operator/ ( //scalar divide -const FCOORD & op1, //operands -float scale) { - FCOORD result; //output - - if (scale != 0) { - result.xcoord = op1.xcoord / scale; - result.ycoord = op1.ycoord / scale; - } - return result; -} - - -/********************************************************************** - * operator/= - * - * Scalar divide of an FCOORD. - **********************************************************************/ - -inline FCOORD & -operator/= ( //scalar divide -FCOORD & op1, //operands -float scale) { - if (scale != 0) { - op1.xcoord /= scale; - op1.ycoord /= scale; - } - return op1; -} - - -/********************************************************************** - * rotate - * - * Rotate an FCOORD by the given (normalized) (cos,sin) vector. - **********************************************************************/ - -inline void FCOORD::rotate( //rotate by vector - const FCOORD vec) { - float tmp; - - tmp = xcoord * vec.x () - ycoord * vec.y (); - ycoord = ycoord * vec.x () + xcoord * vec.y (); - xcoord = tmp; -} - -inline void FCOORD::unrotate(const FCOORD& vec) { - rotate(FCOORD(vec.x(), -vec.y())); -} - -#endif diff --git a/src/ccstruct/points.h b/src/ccstruct/points.h index 00f7aff7dc..ea7516a011 100644 --- a/src/ccstruct/points.h +++ b/src/ccstruct/points.h @@ -317,5 +317,463 @@ class DLLSYM FCOORD float ycoord; }; -#include "ipoints.h" /*do inline funcs */ +/********************************************************************** + * operator! + * + * Rotate an ICOORD 90 degrees anticlockwise. + **********************************************************************/ + +inline ICOORD +operator! ( //rotate 90 deg anti +const ICOORD & src //thing to rotate +) { + ICOORD result; //output + + result.xcoord = -src.ycoord; + result.ycoord = src.xcoord; + return result; +} + + +/********************************************************************** + * operator- + * + * Unary minus of an ICOORD. + **********************************************************************/ + +inline ICOORD +operator- ( //unary minus +const ICOORD & src //thing to minus +) { + ICOORD result; //output + + result.xcoord = -src.xcoord; + result.ycoord = -src.ycoord; + return result; +} + + +/********************************************************************** + * operator+ + * + * Add 2 ICOORDS. + **********************************************************************/ + +inline ICOORD +operator+ ( //sum vectors +const ICOORD & op1, //operands +const ICOORD & op2) { + ICOORD sum; //result + + sum.xcoord = op1.xcoord + op2.xcoord; + sum.ycoord = op1.ycoord + op2.ycoord; + return sum; +} + + +/********************************************************************** + * operator+= + * + * Add 2 ICOORDS. + **********************************************************************/ + +inline ICOORD & +operator+= ( //sum vectors +ICOORD & op1, //operands +const ICOORD & op2) { + op1.xcoord += op2.xcoord; + op1.ycoord += op2.ycoord; + return op1; +} + + +/********************************************************************** + * operator- + * + * Subtract 2 ICOORDS. + **********************************************************************/ + +inline ICOORD +operator- ( //subtract vectors +const ICOORD & op1, //operands +const ICOORD & op2) { + ICOORD sum; //result + + sum.xcoord = op1.xcoord - op2.xcoord; + sum.ycoord = op1.ycoord - op2.ycoord; + return sum; +} + + +/********************************************************************** + * operator-= + * + * Subtract 2 ICOORDS. + **********************************************************************/ + +inline ICOORD & +operator-= ( //sum vectors +ICOORD & op1, //operands +const ICOORD & op2) { + op1.xcoord -= op2.xcoord; + op1.ycoord -= op2.ycoord; + return op1; +} + + +/********************************************************************** + * operator% + * + * Scalar product of 2 ICOORDS. + **********************************************************************/ + +inline int32_t +operator% ( //scalar product +const ICOORD & op1, //operands +const ICOORD & op2) { + return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord; +} + + +/********************************************************************** + * operator* + * + * Cross product of 2 ICOORDS. + **********************************************************************/ + +inline int32_t operator *( //cross product + const ICOORD &op1, //operands + const ICOORD &op2) { + return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord; +} + + +/********************************************************************** + * operator* + * + * Scalar multiply of an ICOORD. + **********************************************************************/ + +inline ICOORD operator *( //scalar multiply + const ICOORD &op1, //operands + int16_t scale) { + ICOORD result; //output + + result.xcoord = op1.xcoord * scale; + result.ycoord = op1.ycoord * scale; + return result; +} + + +inline ICOORD operator *( //scalar multiply + int16_t scale, + const ICOORD &op1 //operands + ) { + ICOORD result; //output + + result.xcoord = op1.xcoord * scale; + result.ycoord = op1.ycoord * scale; + return result; +} + + +/********************************************************************** + * operator*= + * + * Scalar multiply of an ICOORD. + **********************************************************************/ + +inline ICOORD & +operator*= ( //scalar multiply +ICOORD & op1, //operands +int16_t scale) { + op1.xcoord *= scale; + op1.ycoord *= scale; + return op1; +} + + +/********************************************************************** + * operator/ + * + * Scalar divide of an ICOORD. + **********************************************************************/ + +inline ICOORD +operator/ ( //scalar divide +const ICOORD & op1, //operands +int16_t scale) { + ICOORD result; //output + + result.xcoord = op1.xcoord / scale; + result.ycoord = op1.ycoord / scale; + return result; +} + + +/********************************************************************** + * operator/= + * + * Scalar divide of an ICOORD. + **********************************************************************/ + +inline ICOORD & +operator/= ( //scalar divide +ICOORD & op1, //operands +int16_t scale) { + op1.xcoord /= scale; + op1.ycoord /= scale; + return op1; +} + + +/********************************************************************** + * ICOORD::rotate + * + * Rotate an ICOORD by the given (normalized) (cos,sin) vector. + **********************************************************************/ + +inline void ICOORD::rotate( //rotate by vector + const FCOORD& vec) { + int16_t tmp; + + tmp = (int16_t) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5); + ycoord = (int16_t) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5); + xcoord = tmp; +} + + +/********************************************************************** + * operator! + * + * Rotate an FCOORD 90 degrees anticlockwise. + **********************************************************************/ + +inline FCOORD +operator! ( //rotate 90 deg anti +const FCOORD & src //thing to rotate +) { + FCOORD result; //output + + result.xcoord = -src.ycoord; + result.ycoord = src.xcoord; + return result; +} + + +/********************************************************************** + * operator- + * + * Unary minus of an FCOORD. + **********************************************************************/ + +inline FCOORD +operator- ( //unary minus +const FCOORD & src //thing to minus +) { + FCOORD result; //output + + result.xcoord = -src.xcoord; + result.ycoord = -src.ycoord; + return result; +} + + +/********************************************************************** + * operator+ + * + * Add 2 FCOORDS. + **********************************************************************/ + +inline FCOORD +operator+ ( //sum vectors +const FCOORD & op1, //operands +const FCOORD & op2) { + FCOORD sum; //result + + sum.xcoord = op1.xcoord + op2.xcoord; + sum.ycoord = op1.ycoord + op2.ycoord; + return sum; +} + + +/********************************************************************** + * operator+= + * + * Add 2 FCOORDS. + **********************************************************************/ + +inline FCOORD & +operator+= ( //sum vectors +FCOORD & op1, //operands +const FCOORD & op2) { + op1.xcoord += op2.xcoord; + op1.ycoord += op2.ycoord; + return op1; +} + + +/********************************************************************** + * operator- + * + * Subtract 2 FCOORDS. + **********************************************************************/ + +inline FCOORD +operator- ( //subtract vectors +const FCOORD & op1, //operands +const FCOORD & op2) { + FCOORD sum; //result + + sum.xcoord = op1.xcoord - op2.xcoord; + sum.ycoord = op1.ycoord - op2.ycoord; + return sum; +} + + +/********************************************************************** + * operator-= + * + * Subtract 2 FCOORDS. + **********************************************************************/ + +inline FCOORD & +operator-= ( //sum vectors +FCOORD & op1, //operands +const FCOORD & op2) { + op1.xcoord -= op2.xcoord; + op1.ycoord -= op2.ycoord; + return op1; +} + + +/********************************************************************** + * operator% + * + * Scalar product of 2 FCOORDS. + **********************************************************************/ + +inline float +operator% ( //scalar product +const FCOORD & op1, //operands +const FCOORD & op2) { + return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord; +} + + +/********************************************************************** + * operator* + * + * Cross product of 2 FCOORDS. + **********************************************************************/ + +inline float operator *( //cross product + const FCOORD &op1, //operands + const FCOORD &op2) { + return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord; +} + + +/********************************************************************** + * operator* + * + * Scalar multiply of an FCOORD. + **********************************************************************/ + +inline FCOORD operator *( //scalar multiply + const FCOORD &op1, //operands + float scale) { + FCOORD result; //output + + result.xcoord = op1.xcoord * scale; + result.ycoord = op1.ycoord * scale; + return result; +} + + +inline FCOORD operator *( //scalar multiply + float scale, + const FCOORD &op1 //operands + ) { + FCOORD result; //output + + result.xcoord = op1.xcoord * scale; + result.ycoord = op1.ycoord * scale; + return result; +} + + +/********************************************************************** + * operator*= + * + * Scalar multiply of an FCOORD. + **********************************************************************/ + +inline FCOORD & +operator*= ( //scalar multiply +FCOORD & op1, //operands +float scale) { + op1.xcoord *= scale; + op1.ycoord *= scale; + return op1; +} + + +/********************************************************************** + * operator/ + * + * Scalar divide of an FCOORD. + **********************************************************************/ + +inline FCOORD +operator/ ( //scalar divide +const FCOORD & op1, //operands +float scale) { + FCOORD result; //output + + if (scale != 0) { + result.xcoord = op1.xcoord / scale; + result.ycoord = op1.ycoord / scale; + } + return result; +} + + +/********************************************************************** + * operator/= + * + * Scalar divide of an FCOORD. + **********************************************************************/ + +inline FCOORD & +operator/= ( //scalar divide +FCOORD & op1, //operands +float scale) { + if (scale != 0) { + op1.xcoord /= scale; + op1.ycoord /= scale; + } + return op1; +} + + +/********************************************************************** + * rotate + * + * Rotate an FCOORD by the given (normalized) (cos,sin) vector. + **********************************************************************/ + +inline void FCOORD::rotate( //rotate by vector + const FCOORD vec) { + float tmp; + + tmp = xcoord * vec.x () - ycoord * vec.y (); + ycoord = ycoord * vec.x () + xcoord * vec.y (); + xcoord = tmp; +} + +inline void FCOORD::unrotate(const FCOORD& vec) { + rotate(FCOORD(vec.x(), -vec.y())); +} + #endif diff --git a/src/ccstruct/polyaprx.cpp b/src/ccstruct/polyaprx.cpp index 62b198b14f..4328217644 100644 --- a/src/ccstruct/polyaprx.cpp +++ b/src/ccstruct/polyaprx.cpp @@ -23,7 +23,6 @@ #include "coutln.h" // for C_OUTLINE #include "errcode.h" // for ASSERT_HOST #include "host.h" // for FALSE, TRUE -#include "ipoints.h" // for operator+=, operator*= #include "mod128.h" // for DIR128 #include "params.h" // for BoolParam, BOOL_VAR #include "points.h" // for ICOORD diff --git a/src/ccstruct/rect.h b/src/ccstruct/rect.h index 978687ce49..50583f3a26 100644 --- a/src/ccstruct/rect.h +++ b/src/ccstruct/rect.h @@ -24,7 +24,6 @@ #include // for ceil, floor #include // for INT16_MAX #include // for FILE -#include "ipoints.h" // for operator+=, operator-=, ICOORD::rotate #include "platform.h" // for DLLSYM #include "points.h" // for ICOORD, FCOORD #include "scrollview.h" // for ScrollView, ScrollView::Color diff --git a/src/ccstruct/stepblob.cpp b/src/ccstruct/stepblob.cpp index af77122e48..d0c4a0d251 100644 --- a/src/ccstruct/stepblob.cpp +++ b/src/ccstruct/stepblob.cpp @@ -26,7 +26,7 @@ #include "allheaders.h" // for pixCreate, pixGetDepth #include "genericvector.h" // for GenericVector #include "host.h" // for TRUE, FALSE -#include "ipoints.h" // for operator+= +#include "points.h" // for operator+=, FCOORD, ICOORD class DENORM;