tesseract  5.0.0-alpha-619-ge9db
intproto.cpp File Reference
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cassert>
#include "classify.h"
#include "callcpp.h"
#include "emalloc.h"
#include "fontinfo.h"
#include <tesseract/genericvector.h>
#include <tesseract/helpers.h>
#include "intproto.h"
#include "mfoutline.h"
#include "picofeat.h"
#include "points.h"
#include "shapetable.h"
#include "svmnode.h"

Go to the source code of this file.

Classes

struct  FILL_SWITCH
 
struct  TABLE_FILLER
 
struct  FILL_SPEC
 

Namespaces

 tesseract
 

Macros

#define _USE_MATH_DEFINES
 
#define PROTO_PRUNER_SCALE   (4.0)
 
#define INT_DESCENDER   (0.0 * INT_CHAR_NORM_RANGE)
 
#define INT_BASELINE   (0.25 * INT_CHAR_NORM_RANGE)
 
#define INT_XHEIGHT   (0.75 * INT_CHAR_NORM_RANGE)
 
#define INT_CAPHEIGHT   (1.0 * INT_CHAR_NORM_RANGE)
 
#define INT_XCENTER   (0.5 * INT_CHAR_NORM_RANGE)
 
#define INT_YCENTER   (0.5 * INT_CHAR_NORM_RANGE)
 
#define INT_XRADIUS   (0.2 * INT_CHAR_NORM_RANGE)
 
#define INT_YRADIUS   (0.2 * INT_CHAR_NORM_RANGE)
 
#define INT_MIN_X   0
 
#define INT_MIN_Y   0
 
#define INT_MAX_X   INT_CHAR_NORM_RANGE
 
#define INT_MAX_Y   INT_CHAR_NORM_RANGE
 
#define HV_TOLERANCE   (0.0025) /* approx 0.9 degrees */
 
#define MAX_NUM_SWITCHES   3
 
#define OLD_MAX_NUM_CONFIGS   32
 
#define OLD_WERDS_PER_CONFIG_VEC
 
#define CircularIncrement(i, r)   (((i) < (r) - 1)?((i)++):((i) = 0))
 
#define MapParam(P, O, N)   (std::floor(((P) + (O)) * (N)))
 
#define MAX_LEVEL   2
 
#define XS   X_SHIFT
 
#define YS   Y_SHIFT
 
#define AS   ANGLE_SHIFT
 
#define NB   NUM_CP_BUCKETS
 

Enumerations

enum  SWITCH_TYPE { StartSwitch, EndSwitch, LastSwitch }
 

Functions

float BucketStart (int Bucket, float Offset, int NumBuckets)
 
float BucketEnd (int Bucket, float Offset, int NumBuckets)
 
void DoFill (FILL_SPEC *FillSpec, CLASS_PRUNER_STRUCT *Pruner, uint32_t ClassMask, uint32_t ClassCount, uint32_t WordIndex)
 
bool FillerDone (TABLE_FILLER *Filler)
 
void FillPPCircularBits (uint32_t ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, float Center, float Spread, bool debug)
 
void FillPPLinearBits (uint32_t ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, float Center, float Spread, bool debug)
 
void GetCPPadsForLevel (int Level, float *EndPad, float *SidePad, float *AnglePad)
 
ScrollView::Color GetMatchColorFor (float Evidence)
 
void GetNextFill (TABLE_FILLER *Filler, FILL_SPEC *Fill)
 
void InitTableFiller (float EndPad, float SidePad, float AnglePad, PROTO Proto, TABLE_FILLER *Filler)
 
void RenderIntFeature (ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
 
void RenderIntProto (ScrollView *window, INT_CLASS Class, PROTO_ID ProtoId, ScrollView::Color color)
 
int TruncateParam (float Param, int Min, int Max, char *Id)
 
void AddIntClass (INT_TEMPLATES Templates, CLASS_ID ClassId, INT_CLASS Class)
 
int AddIntConfig (INT_CLASS Class)
 
int AddIntProto (INT_CLASS Class)
 
void AddProtoToClassPruner (PROTO Proto, CLASS_ID ClassId, INT_TEMPLATES Templates)
 
void AddProtoToProtoPruner (PROTO Proto, int ProtoId, INT_CLASS Class, bool debug)
 
uint8_t Bucket8For (float param, float offset, int num_buckets)
 
uint16_t Bucket16For (float param, float offset, int num_buckets)
 
uint8_t CircBucketFor (float param, float offset, int num_buckets)
 
void UpdateMatchDisplay ()
 
void ConvertConfig (BIT_VECTOR Config, int ConfigId, INT_CLASS Class)
 
void DisplayIntFeature (const INT_FEATURE_STRUCT *Feature, float Evidence)
 
void DisplayIntProto (INT_CLASS Class, PROTO_ID ProtoId, float Evidence)
 
INT_CLASS NewIntClass (int MaxNumProtos, int MaxNumConfigs)
 
INT_TEMPLATES NewIntTemplates ()
 
void free_int_templates (INT_TEMPLATES templates)
 
void tesseract::ClearFeatureSpaceWindow (NORM_METHOD norm_method, ScrollView *window)
 
void InitIntMatchWindowIfReqd ()
 
void InitProtoDisplayWindowIfReqd ()
 
void InitFeatureDisplayWindowIfReqd ()
 
ScrollViewCreateFeatureSpaceWindow (const char *name, int xpos, int ypos)
 

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

Definition at line 20 of file intproto.cpp.

◆ AS

#define AS   ANGLE_SHIFT

◆ CircularIncrement

#define CircularIncrement (   i,
 
)    (((i) < (r) - 1)?((i)++):((i) = 0))

macro for performing circular increments of bucket indices

Definition at line 115 of file intproto.cpp.

◆ HV_TOLERANCE

#define HV_TOLERANCE   (0.0025) /* approx 0.9 degrees */

define pad used to snap near horiz/vertical protos to horiz/vertical

Definition at line 64 of file intproto.cpp.

◆ INT_BASELINE

#define INT_BASELINE   (0.25 * INT_CHAR_NORM_RANGE)

Definition at line 50 of file intproto.cpp.

◆ INT_CAPHEIGHT

#define INT_CAPHEIGHT   (1.0 * INT_CHAR_NORM_RANGE)

Definition at line 52 of file intproto.cpp.

◆ INT_DESCENDER

#define INT_DESCENDER   (0.0 * INT_CHAR_NORM_RANGE)

Definition at line 49 of file intproto.cpp.

◆ INT_MAX_X

#define INT_MAX_X   INT_CHAR_NORM_RANGE

Definition at line 60 of file intproto.cpp.

◆ INT_MAX_Y

#define INT_MAX_Y   INT_CHAR_NORM_RANGE

Definition at line 61 of file intproto.cpp.

◆ INT_MIN_X

#define INT_MIN_X   0

Definition at line 58 of file intproto.cpp.

◆ INT_MIN_Y

#define INT_MIN_Y   0

Definition at line 59 of file intproto.cpp.

◆ INT_XCENTER

#define INT_XCENTER   (0.5 * INT_CHAR_NORM_RANGE)

Definition at line 54 of file intproto.cpp.

◆ INT_XHEIGHT

#define INT_XHEIGHT   (0.75 * INT_CHAR_NORM_RANGE)

Definition at line 51 of file intproto.cpp.

◆ INT_XRADIUS

#define INT_XRADIUS   (0.2 * INT_CHAR_NORM_RANGE)

Definition at line 56 of file intproto.cpp.

◆ INT_YCENTER

#define INT_YCENTER   (0.5 * INT_CHAR_NORM_RANGE)

Definition at line 55 of file intproto.cpp.

◆ INT_YRADIUS

#define INT_YRADIUS   (0.2 * INT_CHAR_NORM_RANGE)

Definition at line 57 of file intproto.cpp.

◆ MapParam

#define MapParam (   P,
  O,
 
)    (std::floor(((P) + (O)) * (N)))

macro for mapping floats to ints without bounds checking

Definition at line 118 of file intproto.cpp.

◆ MAX_LEVEL

#define MAX_LEVEL   2

◆ MAX_NUM_SWITCHES

#define MAX_NUM_SWITCHES   3

Definition at line 69 of file intproto.cpp.

◆ NB

#define NB   NUM_CP_BUCKETS

◆ OLD_MAX_NUM_CONFIGS

#define OLD_MAX_NUM_CONFIGS   32

Definition at line 107 of file intproto.cpp.

◆ OLD_WERDS_PER_CONFIG_VEC

#define OLD_WERDS_PER_CONFIG_VEC
Value:

Definition at line 108 of file intproto.cpp.

◆ PROTO_PRUNER_SCALE

#define PROTO_PRUNER_SCALE   (4.0)

Definition at line 47 of file intproto.cpp.

◆ XS

#define XS   X_SHIFT

◆ YS

#define YS   Y_SHIFT

Enumeration Type Documentation

◆ SWITCH_TYPE

Enumerator
StartSwitch 
EndSwitch 
LastSwitch 

Definition at line 66 of file intproto.cpp.

Function Documentation

◆ AddIntClass()

void AddIntClass ( INT_TEMPLATES  Templates,
CLASS_ID  ClassId,
INT_CLASS  Class 
)

This routine adds a new class structure to a set of templates. Classes have to be added to Templates in the order of increasing ClassIds.

Parameters
Templatestemplates to add new class to
ClassIdclass id to associate new class with
Classclass data structure to add to templates

Globals: none

Definition at line 230 of file intproto.cpp.

231  {
232  int Pruner;
233 
234  assert (LegalClassId (ClassId));
235  if (ClassId != Templates->NumClasses) {
236  fprintf(stderr, "Please make sure that classes are added to templates");
237  fprintf(stderr, " in increasing order of ClassIds\n");
238  exit(1);
239  }
240  ClassForClassId (Templates, ClassId) = Class;
241  Templates->NumClasses++;
242 
243  if (Templates->NumClasses > MaxNumClassesIn (Templates)) {
244  Pruner = Templates->NumClassPruners++;
245  Templates->ClassPruners[Pruner] = new CLASS_PRUNER_STRUCT;
246  memset(Templates->ClassPruners[Pruner], 0, sizeof(CLASS_PRUNER_STRUCT));
247  }

◆ AddIntConfig()

int AddIntConfig ( INT_CLASS  Class)

This routine returns the index of the next free config in Class.

Parameters
Classclass to add new configuration to

Globals: none

Returns
Index of next free config.

Definition at line 260 of file intproto.cpp.

261  {
262  int Index;
263 
264  assert(Class->NumConfigs < MAX_NUM_CONFIGS);
265 
266  Index = Class->NumConfigs++;
267  Class->ConfigLengths[Index] = 0;
268  return Index;

◆ AddIntProto()

int AddIntProto ( INT_CLASS  Class)

This routine allocates the next free proto in Class and returns its index.

Parameters
Classclass to add new proto to

Globals: none

Returns
Proto index of new proto.

Definition at line 281 of file intproto.cpp.

282  {
283  int Index;
284  int ProtoSetId;
285  PROTO_SET ProtoSet;
286  INT_PROTO Proto;
287  uint32_t *Word;
288 
289  if (Class->NumProtos >= MAX_NUM_PROTOS)
290  return (NO_PROTO);
291 
292  Index = Class->NumProtos++;
293 
294  if (Class->NumProtos > MaxNumIntProtosIn(Class)) {
295  ProtoSetId = Class->NumProtoSets++;
296 
297  ProtoSet = static_cast<PROTO_SET>(Emalloc(sizeof(PROTO_SET_STRUCT)));
298  Class->ProtoSets[ProtoSetId] = ProtoSet;
299  memset(ProtoSet, 0, sizeof(*ProtoSet));
300 
301  /* reallocate space for the proto lengths and install in class */
302  Class->ProtoLengths =
303  static_cast<uint8_t *>(Erealloc(Class->ProtoLengths,
304  MaxNumIntProtosIn(Class) * sizeof(uint8_t)));
305  memset(&Class->ProtoLengths[Index], 0,
306  sizeof(*Class->ProtoLengths) * (MaxNumIntProtosIn(Class) - Index));
307  }
308 
309  /* initialize proto so its length is zero and it isn't in any configs */
310  Class->ProtoLengths[Index] = 0;
311  Proto = ProtoForProtoId (Class, Index);
312  for (Word = Proto->Configs;
313  Word < Proto->Configs + WERDS_PER_CONFIG_VEC; *Word++ = 0);
314 
315  return (Index);

◆ AddProtoToClassPruner()

void AddProtoToClassPruner ( PROTO  Proto,
CLASS_ID  ClassId,
INT_TEMPLATES  Templates 
)

This routine adds Proto to the class pruning tables for the specified class in Templates.

Globals:

  • classify_num_cp_levels number of levels used in the class pruner
    Parameters
    Protofloating-pt proto to add to class pruner
    ClassIdclass id corresponding to Proto
    Templatesset of templates containing class pruner

Definition at line 327 of file intproto.cpp.

331 {
332  CLASS_PRUNER_STRUCT* Pruner;
333  uint32_t ClassMask;
334  uint32_t ClassCount;
335  uint32_t WordIndex;
336  int Level;
337  float EndPad, SidePad, AnglePad;
338  TABLE_FILLER TableFiller;
339  FILL_SPEC FillSpec;
340 
341  Pruner = CPrunerFor (Templates, ClassId);
342  WordIndex = CPrunerWordIndexFor (ClassId);
343  ClassMask = CPrunerMaskFor (MAX_LEVEL, ClassId);
344 
345  for (Level = classify_num_cp_levels - 1; Level >= 0; Level--) {
346  GetCPPadsForLevel(Level, &EndPad, &SidePad, &AnglePad);
347  ClassCount = CPrunerMaskFor (Level, ClassId);
348  InitTableFiller(EndPad, SidePad, AnglePad, Proto, &TableFiller);
349 
350  while (!FillerDone (&TableFiller)) {
351  GetNextFill(&TableFiller, &FillSpec);
352  DoFill(&FillSpec, Pruner, ClassMask, ClassCount, WordIndex);
353  }
354  }

◆ AddProtoToProtoPruner()

void AddProtoToProtoPruner ( PROTO  Proto,
int  ProtoId,
INT_CLASS  Class,
bool  debug 
)

This routine updates the proto pruner lookup tables for Class to include a new proto identified by ProtoId and described by Proto.

Parameters
Protofloating-pt proto to be added to proto pruner
ProtoIdid of proto
Classinteger class that contains desired proto pruner
debugdebug flag
Note
Globals: none

Definition at line 366 of file intproto.cpp.

368  {
369  float Angle, X, Y, Length;
370  float Pad;
371  int Index;
372  PROTO_SET ProtoSet;
373 
374  if (ProtoId >= Class->NumProtos)
375  cprintf("AddProtoToProtoPruner:assert failed: %d < %d",
376  ProtoId, Class->NumProtos);
377  assert(ProtoId < Class->NumProtos);
378 
379  Index = IndexForProto (ProtoId);
380  ProtoSet = Class->ProtoSets[SetForProto (ProtoId)];
381 
382  Angle = Proto->Angle;
383 #ifndef _WIN32
384  assert(!std::isnan(Angle));
385 #endif
386 
387  FillPPCircularBits (ProtoSet->ProtoPruner[PRUNER_ANGLE], Index,
388  Angle + ANGLE_SHIFT, classify_pp_angle_pad / 360.0,
389  debug);
390 
391  Angle *= 2.0 * M_PI;
392  Length = Proto->Length;
393 
394  X = Proto->X + X_SHIFT;
395  Pad = std::max(fabs (cos (Angle)) * (Length / 2.0 +
396  classify_pp_end_pad *
398  fabs (sin (Angle)) * (classify_pp_side_pad *
400 
401  FillPPLinearBits(ProtoSet->ProtoPruner[PRUNER_X], Index, X, Pad, debug);
402 
403  Y = Proto->Y + Y_SHIFT;
404  Pad = std::max(fabs (sin (Angle)) * (Length / 2.0 +
405  classify_pp_end_pad *
407  fabs (cos (Angle)) * (classify_pp_side_pad *
409 
410  FillPPLinearBits(ProtoSet->ProtoPruner[PRUNER_Y], Index, Y, Pad, debug);

◆ Bucket16For()

uint16_t Bucket16For ( float  param,
float  offset,
int  num_buckets 
)

Definition at line 421 of file intproto.cpp.

422  {
423  int bucket = IntCastRounded(MapParam(param, offset, num_buckets));
424  return static_cast<uint16_t>(ClipToRange<int>(bucket, 0, num_buckets - 1));

◆ Bucket8For()

uint8_t Bucket8For ( float  param,
float  offset,
int  num_buckets 
)

Returns a quantized bucket for the given param shifted by offset, notionally (param + offset) * num_buckets, but clipped and casted to the appropriate type.

Definition at line 417 of file intproto.cpp.

418  {
419  int bucket = IntCastRounded(MapParam(param, offset, num_buckets));
420  return static_cast<uint8_t>(ClipToRange<int>(bucket, 0, num_buckets - 1));

◆ BucketEnd()

float BucketEnd ( int  Bucket,
float  Offset,
int  NumBuckets 
)

This routine returns the parameter value which corresponds to the end of the specified bucket. The bucket number should have been generated using the BucketFor() function with parameters Offset and NumBuckets.

Parameters
Bucketbucket whose end is to be computed
Offsetoffset used to map params to buckets
NumBucketstotal number of buckets
Returns
Param value corresponding to end position of Bucket.
Note
Globals: none

Definition at line 1109 of file intproto.cpp.

1110  {
1111  return ((static_cast<float>(Bucket + 1) / NumBuckets) - Offset);

◆ BucketStart()

float BucketStart ( int  Bucket,
float  Offset,
int  NumBuckets 
)

This routine returns the parameter value which corresponds to the beginning of the specified bucket. The bucket number should have been generated using the BucketFor() function with parameters Offset and NumBuckets.

Parameters
Bucketbucket whose start is to be computed
Offsetoffset used to map params to buckets
NumBucketstotal number of buckets
Returns
Param value corresponding to start position of Bucket.
Note
Globals: none

Definition at line 1093 of file intproto.cpp.

1094  {
1095  return ((static_cast<float>(Bucket) / NumBuckets) - Offset);
1096 

◆ CircBucketFor()

uint8_t CircBucketFor ( float  param,
float  offset,
int  num_buckets 
)

Returns a quantized bucket for the given circular param shifted by offset, notionally (param + offset) * num_buckets, but modded and casted to the appropriate type.

Definition at line 431 of file intproto.cpp.

432  {
433  int bucket = IntCastRounded(MapParam(param, offset, num_buckets));
434  return static_cast<uint8_t>(Modulo(bucket, num_buckets));

◆ ConvertConfig()

void ConvertConfig ( BIT_VECTOR  Config,
int  ConfigId,
INT_CLASS  Class 
)

This operation updates the config vectors of all protos in Class to indicate that the protos with 1's in Config belong to a new configuration identified by ConfigId. It is assumed that the length of the Config bit vector is equal to the number of protos in Class.

Parameters
Configconfig to be added to class
ConfigIdid to be used for new config
Classclass to add new config to

Definition at line 462 of file intproto.cpp.

463  {
464  int ProtoId;
465  INT_PROTO Proto;
466  int TotalLength;
467 
468  for (ProtoId = 0, TotalLength = 0;
469  ProtoId < Class->NumProtos; ProtoId++) {
470  if (test_bit(Config, ProtoId)) {
471  Proto = ProtoForProtoId(Class, ProtoId);
472  SET_BIT(Proto->Configs, ConfigId);
473  TotalLength += Class->ProtoLengths[ProtoId];
474  }
475  }
476  Class->ConfigLengths[ConfigId] = TotalLength;

◆ CreateFeatureSpaceWindow()

ScrollView* CreateFeatureSpaceWindow ( const char *  name,
int  xpos,
int  ypos 
)

Creates a window of the appropriate size for displaying elements in feature space.

Definition at line 1764 of file intproto.cpp.

1765  {
1766  return new ScrollView(name, xpos, ypos, 520, 520, 260, 260, true);

◆ DisplayIntFeature()

void DisplayIntFeature ( const INT_FEATURE_STRUCT Feature,
float  Evidence 
)

This routine renders the specified feature into a global display list.

Globals:

  • FeatureShapes global display list for features
    Parameters
    Featurepico-feature to be displayed
    Evidencebest evidence for this feature (0-1)

Definition at line 589 of file intproto.cpp.

590  {
591  ScrollView::Color color = GetMatchColorFor(Evidence);
592  RenderIntFeature(IntMatchWindow, Feature, color);
593  if (FeatureDisplayWindow) {
594  RenderIntFeature(FeatureDisplayWindow, Feature, color);
595  }

◆ DisplayIntProto()

void DisplayIntProto ( INT_CLASS  Class,
PROTO_ID  ProtoId,
float  Evidence 
)

This routine renders the specified proto into a global display list.

Globals:

  • ProtoShapes global display list for protos
    Parameters
    Classclass to take proto from
    ProtoIdid of proto in Class to be displayed
    Evidencetotal evidence for proto (0-1)

Definition at line 607 of file intproto.cpp.

608  {
609  ScrollView::Color color = GetMatchColorFor(Evidence);
610  RenderIntProto(IntMatchWindow, Class, ProtoId, color);
611  if (ProtoDisplayWindow) {
612  RenderIntProto(ProtoDisplayWindow, Class, ProtoId, color);
613  }

◆ DoFill()

void DoFill ( FILL_SPEC FillSpec,
CLASS_PRUNER_STRUCT Pruner,
uint32_t  ClassMask,
uint32_t  ClassCount,
uint32_t  WordIndex 
)

This routine fills in the section of a class pruner corresponding to a single x value for a single proto of a class.

Parameters
FillSpecspecifies which bits to fill in pruner
Prunerclass pruner to be filled
ClassMaskindicates which bits to change in each word
ClassCountindicates what to change bits to
WordIndexindicates which word to change

Definition at line 1123 of file intproto.cpp.

1128  {
1129  int X, Y, Angle;
1130  uint32_t OldWord;
1131 
1132  X = FillSpec->X;
1133  if (X < 0)
1134  X = 0;
1135  if (X >= NUM_CP_BUCKETS)
1136  X = NUM_CP_BUCKETS - 1;
1137 
1138  if (FillSpec->YStart < 0)
1139  FillSpec->YStart = 0;
1140  if (FillSpec->YEnd >= NUM_CP_BUCKETS)
1141  FillSpec->YEnd = NUM_CP_BUCKETS - 1;
1142 
1143  for (Y = FillSpec->YStart; Y <= FillSpec->YEnd; Y++)
1144  for (Angle = FillSpec->AngleStart; ;
1146  OldWord = Pruner->p[X][Y][Angle][WordIndex];
1147  if (ClassCount > (OldWord & ClassMask)) {
1148  OldWord &= ~ClassMask;
1149  OldWord |= ClassCount;
1150  Pruner->p[X][Y][Angle][WordIndex] = OldWord;
1151  }
1152  if (Angle == FillSpec->AngleEnd)
1153  break;
1154  }

◆ FillerDone()

bool FillerDone ( TABLE_FILLER Filler)

Return true if the specified table filler is done, i.e. if it has no more lines to fill.

Parameters
Fillertable filler to check if done
Returns
true if no more lines to fill, false otherwise.
Note
Globals: none

Definition at line 1163 of file intproto.cpp.

1164  {
1165  FILL_SWITCH *Next;
1166 
1167  Next = &(Filler->Switch[Filler->NextSwitch]);
1168 
1169  return Filler->X > Next->X && Next->Type == LastSwitch;
1170 

◆ FillPPCircularBits()

void FillPPCircularBits ( uint32_t  ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
int  Bit,
float  Center,
float  Spread,
bool  debug 
)

This routine sets Bit in each bit vector whose bucket lies within the range Center +- Spread. The fill is done for a circular dimension, i.e. bucket 0 is adjacent to the last bucket. It is assumed that Center and Spread are expressed in a circular coordinate system whose range is 0 to 1.

Parameters
ParamTabletable of bit vectors, one per param bucket
Bitbit position in vectors to be filled
Centercenter of filled area
Spreadspread of filled area
debugdebug flag

Definition at line 1185 of file intproto.cpp.

1187  {
1188  int i, FirstBucket, LastBucket;
1189 
1190  if (Spread > 0.5)
1191  Spread = 0.5;
1192 
1193  FirstBucket = static_cast<int>(std::floor((Center - Spread) * NUM_PP_BUCKETS));
1194  if (FirstBucket < 0)
1195  FirstBucket += NUM_PP_BUCKETS;
1196 
1197  LastBucket = static_cast<int>(std::floor((Center + Spread) * NUM_PP_BUCKETS));
1198  if (LastBucket >= NUM_PP_BUCKETS)
1199  LastBucket -= NUM_PP_BUCKETS;
1200  if (debug) tprintf("Circular fill from %d to %d", FirstBucket, LastBucket);
1201  for (i = FirstBucket; true; CircularIncrement (i, NUM_PP_BUCKETS)) {
1202  SET_BIT (ParamTable[i], Bit);
1203 
1204  /* exit loop after we have set the bit for the last bucket */
1205  if (i == LastBucket)
1206  break;
1207  }
1208 

◆ FillPPLinearBits()

void FillPPLinearBits ( uint32_t  ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
int  Bit,
float  Center,
float  Spread,
bool  debug 
)

This routine sets Bit in each bit vector whose bucket lies within the range Center +- Spread. The fill is done for a linear dimension, i.e. there is no wrap-around for this dimension. It is assumed that Center and Spread are expressed in a linear coordinate system whose range is approximately 0 to 1. Values outside this range will be clipped.

Parameters
ParamTabletable of bit vectors, one per param bucket
Bitbit number being filled
Centercenter of filled area
Spreadspread of filled area
debugdebug flag

Definition at line 1224 of file intproto.cpp.

1226  {
1227  int i, FirstBucket, LastBucket;
1228 
1229  FirstBucket = static_cast<int>(std::floor((Center - Spread) * NUM_PP_BUCKETS));
1230  if (FirstBucket < 0)
1231  FirstBucket = 0;
1232 
1233  LastBucket = static_cast<int>(std::floor((Center + Spread) * NUM_PP_BUCKETS));
1234  if (LastBucket >= NUM_PP_BUCKETS)
1235  LastBucket = NUM_PP_BUCKETS - 1;
1236 
1237  if (debug) tprintf("Linear fill from %d to %d", FirstBucket, LastBucket);
1238  for (i = FirstBucket; i <= LastBucket; i++)
1239  SET_BIT (ParamTable[i], Bit);
1240 

◆ free_int_templates()

void free_int_templates ( INT_TEMPLATES  templates)

Definition at line 697 of file intproto.cpp.

698  {
699  int i;
700 
701  for (i = 0; i < templates->NumClasses; i++)
702  free_int_class(templates->Class[i]);
703  for (i = 0; i < templates->NumClassPruners; i++)
704  delete templates->ClassPruners[i];
705  Efree(templates);

◆ GetCPPadsForLevel()

void GetCPPadsForLevel ( int  Level,
float *  EndPad,
float *  SidePad,
float *  AnglePad 
)

This routine copies the appropriate global pad variables into EndPad, SidePad, and AnglePad. This is a kludge used to get around the fact that global control variables cannot be arrays. If the specified level is illegal, the tightest possible pads are returned.

Parameters
Level"tightness" level to return pads for
EndPadplace to put end pad for Level
SidePadplace to put side pad for Level
AnglePadplace to put angle pad for Level

Definition at line 1332 of file intproto.cpp.

1336  {
1337  switch (Level) {
1338  case 0:
1339  *EndPad = classify_cp_end_pad_loose * GetPicoFeatureLength ();
1340  *SidePad = classify_cp_side_pad_loose * GetPicoFeatureLength ();
1341  *AnglePad = classify_cp_angle_pad_loose / 360.0;
1342  break;
1343 
1344  case 1:
1345  *EndPad = classify_cp_end_pad_medium * GetPicoFeatureLength ();
1346  *SidePad = classify_cp_side_pad_medium * GetPicoFeatureLength ();
1347  *AnglePad = classify_cp_angle_pad_medium / 360.0;
1348  break;
1349 
1350  case 2:
1351  *EndPad = classify_cp_end_pad_tight * GetPicoFeatureLength ();
1352  *SidePad = classify_cp_side_pad_tight * GetPicoFeatureLength ();
1353  *AnglePad = classify_cp_angle_pad_tight / 360.0;
1354  break;
1355 
1356  default:
1357  *EndPad = classify_cp_end_pad_tight * GetPicoFeatureLength ();
1358  *SidePad = classify_cp_side_pad_tight * GetPicoFeatureLength ();
1359  *AnglePad = classify_cp_angle_pad_tight / 360.0;
1360  break;
1361  }
1362  if (*AnglePad > 0.5)
1363  *AnglePad = 0.5;
1364 

◆ GetMatchColorFor()

ScrollView::Color GetMatchColorFor ( float  Evidence)
Parameters
Evidenceevidence value to return color for
Returns
Color which corresponds to specified Evidence value.
Note
Globals: none

Definition at line 1371 of file intproto.cpp.

1372  {
1373  assert (Evidence >= 0.0);
1374  assert (Evidence <= 1.0);
1375 
1376  if (Evidence >= 0.90)
1377  return ScrollView::WHITE;
1378  else if (Evidence >= 0.75)
1379  return ScrollView::GREEN;
1380  else if (Evidence >= 0.50)
1381  return ScrollView::RED;
1382  else
1383  return ScrollView::BLUE;

◆ GetNextFill()

void GetNextFill ( TABLE_FILLER Filler,
FILL_SPEC Fill 
)

This routine returns (in Fill) the specification of the next line to be filled from Filler. FillerDone() should always be called before GetNextFill() to ensure that we do not run past the end of the fill table.

Parameters
Fillerfiller to get next fill spec from
Fillplace to put spec for next fill

Definition at line 1393 of file intproto.cpp.

1394  {
1395  FILL_SWITCH *Next;
1396 
1397  /* compute the fill assuming no switches will be encountered */
1398  Fill->AngleStart = Filler->AngleStart;
1399  Fill->AngleEnd = Filler->AngleEnd;
1400  Fill->X = Filler->X;
1401  Fill->YStart = Filler->YStart >> 8;
1402  Fill->YEnd = Filler->YEnd >> 8;
1403 
1404  /* update the fill info and the filler for ALL switches at this X value */
1405  Next = &(Filler->Switch[Filler->NextSwitch]);
1406  while (Filler->X >= Next->X) {
1407  Fill->X = Filler->X = Next->X;
1408  if (Next->Type == StartSwitch) {
1409  Fill->YStart = Next->Y;
1410  Filler->StartDelta = Next->Delta;
1411  Filler->YStart = Next->YInit;
1412  }
1413  else if (Next->Type == EndSwitch) {
1414  Fill->YEnd = Next->Y;
1415  Filler->EndDelta = Next->Delta;
1416  Filler->YEnd = Next->YInit;
1417  }
1418  else { /* Type must be LastSwitch */
1419  break;
1420  }
1421  Filler->NextSwitch++;
1422  Next = &(Filler->Switch[Filler->NextSwitch]);
1423  }
1424 
1425  /* prepare the filler for the next call to this routine */
1426  Filler->X++;
1427  Filler->YStart += Filler->StartDelta;
1428  Filler->YEnd += Filler->EndDelta;
1429 

◆ InitFeatureDisplayWindowIfReqd()

void InitFeatureDisplayWindowIfReqd ( )

Initializes the feature display window if it is not already initialized.

Definition at line 1755 of file intproto.cpp.

1756  {
1757  if (FeatureDisplayWindow == nullptr) {
1758  FeatureDisplayWindow = CreateFeatureSpaceWindow("FeatureDisplayWindow",
1759  50, 700);
1760  }

◆ InitIntMatchWindowIfReqd()

void InitIntMatchWindowIfReqd ( )

Initializes the int matcher window if it is not already initialized.

Definition at line 1723 of file intproto.cpp.

1724  {
1725  if (IntMatchWindow == nullptr) {
1726  IntMatchWindow = CreateFeatureSpaceWindow("IntMatchWindow", 50, 200);
1727  auto* popup_menu = new SVMenuNode();
1728 
1729  popup_menu->AddChild("Debug Adapted classes", IDA_ADAPTIVE,
1730  "x", "Class to debug");
1731  popup_menu->AddChild("Debug Static classes", IDA_STATIC,
1732  "x", "Class to debug");
1733  popup_menu->AddChild("Debug Both", IDA_BOTH,
1734  "x", "Class to debug");
1735  popup_menu->AddChild("Debug Shape Index", IDA_SHAPE_INDEX,
1736  "0", "Index to debug");
1737  popup_menu->BuildMenu(IntMatchWindow, false);
1738  }

◆ InitProtoDisplayWindowIfReqd()

void InitProtoDisplayWindowIfReqd ( )

Initializes the proto display window if it is not already initialized.

Definition at line 1744 of file intproto.cpp.

1745  {
1746  if (ProtoDisplayWindow == nullptr) {
1747  ProtoDisplayWindow = CreateFeatureSpaceWindow("ProtoDisplayWindow",
1748  550, 200);
1749  }

◆ InitTableFiller()

void InitTableFiller ( float  EndPad,
float  SidePad,
float  AnglePad,
PROTO  Proto,
TABLE_FILLER Filler 
)

This routine computes a data structure (Filler) which can be used to fill in a rectangle surrounding the specified Proto. Results are returned in Filler.

Parameters
EndPad,SidePad,AnglePadpadding to add to proto
Protoproto to create a filler for
Fillerplace to put table filler

Definition at line 1440 of file intproto.cpp.

1447 {
1448  float Angle;
1449  float X, Y, HalfLength;
1450  float Cos, Sin;
1451  float XAdjust, YAdjust;
1452  FPOINT Start, Switch1, Switch2, End;
1453  int S1 = 0;
1454  int S2 = 1;
1455 
1456  Angle = Proto->Angle;
1457  X = Proto->X;
1458  Y = Proto->Y;
1459  HalfLength = Proto->Length / 2.0;
1460 
1461  Filler->AngleStart = CircBucketFor(Angle - AnglePad, AS, NB);
1462  Filler->AngleEnd = CircBucketFor(Angle + AnglePad, AS, NB);
1463  Filler->NextSwitch = 0;
1464 
1465  if (fabs (Angle - 0.0) < HV_TOLERANCE || fabs (Angle - 0.5) < HV_TOLERANCE) {
1466  /* horizontal proto - handle as special case */
1467  Filler->X = Bucket8For(X - HalfLength - EndPad, XS, NB);
1468  Filler->YStart = Bucket16For(Y - SidePad, YS, NB * 256);
1469  Filler->YEnd = Bucket16For(Y + SidePad, YS, NB * 256);
1470  Filler->StartDelta = 0;
1471  Filler->EndDelta = 0;
1472  Filler->Switch[0].Type = LastSwitch;
1473  Filler->Switch[0].X = Bucket8For(X + HalfLength + EndPad, XS, NB);
1474  } else if (fabs(Angle - 0.25) < HV_TOLERANCE ||
1475  fabs(Angle - 0.75) < HV_TOLERANCE) {
1476  /* vertical proto - handle as special case */
1477  Filler->X = Bucket8For(X - SidePad, XS, NB);
1478  Filler->YStart = Bucket16For(Y - HalfLength - EndPad, YS, NB * 256);
1479  Filler->YEnd = Bucket16For(Y + HalfLength + EndPad, YS, NB * 256);
1480  Filler->StartDelta = 0;
1481  Filler->EndDelta = 0;
1482  Filler->Switch[0].Type = LastSwitch;
1483  Filler->Switch[0].X = Bucket8For(X + SidePad, XS, NB);
1484  } else {
1485  /* diagonal proto */
1486 
1487  if ((Angle > 0.0 && Angle < 0.25) || (Angle > 0.5 && Angle < 0.75)) {
1488  /* rising diagonal proto */
1489  Angle *= 2.0 * M_PI;
1490  Cos = fabs(cos(Angle));
1491  Sin = fabs(sin(Angle));
1492 
1493  /* compute the positions of the corners of the acceptance region */
1494  Start.x = X - (HalfLength + EndPad) * Cos - SidePad * Sin;
1495  Start.y = Y - (HalfLength + EndPad) * Sin + SidePad * Cos;
1496  End.x = 2.0 * X - Start.x;
1497  End.y = 2.0 * Y - Start.y;
1498  Switch1.x = X - (HalfLength + EndPad) * Cos + SidePad * Sin;
1499  Switch1.y = Y - (HalfLength + EndPad) * Sin - SidePad * Cos;
1500  Switch2.x = 2.0 * X - Switch1.x;
1501  Switch2.y = 2.0 * Y - Switch1.y;
1502 
1503  if (Switch1.x > Switch2.x) {
1504  S1 = 1;
1505  S2 = 0;
1506  }
1507 
1508  /* translate into bucket positions and deltas */
1509  Filler->X = Bucket8For(Start.x, XS, NB);
1510  Filler->StartDelta = -static_cast<int16_t>((Cos / Sin) * 256);
1511  Filler->EndDelta = static_cast<int16_t>((Sin / Cos) * 256);
1512 
1513  XAdjust = BucketEnd(Filler->X, XS, NB) - Start.x;
1514  YAdjust = XAdjust * Cos / Sin;
1515  Filler->YStart = Bucket16For(Start.y - YAdjust, YS, NB * 256);
1516  YAdjust = XAdjust * Sin / Cos;
1517  Filler->YEnd = Bucket16For(Start.y + YAdjust, YS, NB * 256);
1518 
1519  Filler->Switch[S1].Type = StartSwitch;
1520  Filler->Switch[S1].X = Bucket8For(Switch1.x, XS, NB);
1521  Filler->Switch[S1].Y = Bucket8For(Switch1.y, YS, NB);
1522  XAdjust = Switch1.x - BucketStart(Filler->Switch[S1].X, XS, NB);
1523  YAdjust = XAdjust * Sin / Cos;
1524  Filler->Switch[S1].YInit = Bucket16For(Switch1.y - YAdjust, YS, NB * 256);
1525  Filler->Switch[S1].Delta = Filler->EndDelta;
1526 
1527  Filler->Switch[S2].Type = EndSwitch;
1528  Filler->Switch[S2].X = Bucket8For(Switch2.x, XS, NB);
1529  Filler->Switch[S2].Y = Bucket8For(Switch2.y, YS, NB);
1530  XAdjust = Switch2.x - BucketStart(Filler->Switch[S2].X, XS, NB);
1531  YAdjust = XAdjust * Cos / Sin;
1532  Filler->Switch[S2].YInit = Bucket16For(Switch2.y + YAdjust, YS, NB * 256);
1533  Filler->Switch[S2].Delta = Filler->StartDelta;
1534 
1535  Filler->Switch[2].Type = LastSwitch;
1536  Filler->Switch[2].X = Bucket8For(End.x, XS, NB);
1537  } else {
1538  /* falling diagonal proto */
1539  Angle *= 2.0 * M_PI;
1540  Cos = fabs(cos(Angle));
1541  Sin = fabs(sin(Angle));
1542 
1543  /* compute the positions of the corners of the acceptance region */
1544  Start.x = X - (HalfLength + EndPad) * Cos - SidePad * Sin;
1545  Start.y = Y + (HalfLength + EndPad) * Sin - SidePad * Cos;
1546  End.x = 2.0 * X - Start.x;
1547  End.y = 2.0 * Y - Start.y;
1548  Switch1.x = X - (HalfLength + EndPad) * Cos + SidePad * Sin;
1549  Switch1.y = Y + (HalfLength + EndPad) * Sin + SidePad * Cos;
1550  Switch2.x = 2.0 * X - Switch1.x;
1551  Switch2.y = 2.0 * Y - Switch1.y;
1552 
1553  if (Switch1.x > Switch2.x) {
1554  S1 = 1;
1555  S2 = 0;
1556  }
1557 
1558  /* translate into bucket positions and deltas */
1559  Filler->X = Bucket8For(Start.x, XS, NB);
1560  Filler->StartDelta = static_cast<int16_t>(ClipToRange<int>(
1561  -IntCastRounded((Sin / Cos) * 256), INT16_MIN, INT16_MAX));
1562  Filler->EndDelta = static_cast<int16_t>(ClipToRange<int>(
1563  IntCastRounded((Cos / Sin) * 256), INT16_MIN, INT16_MAX));
1564 
1565  XAdjust = BucketEnd(Filler->X, XS, NB) - Start.x;
1566  YAdjust = XAdjust * Sin / Cos;
1567  Filler->YStart = Bucket16For(Start.y - YAdjust, YS, NB * 256);
1568  YAdjust = XAdjust * Cos / Sin;
1569  Filler->YEnd = Bucket16For(Start.y + YAdjust, YS, NB * 256);
1570 
1571  Filler->Switch[S1].Type = EndSwitch;
1572  Filler->Switch[S1].X = Bucket8For(Switch1.x, XS, NB);
1573  Filler->Switch[S1].Y = Bucket8For(Switch1.y, YS, NB);
1574  XAdjust = Switch1.x - BucketStart(Filler->Switch[S1].X, XS, NB);
1575  YAdjust = XAdjust * Sin / Cos;
1576  Filler->Switch[S1].YInit = Bucket16For(Switch1.y + YAdjust, YS, NB * 256);
1577  Filler->Switch[S1].Delta = Filler->StartDelta;
1578 
1579  Filler->Switch[S2].Type = StartSwitch;
1580  Filler->Switch[S2].X = Bucket8For(Switch2.x, XS, NB);
1581  Filler->Switch[S2].Y = Bucket8For(Switch2.y, YS, NB);
1582  XAdjust = Switch2.x - BucketStart(Filler->Switch[S2].X, XS, NB);
1583  YAdjust = XAdjust * Cos / Sin;
1584  Filler->Switch[S2].YInit = Bucket16For(Switch2.y - YAdjust, YS, NB * 256);
1585  Filler->Switch[S2].Delta = Filler->EndDelta;
1586 
1587  Filler->Switch[2].Type = LastSwitch;
1588  Filler->Switch[2].X = Bucket8For(End.x, XS, NB);
1589  }
1590  }

◆ NewIntClass()

INT_CLASS NewIntClass ( int  MaxNumProtos,
int  MaxNumConfigs 
)

This routine creates a new integer class data structure and returns it. Sufficient space is allocated to handle the specified number of protos and configs.

Parameters
MaxNumProtosnumber of protos to allocate space for
MaxNumConfigsnumber of configs to allocate space for
Returns
New class created.
Note
Globals: none

Definition at line 625 of file intproto.cpp.

626  {
627  INT_CLASS Class;
628  PROTO_SET ProtoSet;
629  int i;
630 
631  assert(MaxNumConfigs <= MAX_NUM_CONFIGS);
632 
633  Class = static_cast<INT_CLASS>(Emalloc(sizeof(INT_CLASS_STRUCT)));
634  Class->NumProtoSets = ((MaxNumProtos + PROTOS_PER_PROTO_SET - 1) /
636 
637  assert(Class->NumProtoSets <= MAX_NUM_PROTO_SETS);
638 
639  Class->NumProtos = 0;
640  Class->NumConfigs = 0;
641 
642  for (i = 0; i < Class->NumProtoSets; i++) {
643  /* allocate space for a proto set, install in class, and initialize */
644  ProtoSet = static_cast<PROTO_SET>(Emalloc(sizeof(PROTO_SET_STRUCT)));
645  memset(ProtoSet, 0, sizeof(*ProtoSet));
646  Class->ProtoSets[i] = ProtoSet;
647 
648  /* allocate space for the proto lengths and install in class */
649  }
650  if (MaxNumIntProtosIn (Class) > 0) {
651  Class->ProtoLengths =
652  static_cast<uint8_t *>(Emalloc(MaxNumIntProtosIn (Class) * sizeof (uint8_t)));
653  memset(Class->ProtoLengths, 0,
654  MaxNumIntProtosIn(Class) * sizeof(*Class->ProtoLengths));
655  } else {
656  Class->ProtoLengths = nullptr;
657  }
658  memset(Class->ConfigLengths, 0, sizeof(Class->ConfigLengths));
659 
660  return (Class);
661 

◆ NewIntTemplates()

INT_TEMPLATES NewIntTemplates ( )

This routine allocates a new set of integer templates initialized to hold 0 classes.

Returns
The integer templates created.
Note
Globals: none

Definition at line 681 of file intproto.cpp.

682  {
683  INT_TEMPLATES T;
684  int i;
685 
686  T = static_cast<INT_TEMPLATES>(Emalloc (sizeof (INT_TEMPLATES_STRUCT)));
687  T->NumClasses = 0;
688  T->NumClassPruners = 0;
689 
690  for (i = 0; i < MAX_NUM_CLASSES; i++)
691  ClassForClassId (T, i) = nullptr;
692 
693  return (T);

◆ RenderIntFeature()

void RenderIntFeature ( ScrollView window,
const INT_FEATURE_STRUCT Feature,
ScrollView::Color  color 
)

This routine renders the specified feature into ShapeList.

Parameters
windowto add feature rendering to
Featurefeature to be rendered
colorcolor to use for feature rendering
Returns
New shape list with rendering of Feature added.
Note
Globals: none

Definition at line 1603 of file intproto.cpp.

1605  {
1606  float X, Y, Dx, Dy, Length;
1607 
1608  window->Pen(color);
1609  assert(Feature != nullptr);
1610  assert(color != 0);
1611 
1612  X = Feature->X;
1613  Y = Feature->Y;
1614  Length = GetPicoFeatureLength() * 0.7 * INT_CHAR_NORM_RANGE;
1615  // The -PI has no significant effect here, but the value of Theta is computed
1616  // using BinaryAnglePlusPi in intfx.cpp.
1617  Dx = (Length / 2.0) * cos((Feature->Theta / 256.0) * 2.0 * M_PI - M_PI);
1618  Dy = (Length / 2.0) * sin((Feature->Theta / 256.0) * 2.0 * M_PI - M_PI);
1619 
1620  window->SetCursor(X, Y);
1621  window->DrawTo(X + Dx, Y + Dy);

◆ RenderIntProto()

void RenderIntProto ( ScrollView window,
INT_CLASS  Class,
PROTO_ID  ProtoId,
ScrollView::Color  color 
)

This routine extracts the parameters of the specified proto from the class description and adds a rendering of the proto onto the ShapeList.

Parameters
windowScrollView instance
Classclass that proto is contained in
ProtoIdid of proto to be rendered
colorcolor to render proto in

Globals: none

Returns
New shape list with a rendering of one proto added.

Definition at line 1637 of file intproto.cpp.

1641  {
1642  PROTO_SET ProtoSet;
1643  INT_PROTO Proto;
1644  int ProtoSetIndex;
1645  int ProtoWordIndex;
1646  float Length;
1647  int Xmin, Xmax, Ymin, Ymax;
1648  float X, Y, Dx, Dy;
1649  uint32_t ProtoMask;
1650  int Bucket;
1651 
1652  assert(ProtoId >= 0);
1653  assert(Class != nullptr);
1654  assert(ProtoId < Class->NumProtos);
1655  assert(color != 0);
1656  window->Pen(color);
1657 
1658  ProtoSet = Class->ProtoSets[SetForProto(ProtoId)];
1659  ProtoSetIndex = IndexForProto(ProtoId);
1660  Proto = &(ProtoSet->Protos[ProtoSetIndex]);
1661  Length = (Class->ProtoLengths[ProtoId] *
1663  ProtoMask = PPrunerMaskFor(ProtoId);
1664  ProtoWordIndex = PPrunerWordIndexFor(ProtoId);
1665 
1666  // find the x and y extent of the proto from the proto pruning table
1667  Xmin = Ymin = NUM_PP_BUCKETS;
1668  Xmax = Ymax = 0;
1669  for (Bucket = 0; Bucket < NUM_PP_BUCKETS; Bucket++) {
1670  if (ProtoMask & ProtoSet->ProtoPruner[PRUNER_X][Bucket][ProtoWordIndex]) {
1671  UpdateRange(Bucket, &Xmin, &Xmax);
1672  }
1673 
1674  if (ProtoMask & ProtoSet->ProtoPruner[PRUNER_Y][Bucket][ProtoWordIndex]) {
1675  UpdateRange(Bucket, &Ymin, &Ymax);
1676  }
1677  }
1678  X = (Xmin + Xmax + 1) / 2.0 * PROTO_PRUNER_SCALE;
1679  Y = (Ymin + Ymax + 1) / 2.0 * PROTO_PRUNER_SCALE;
1680  // The -PI has no significant effect here, but the value of Theta is computed
1681  // using BinaryAnglePlusPi in intfx.cpp.
1682  Dx = (Length / 2.0) * cos((Proto->Angle / 256.0) * 2.0 * M_PI - M_PI);
1683  Dy = (Length / 2.0) * sin((Proto->Angle / 256.0) * 2.0 * M_PI - M_PI);
1684 
1685  window->SetCursor(X - Dx, Y - Dy);
1686  window->DrawTo(X + Dx, Y + Dy);

◆ TruncateParam()

int TruncateParam ( float  Param,
int  Min,
int  Max,
char *  Id 
)

This routine truncates Param to lie within the range of Min-Max inclusive. If a truncation is performed, and Id is not null, an warning message is printed.

Parameters
Paramparameter value to be truncated
Min,Maxparameter limits (inclusive)
Idstring id of parameter for error messages

Globals: none

Returns
Truncated parameter.

Definition at line 1702 of file intproto.cpp.

1703  {
1704  if (Param < Min) {
1705  if (Id)
1706  cprintf("Warning: Param %s truncated from %f to %d!\n",
1707  Id, Param, Min);
1708  Param = Min;
1709  } else if (Param > Max) {
1710  if (Id)
1711  cprintf("Warning: Param %s truncated from %f to %d!\n",
1712  Id, Param, Max);
1713  Param = Max;
1714  }
1715  return static_cast<int>(std::floor(Param));

◆ UpdateMatchDisplay()

void UpdateMatchDisplay ( )

This routine clears the global feature and proto display lists.

Globals:

  • FeatureShapes display list for features
  • ProtoShapes display list for protos

Definition at line 446 of file intproto.cpp.

447  {
448  if (IntMatchWindow != nullptr)
449  IntMatchWindow->Update();
FILL_SPEC::X
int8_t X
Definition: intproto.cpp:97
INT_TEMPLATES_STRUCT
Definition: intproto.h:117
PROTO_STRUCT::Length
float Length
Definition: protos.h:41
INT_CLASS_STRUCT::ConfigLengths
uint16_t ConfigLengths[MAX_NUM_CONFIGS]
Definition: intproto.h:110
ScrollView
Definition: scrollview.h:97
PROTOS_PER_PROTO_SET
#define PROTOS_PER_PROTO_SET
Definition: intproto.h:48
PROTO_PRUNER_SCALE
#define PROTO_PRUNER_SCALE
Definition: intproto.cpp:47
TABLE_FILLER::Switch
FILL_SWITCH Switch[MAX_NUM_SWITCHES]
Definition: intproto.cpp:89
PRUNER_ANGLE
#define PRUNER_ANGLE
Definition: intproto.h:36
IDA_SHAPE_INDEX
Definition: intproto.h:156
PROTO_SET_STRUCT::Protos
INT_PROTO_STRUCT Protos[PROTOS_PER_PROTO_SET]
Definition: intproto.h:96
FILL_SPEC
Definition: intproto.cpp:95
GetMatchColorFor
ScrollView::Color GetMatchColorFor(float Evidence)
Definition: intproto.cpp:1371
FillPPLinearBits
void FillPPLinearBits(uint32_t ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, float Center, float Spread, bool debug)
Definition: intproto.cpp:1224
FPOINT::y
float y
Definition: fpoint.h:44
Emalloc
void * Emalloc(int Size)
Definition: emalloc.cpp:31
FILL_SWITCH::YInit
int16_t YInit
Definition: intproto.cpp:75
Bucket8For
uint8_t Bucket8For(float param, float offset, int num_buckets)
Definition: intproto.cpp:417
MAX_LEVEL
#define MAX_LEVEL
INT_CLASS_STRUCT
Definition: intproto.h:104
FILL_SPEC::YEnd
int8_t YEnd
Definition: intproto.cpp:98
BucketEnd
float BucketEnd(int Bucket, float Offset, int NumBuckets)
Definition: intproto.cpp:1109
INT_FEATURE_STRUCT::Theta
uint8_t Theta
Definition: intproto.h:141
INT_PROTO_STRUCT
Definition: intproto.h:80
FILL_SPEC::AngleEnd
uint8_t AngleEnd
Definition: intproto.cpp:99
Config
CLUSTERCONFIG Config
Definition: commontraining.cpp:88
test_bit
#define test_bit(array, bit)
Definition: bitvec.h:58
INT_CHAR_NORM_RANGE
#define INT_CHAR_NORM_RANGE
Definition: intproto.h:129
INT_PROTO_STRUCT::Configs
uint32_t Configs[WERDS_PER_CONFIG_VEC]
Definition: intproto.h:85
FPOINT
Definition: fpoint.h:28
cprintf
void cprintf(const char *format,...)
Definition: callcpp.cpp:32
TABLE_FILLER
Definition: intproto.cpp:82
ScrollView::Pen
void Pen(Color color)
Definition: scrollview.cpp:717
ScrollView::DrawTo
void DrawTo(int x, int y)
Definition: scrollview.cpp:524
PRUNER_X
#define PRUNER_X
Definition: intproto.h:34
Bucket16For
uint16_t Bucket16For(float param, float offset, int num_buckets)
Definition: intproto.cpp:421
NUM_PP_BUCKETS
#define NUM_PP_BUCKETS
Definition: intproto.h:51
InitTableFiller
void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO Proto, TABLE_FILLER *Filler)
Definition: intproto.cpp:1440
IntCastRounded
int IntCastRounded(double x)
Definition: helpers.h:173
CircBucketFor
uint8_t CircBucketFor(float param, float offset, int num_buckets)
Definition: intproto.cpp:431
FPOINT::x
float x
Definition: fpoint.h:44
MAX_NUM_PROTO_SETS
#define MAX_NUM_PROTO_SETS
Definition: intproto.h:49
PROTO_SET_STRUCT::ProtoPruner
PROTO_PRUNER ProtoPruner
Definition: intproto.h:95
INT_CLASS_STRUCT::NumProtos
uint16_t NumProtos
Definition: intproto.h:105
GetNextFill
void GetNextFill(TABLE_FILLER *Filler, FILL_SPEC *Fill)
Definition: intproto.cpp:1393
PRUNER_Y
#define PRUNER_Y
Definition: intproto.h:35
FILL_SWITCH::Type
SWITCH_TYPE Type
Definition: intproto.cpp:73
INT_TEMPLATES_STRUCT::NumClassPruners
int NumClassPruners
Definition: intproto.h:119
ScrollView::BLUE
Definition: scrollview.h:108
FILL_SPEC::AngleStart
uint8_t AngleStart
Definition: intproto.cpp:99
CPrunerWordIndexFor
#define CPrunerWordIndexFor(c)
Definition: intproto.h:181
Y_SHIFT
#define Y_SHIFT
Definition: intproto.h:41
INT_CLASS_STRUCT::NumProtoSets
uint8_t NumProtoSets
Definition: intproto.h:106
FILL_SPEC::YStart
int8_t YStart
Definition: intproto.cpp:98
IndexForProto
#define IndexForProto(P)
Definition: intproto.h:166
TABLE_FILLER::NextSwitch
uint8_t NextSwitch
Definition: intproto.cpp:84
INT_PROTO_STRUCT::Angle
uint8_t Angle
Definition: intproto.h:84
TABLE_FILLER::YStart
int16_t YStart
Definition: intproto.cpp:87
BucketStart
float BucketStart(int Bucket, float Offset, int NumBuckets)
Definition: intproto.cpp:1093
CPrunerMaskFor
#define CPrunerMaskFor(L, c)
Definition: intproto.h:183
TABLE_FILLER::X
int8_t X
Definition: intproto.cpp:86
BITS_PER_WERD
#define BITS_PER_WERD
Definition: intproto.h:44
LegalClassId
#define LegalClassId(c)
Definition: intproto.h:175
MAX_NUM_CONFIGS
#define MAX_NUM_CONFIGS
Definition: intproto.h:46
MAX_NUM_PROTOS
#define MAX_NUM_PROTOS
Definition: intproto.h:47
MAX_NUM_CLASSES
#define MAX_NUM_CLASSES
Definition: matchdefs.h:29
TABLE_FILLER::AngleStart
uint8_t AngleStart
Definition: intproto.cpp:85
EndSwitch
Definition: intproto.cpp:67
GetCPPadsForLevel
void GetCPPadsForLevel(int Level, float *EndPad, float *SidePad, float *AnglePad)
Definition: intproto.cpp:1332
NO_PROTO
#define NO_PROTO
Definition: matchdefs.h:40
INT_CLASS_STRUCT::ProtoLengths
uint8_t * ProtoLengths
Definition: intproto.h:109
PROTO_STRUCT::Y
float Y
Definition: protos.h:39
MaxNumIntProtosIn
#define MaxNumIntProtosIn(C)
Definition: intproto.h:164
MapParam
#define MapParam(P, O, N)
Definition: intproto.cpp:118
ANGLE_SHIFT
#define ANGLE_SHIFT
Definition: intproto.h:39
HV_TOLERANCE
#define HV_TOLERANCE
Definition: intproto.cpp:64
FillerDone
bool FillerDone(TABLE_FILLER *Filler)
Definition: intproto.cpp:1163
PROTO_STRUCT::X
float X
Definition: protos.h:38
CircularIncrement
#define CircularIncrement(i, r)
Definition: intproto.cpp:115
INT_TEMPLATES_STRUCT::NumClasses
int NumClasses
Definition: intproto.h:118
CreateFeatureSpaceWindow
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
Definition: intproto.cpp:1764
ScrollView::WHITE
Definition: scrollview.h:103
PROTO_STRUCT::Angle
float Angle
Definition: protos.h:40
INT_FEATURE_STRUCT::Y
uint8_t Y
Definition: intproto.h:140
WERDS_PER_CONFIG_VEC
#define WERDS_PER_CONFIG_VEC
Definition: intproto.h:67
DoFill
void DoFill(FILL_SPEC *FillSpec, CLASS_PRUNER_STRUCT *Pruner, uint32_t ClassMask, uint32_t ClassCount, uint32_t WordIndex)
Definition: intproto.cpp:1123
NUM_CP_BUCKETS
#define NUM_CP_BUCKETS
Definition: intproto.h:52
ScrollView::RED
Definition: scrollview.h:104
IDA_STATIC
Definition: intproto.h:155
MaxNumClassesIn
#define MaxNumClassesIn(T)
Definition: intproto.h:174
INT_CLASS_STRUCT::ProtoSets
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
Definition: intproto.h:108
Erealloc
void * Erealloc(void *ptr, int size)
Definition: emalloc.cpp:38
PPrunerWordIndexFor
#define PPrunerWordIndexFor(I)
Definition: intproto.h:169
AS
#define AS
RenderIntProto
void RenderIntProto(ScrollView *window, INT_CLASS Class, PROTO_ID ProtoId, ScrollView::Color color)
Definition: intproto.cpp:1637
SET_BIT
#define SET_BIT(array, bit)
Definition: bitvec.h:54
TABLE_FILLER::AngleEnd
uint8_t AngleEnd
Definition: intproto.cpp:85
SetForProto
#define SetForProto(P)
Definition: intproto.h:165
INT_TEMPLATES_STRUCT::Class
INT_CLASS Class[MAX_NUM_CLASSES]
Definition: intproto.h:120
StartSwitch
Definition: intproto.cpp:67
SVMenuNode
Definition: svmnode.h:35
PROTO_SET_STRUCT
Definition: intproto.h:94
FillPPCircularBits
void FillPPCircularBits(uint32_t ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, float Center, float Spread, bool debug)
Definition: intproto.cpp:1185
Efree
void Efree(void *ptr)
Definition: emalloc.cpp:45
ScrollView::GREEN
Definition: scrollview.h:106
CPrunerFor
#define CPrunerFor(T, c)
Definition: intproto.h:180
FILL_SWITCH::Y
int8_t Y
Definition: intproto.cpp:74
TABLE_FILLER::YEnd
int16_t YEnd
Definition: intproto.cpp:87
XS
#define XS
X_SHIFT
#define X_SHIFT
Definition: intproto.h:40
INT_TEMPLATES_STRUCT::ClassPruners
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
Definition: intproto.h:121
Modulo
int Modulo(int a, int b)
Definition: helpers.h:156
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34
CLASS_PRUNER_STRUCT
Definition: intproto.h:75
CLASS_PRUNER_STRUCT::p
uint32_t p[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]
Definition: intproto.h:77
ScrollView::Update
static void Update()
Definition: scrollview.cpp:708
FILL_SWITCH
Definition: intproto.cpp:71
ScrollView::SetCursor
void SetCursor(int x, int y)
Definition: scrollview.cpp:518
IDA_BOTH
Definition: intproto.h:157
ProtoForProtoId
#define ProtoForProtoId(C, P)
Definition: intproto.h:167
INT_CLASS_STRUCT::NumConfigs
uint8_t NumConfigs
Definition: intproto.h:107
ScrollView::Color
Color
Definition: scrollview.h:100
UpdateRange
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:118
TABLE_FILLER::StartDelta
int16_t StartDelta
Definition: intproto.cpp:88
FILL_SWITCH::X
int8_t X
Definition: intproto.cpp:74
INT_FEATURE_STRUCT::X
uint8_t X
Definition: intproto.h:139
OLD_MAX_NUM_CONFIGS
#define OLD_MAX_NUM_CONFIGS
Definition: intproto.cpp:107
FILL_SWITCH::Delta
int16_t Delta
Definition: intproto.cpp:76
ClassForClassId
#define ClassForClassId(T, c)
Definition: intproto.h:177
YS
#define YS
IDA_ADAPTIVE
Definition: intproto.h:154
LastSwitch
Definition: intproto.cpp:67
NB
#define NB
RenderIntFeature
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
Definition: intproto.cpp:1603
TABLE_FILLER::EndDelta
int16_t EndDelta
Definition: intproto.cpp:88
PPrunerMaskFor
#define PPrunerMaskFor(I)
Definition: intproto.h:172
GetPicoFeatureLength
#define GetPicoFeatureLength()
Definition: picofeat.h:56