tesseract  4.00.00dev
intproto.h File Reference
#include "genericvector.h"
#include "matchdefs.h"
#include "mfoutline.h"
#include "protos.h"
#include "scrollview.h"
#include "unicharset.h"

Go to the source code of this file.

Classes

struct  CLASS_PRUNER_STRUCT
 
struct  INT_PROTO_STRUCT
 
struct  PROTO_SET_STRUCT
 
struct  INT_CLASS_STRUCT
 
struct  INT_TEMPLATES_STRUCT
 
struct  INT_FEATURE_STRUCT
 

Namespaces

 tesseract
 

Macros

#define PRUNER_X   0
 
#define PRUNER_Y   1
 
#define PRUNER_ANGLE   2
 
#define ANGLE_SHIFT   (0.0)
 
#define X_SHIFT   (0.5)
 
#define Y_SHIFT   (0.5)
 
#define MAX_PROTO_INDEX   24
 
#define BITS_PER_WERD   static_cast<int>(8 * sizeof(uinT32))
 
#define MAX_NUM_CONFIGS   64
 
#define MAX_NUM_PROTOS   512
 
#define PROTOS_PER_PROTO_SET   64
 
#define MAX_NUM_PROTO_SETS   (MAX_NUM_PROTOS / PROTOS_PER_PROTO_SET)
 
#define NUM_PP_PARAMS   3
 
#define NUM_PP_BUCKETS   64
 
#define NUM_CP_BUCKETS   24
 
#define CLASSES_PER_CP   32
 
#define NUM_BITS_PER_CLASS   2
 
#define CLASS_PRUNER_CLASS_MASK   (~(~0u << NUM_BITS_PER_CLASS))
 
#define CLASSES_PER_CP_WERD   (CLASSES_PER_CP / NUM_BITS_PER_CLASS)
 
#define PROTOS_PER_PP_WERD   BITS_PER_WERD
 
#define BITS_PER_CP_VECTOR   (CLASSES_PER_CP * NUM_BITS_PER_CLASS)
 
#define MAX_NUM_CLASS_PRUNERS
 
#define WERDS_PER_CP_VECTOR   (BITS_PER_CP_VECTOR / BITS_PER_WERD)
 
#define WERDS_PER_PP_VECTOR
 
#define WERDS_PER_PP
 
#define WERDS_PER_CP
 
#define WERDS_PER_CONFIG_VEC
 
#define MAX_NUM_INT_FEATURES   512
 
#define INT_CHAR_NORM_RANGE   256
 
#define MaxNumIntProtosIn(C)   (C->NumProtoSets * PROTOS_PER_PROTO_SET)
 
#define SetForProto(P)   (P / PROTOS_PER_PROTO_SET)
 
#define IndexForProto(P)   (P % PROTOS_PER_PROTO_SET)
 
#define ProtoForProtoId(C, P)
 
#define PPrunerWordIndexFor(I)
 
#define PPrunerBitIndexFor(I)   ((I) % PROTOS_PER_PP_WERD)
 
#define PPrunerMaskFor(I)   (1 << PPrunerBitIndexFor (I))
 
#define MaxNumClassesIn(T)   (T->NumClassPruners * CLASSES_PER_CP)
 
#define LegalClassId(c)   ((c) >= 0 && (c) <= MAX_CLASS_ID)
 
#define UnusedClassIdIn(T, c)   ((T)->Class[c] == NULL)
 
#define ClassForClassId(T, c)   ((T)->Class[c])
 
#define ClassPrunersFor(T)   ((T)->ClassPruner)
 
#define CPrunerIdFor(c)   ((c) / CLASSES_PER_CP)
 
#define CPrunerFor(T, c)   ((T)->ClassPruners[CPrunerIdFor(c)])
 
#define CPrunerWordIndexFor(c)   (((c) % CLASSES_PER_CP) / CLASSES_PER_CP_WERD)
 
#define CPrunerBitIndexFor(c)   (((c) % CLASSES_PER_CP) % CLASSES_PER_CP_WERD)
 
#define CPrunerMaskFor(L, c)   (((L)+1) << CPrunerBitIndexFor (c) * NUM_BITS_PER_CLASS)
 
#define PRINT_MATCH_SUMMARY   0x001
 
#define DISPLAY_FEATURE_MATCHES   0x002
 
#define DISPLAY_PROTO_MATCHES   0x004
 
#define PRINT_FEATURE_MATCHES   0x008
 
#define PRINT_PROTO_MATCHES   0x010
 
#define CLIP_MATCH_EVIDENCE   0x020
 
#define MatchDebuggingOn(D)   (D)
 
#define PrintMatchSummaryOn(D)   ((D) & PRINT_MATCH_SUMMARY)
 
#define DisplayFeatureMatchesOn(D)   ((D) & DISPLAY_FEATURE_MATCHES)
 
#define DisplayProtoMatchesOn(D)   ((D) & DISPLAY_PROTO_MATCHES)
 
#define PrintFeatureMatchesOn(D)   ((D) & PRINT_FEATURE_MATCHES)
 
#define PrintProtoMatchesOn(D)   ((D) & PRINT_PROTO_MATCHES)
 
#define ClipMatchEvidenceOn(D)   ((D) & CLIP_MATCH_EVIDENCE)
 

Typedefs

typedef struct INT_PROTO_STRUCTINT_PROTO
 
typedef uinT32 PROTO_PRUNER[NUM_PP_PARAMS][NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR]
 
typedef struct PROTO_SET_STRUCTPROTO_SET
 
typedef uinT32 CONFIG_PRUNER[NUM_PP_PARAMS][NUM_PP_BUCKETS][4]
 
typedef struct INT_CLASS_STRUCTINT_CLASS
 
typedef struct INT_TEMPLATES_STRUCTINT_TEMPLATES
 
typedef INT_FEATURE_STRUCTINT_FEATURE
 
typedef INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
 

Enumerations

enum  IntmatcherDebugAction { IDA_ADAPTIVE, IDA_STATIC, IDA_SHAPE_INDEX, IDA_BOTH }
 

Functions

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 Bucket8For (FLOAT32 param, FLOAT32 offset, int num_buckets)
 
uinT16 Bucket16For (FLOAT32 param, FLOAT32 offset, int num_buckets)
 
uinT8 CircBucketFor (FLOAT32 param, FLOAT32 offset, int num_buckets)
 
void UpdateMatchDisplay ()
 
void ConvertConfig (BIT_VECTOR Config, int ConfigId, INT_CLASS Class)
 
void DisplayIntFeature (const INT_FEATURE_STRUCT *Feature, FLOAT32 Evidence)
 
void DisplayIntProto (INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence)
 
INT_CLASS NewIntClass (int MaxNumProtos, int MaxNumConfigs)
 
INT_TEMPLATES NewIntTemplates ()
 
void free_int_templates (INT_TEMPLATES templates)
 
void ShowMatchDisplay ()
 
void tesseract::ClearFeatureSpaceWindow (NORM_METHOD norm_method, ScrollView *window)
 
void RenderIntFeature (ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
 
void InitIntMatchWindowIfReqd ()
 
void InitProtoDisplayWindowIfReqd ()
 
void InitFeatureDisplayWindowIfReqd ()
 
ScrollViewCreateFeatureSpaceWindow (const char *name, int xpos, int ypos)
 

Macro Definition Documentation

◆ ANGLE_SHIFT

#define ANGLE_SHIFT   (0.0)

Definition at line 39 of file intproto.h.

◆ BITS_PER_CP_VECTOR

#define BITS_PER_CP_VECTOR   (CLASSES_PER_CP * NUM_BITS_PER_CLASS)

Definition at line 58 of file intproto.h.

◆ BITS_PER_WERD

#define BITS_PER_WERD   static_cast<int>(8 * sizeof(uinT32))

Definition at line 44 of file intproto.h.

◆ CLASS_PRUNER_CLASS_MASK

#define CLASS_PRUNER_CLASS_MASK   (~(~0u << NUM_BITS_PER_CLASS))

Definition at line 55 of file intproto.h.

◆ CLASSES_PER_CP

#define CLASSES_PER_CP   32

Definition at line 53 of file intproto.h.

◆ CLASSES_PER_CP_WERD

#define CLASSES_PER_CP_WERD   (CLASSES_PER_CP / NUM_BITS_PER_CLASS)

Definition at line 56 of file intproto.h.

◆ ClassForClassId

#define ClassForClassId (   T,
 
)    ((T)->Class[c])

Definition at line 181 of file intproto.h.

◆ ClassPrunersFor

#define ClassPrunersFor (   T)    ((T)->ClassPruner)

Definition at line 182 of file intproto.h.

◆ CLIP_MATCH_EVIDENCE

#define CLIP_MATCH_EVIDENCE   0x020

Definition at line 195 of file intproto.h.

◆ ClipMatchEvidenceOn

#define ClipMatchEvidenceOn (   D)    ((D) & CLIP_MATCH_EVIDENCE)

Definition at line 203 of file intproto.h.

◆ CPrunerBitIndexFor

#define CPrunerBitIndexFor (   c)    (((c) % CLASSES_PER_CP) % CLASSES_PER_CP_WERD)

Definition at line 186 of file intproto.h.

◆ CPrunerFor

#define CPrunerFor (   T,
 
)    ((T)->ClassPruners[CPrunerIdFor(c)])

Definition at line 184 of file intproto.h.

◆ CPrunerIdFor

#define CPrunerIdFor (   c)    ((c) / CLASSES_PER_CP)

Definition at line 183 of file intproto.h.

◆ CPrunerMaskFor

#define CPrunerMaskFor (   L,
 
)    (((L)+1) << CPrunerBitIndexFor (c) * NUM_BITS_PER_CLASS)

Definition at line 187 of file intproto.h.

◆ CPrunerWordIndexFor

#define CPrunerWordIndexFor (   c)    (((c) % CLASSES_PER_CP) / CLASSES_PER_CP_WERD)

Definition at line 185 of file intproto.h.

◆ DISPLAY_FEATURE_MATCHES

#define DISPLAY_FEATURE_MATCHES   0x002

Definition at line 191 of file intproto.h.

◆ DISPLAY_PROTO_MATCHES

#define DISPLAY_PROTO_MATCHES   0x004

Definition at line 192 of file intproto.h.

◆ DisplayFeatureMatchesOn

#define DisplayFeatureMatchesOn (   D)    ((D) & DISPLAY_FEATURE_MATCHES)

Definition at line 199 of file intproto.h.

◆ DisplayProtoMatchesOn

#define DisplayProtoMatchesOn (   D)    ((D) & DISPLAY_PROTO_MATCHES)

Definition at line 200 of file intproto.h.

◆ IndexForProto

#define IndexForProto (   P)    (P % PROTOS_PER_PROTO_SET)

Definition at line 170 of file intproto.h.

◆ INT_CHAR_NORM_RANGE

#define INT_CHAR_NORM_RANGE   256

Definition at line 133 of file intproto.h.

◆ LegalClassId

#define LegalClassId (   c)    ((c) >= 0 && (c) <= MAX_CLASS_ID)

Definition at line 179 of file intproto.h.

◆ MatchDebuggingOn

#define MatchDebuggingOn (   D)    (D)

Definition at line 197 of file intproto.h.

◆ MAX_NUM_CLASS_PRUNERS

#define MAX_NUM_CLASS_PRUNERS
Value:
#define CLASSES_PER_CP
Definition: intproto.h:53
#define MAX_NUM_CLASSES
Definition: matchdefs.h:31

Definition at line 59 of file intproto.h.

◆ MAX_NUM_CONFIGS

#define MAX_NUM_CONFIGS   64

Definition at line 46 of file intproto.h.

◆ MAX_NUM_INT_FEATURES

#define MAX_NUM_INT_FEATURES   512

Definition at line 132 of file intproto.h.

◆ MAX_NUM_PROTO_SETS

#define MAX_NUM_PROTO_SETS   (MAX_NUM_PROTOS / PROTOS_PER_PROTO_SET)

Definition at line 49 of file intproto.h.

◆ MAX_NUM_PROTOS

#define MAX_NUM_PROTOS   512

Definition at line 47 of file intproto.h.

◆ MAX_PROTO_INDEX

#define MAX_PROTO_INDEX   24

Definition at line 43 of file intproto.h.

◆ MaxNumClassesIn

#define MaxNumClassesIn (   T)    (T->NumClassPruners * CLASSES_PER_CP)

Definition at line 178 of file intproto.h.

◆ MaxNumIntProtosIn

#define MaxNumIntProtosIn (   C)    (C->NumProtoSets * PROTOS_PER_PROTO_SET)

Macros

Definition at line 168 of file intproto.h.

◆ NUM_BITS_PER_CLASS

#define NUM_BITS_PER_CLASS   2

Definition at line 54 of file intproto.h.

◆ NUM_CP_BUCKETS

#define NUM_CP_BUCKETS   24

Definition at line 52 of file intproto.h.

◆ NUM_PP_BUCKETS

#define NUM_PP_BUCKETS   64

Definition at line 51 of file intproto.h.

◆ NUM_PP_PARAMS

#define NUM_PP_PARAMS   3

Definition at line 50 of file intproto.h.

◆ PPrunerBitIndexFor

#define PPrunerBitIndexFor (   I)    ((I) % PROTOS_PER_PP_WERD)

Definition at line 175 of file intproto.h.

◆ PPrunerMaskFor

#define PPrunerMaskFor (   I)    (1 << PPrunerBitIndexFor (I))

Definition at line 176 of file intproto.h.

◆ PPrunerWordIndexFor

#define PPrunerWordIndexFor (   I)
Value:
PROTOS_PER_PP_WERD)
#define PROTOS_PER_PROTO_SET
Definition: intproto.h:48

Definition at line 173 of file intproto.h.

◆ PRINT_FEATURE_MATCHES

#define PRINT_FEATURE_MATCHES   0x008

Definition at line 193 of file intproto.h.

◆ PRINT_MATCH_SUMMARY

#define PRINT_MATCH_SUMMARY   0x001

Definition at line 190 of file intproto.h.

◆ PRINT_PROTO_MATCHES

#define PRINT_PROTO_MATCHES   0x010

Definition at line 194 of file intproto.h.

◆ PrintFeatureMatchesOn

#define PrintFeatureMatchesOn (   D)    ((D) & PRINT_FEATURE_MATCHES)

Definition at line 201 of file intproto.h.

◆ PrintMatchSummaryOn

#define PrintMatchSummaryOn (   D)    ((D) & PRINT_MATCH_SUMMARY)

Definition at line 198 of file intproto.h.

◆ PrintProtoMatchesOn

#define PrintProtoMatchesOn (   D)    ((D) & PRINT_PROTO_MATCHES)

Definition at line 202 of file intproto.h.

◆ ProtoForProtoId

#define ProtoForProtoId (   C,
 
)
Value:
(&((C->ProtoSets[SetForProto (P)])-> \
Protos [IndexForProto (P)]))
#define IndexForProto(P)
Definition: intproto.h:170
#define SetForProto(P)
Definition: intproto.h:169

Definition at line 171 of file intproto.h.

◆ PROTOS_PER_PP_WERD

#define PROTOS_PER_PP_WERD   BITS_PER_WERD

Definition at line 57 of file intproto.h.

◆ PROTOS_PER_PROTO_SET

#define PROTOS_PER_PROTO_SET   64

Definition at line 48 of file intproto.h.

◆ PRUNER_ANGLE

#define PRUNER_ANGLE   2

Definition at line 36 of file intproto.h.

◆ PRUNER_X

#define PRUNER_X   0

Definition at line 34 of file intproto.h.

◆ PRUNER_Y

#define PRUNER_Y   1

Definition at line 35 of file intproto.h.

◆ SetForProto

#define SetForProto (   P)    (P / PROTOS_PER_PROTO_SET)

Definition at line 169 of file intproto.h.

◆ UnusedClassIdIn

#define UnusedClassIdIn (   T,
 
)    ((T)->Class[c] == NULL)

Definition at line 180 of file intproto.h.

◆ WERDS_PER_CONFIG_VEC

#define WERDS_PER_CONFIG_VEC
Value:
#define BITS_PER_WERD
Definition: intproto.h:44
#define MAX_NUM_CONFIGS
Definition: intproto.h:46

Definition at line 68 of file intproto.h.

◆ WERDS_PER_CP

#define WERDS_PER_CP
Value:
NUM_CP_BUCKETS * WERDS_PER_CP_VECTOR)
#define WERDS_PER_CP_VECTOR
Definition: intproto.h:61
#define NUM_CP_BUCKETS
Definition: intproto.h:52

Definition at line 66 of file intproto.h.

◆ WERDS_PER_CP_VECTOR

#define WERDS_PER_CP_VECTOR   (BITS_PER_CP_VECTOR / BITS_PER_WERD)

Definition at line 61 of file intproto.h.

◆ WERDS_PER_PP

#define WERDS_PER_PP
Value:
WERDS_PER_PP_VECTOR)
#define NUM_PP_PARAMS
Definition: intproto.h:50
#define NUM_PP_BUCKETS
Definition: intproto.h:51

Definition at line 64 of file intproto.h.

◆ WERDS_PER_PP_VECTOR

#define WERDS_PER_PP_VECTOR
Value:
#define BITS_PER_WERD
Definition: intproto.h:44
#define PROTOS_PER_PROTO_SET
Definition: intproto.h:48

Definition at line 62 of file intproto.h.

◆ X_SHIFT

#define X_SHIFT   (0.5)

Definition at line 40 of file intproto.h.

◆ Y_SHIFT

#define Y_SHIFT   (0.5)

Definition at line 41 of file intproto.h.

Typedef Documentation

◆ CONFIG_PRUNER

typedef uinT32 CONFIG_PRUNER[NUM_PP_PARAMS][NUM_PP_BUCKETS][4]

Definition at line 103 of file intproto.h.

◆ INT_CLASS

typedef struct INT_CLASS_STRUCT * INT_CLASS

◆ INT_FEATURE

Definition at line 153 of file intproto.h.

◆ INT_FEATURE_ARRAY

typedef INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]

Definition at line 155 of file intproto.h.

◆ INT_PROTO

typedef struct INT_PROTO_STRUCT * INT_PROTO

◆ INT_TEMPLATES

◆ PROTO_PRUNER

Definition at line 92 of file intproto.h.

◆ PROTO_SET

typedef struct PROTO_SET_STRUCT * PROTO_SET

Enumeration Type Documentation

◆ IntmatcherDebugAction

Enumerator
IDA_ADAPTIVE 
IDA_STATIC 
IDA_SHAPE_INDEX 
IDA_BOTH 

Definition at line 157 of file intproto.h.

157  {
158  IDA_ADAPTIVE,
159  IDA_STATIC,
161  IDA_BOTH
162 };

Function Documentation

◆ AddIntClass()

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

Public Function Prototypes

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

Note
Exceptions: none
History: Mon Feb 11 11:52:08 1991, DSJ, Created.

Definition at line 238 of file intproto.cpp.

238  {
239  int Pruner;
240 
241  assert (LegalClassId (ClassId));
242  if (ClassId != Templates->NumClasses) {
243  fprintf(stderr, "Please make sure that classes are added to templates");
244  fprintf(stderr, " in increasing order of ClassIds\n");
245  exit(1);
246  }
247  ClassForClassId (Templates, ClassId) = Class;
248  Templates->NumClasses++;
249 
250  if (Templates->NumClasses > MaxNumClassesIn (Templates)) {
251  Pruner = Templates->NumClassPruners++;
252  Templates->ClassPruners[Pruner] = new CLASS_PRUNER_STRUCT;
253  memset(Templates->ClassPruners[Pruner], 0, sizeof(CLASS_PRUNER_STRUCT));
254  }
255 } /* AddIntClass */
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
Definition: intproto.h:125
#define LegalClassId(c)
Definition: intproto.h:179
#define ClassForClassId(T, c)
Definition: intproto.h:181
#define MaxNumClassesIn(T)
Definition: intproto.h:178

◆ 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.
Note
Exceptions: none
History: Mon Feb 11 14:44:40 1991, DSJ, Created.

Definition at line 270 of file intproto.cpp.

270  {
271  int Index;
272 
273  assert(Class->NumConfigs < MAX_NUM_CONFIGS);
274 
275  Index = Class->NumConfigs++;
276  Class->ConfigLengths[Index] = 0;
277  return Index;
278 } /* AddIntConfig */
uinT8 NumConfigs
Definition: intproto.h:110
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
Definition: intproto.h:113
#define MAX_NUM_CONFIGS
Definition: intproto.h:46

◆ 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.
Note
Exceptions: none
History: Mon Feb 11 13:26:41 1991, DSJ, Created.

Definition at line 293 of file intproto.cpp.

293  {
294  int Index;
295  int ProtoSetId;
296  PROTO_SET ProtoSet;
297  INT_PROTO Proto;
298  uinT32 *Word;
299 
300  if (Class->NumProtos >= MAX_NUM_PROTOS)
301  return (NO_PROTO);
302 
303  Index = Class->NumProtos++;
304 
305  if (Class->NumProtos > MaxNumIntProtosIn(Class)) {
306  ProtoSetId = Class->NumProtoSets++;
307 
308  ProtoSet = (PROTO_SET) Emalloc(sizeof(PROTO_SET_STRUCT));
309  Class->ProtoSets[ProtoSetId] = ProtoSet;
310  memset(ProtoSet, 0, sizeof(*ProtoSet));
311 
312  /* reallocate space for the proto lengths and install in class */
313  Class->ProtoLengths =
314  (uinT8 *)Erealloc(Class->ProtoLengths,
315  MaxNumIntProtosIn(Class) * sizeof(uinT8));
316  memset(&Class->ProtoLengths[Index], 0,
317  sizeof(*Class->ProtoLengths) * (MaxNumIntProtosIn(Class) - Index));
318  }
319 
320  /* initialize proto so its length is zero and it isn't in any configs */
321  Class->ProtoLengths[Index] = 0;
322  Proto = ProtoForProtoId (Class, Index);
323  for (Word = Proto->Configs;
324  Word < Proto->Configs + WERDS_PER_CONFIG_VEC; *Word++ = 0);
325 
326  return (Index);
327 }
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
Definition: intproto.h:111
uinT8 NumProtoSets
Definition: intproto.h:109
#define MAX_NUM_PROTOS
Definition: intproto.h:47
struct PROTO_SET_STRUCT * PROTO_SET
void * Emalloc(int Size)
Definition: emalloc.cpp:47
uinT16 NumProtos
Definition: intproto.h:108
uinT8 * ProtoLengths
Definition: intproto.h:112
#define ProtoForProtoId(C, P)
Definition: intproto.h:171
uint32_t uinT32
Definition: host.h:39
uinT32 Configs[WERDS_PER_CONFIG_VEC]
Definition: intproto.h:86
#define NO_PROTO
Definition: matchdefs.h:42
void * Erealloc(void *ptr, int size)
Definition: emalloc.cpp:64
uint8_t uinT8
Definition: host.h:35
#define MaxNumIntProtosIn(C)
Definition: intproto.h:168
#define WERDS_PER_CONFIG_VEC
Definition: intproto.h:68

◆ 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
    Returns
    none
    Note
    Exceptions: none
    History: Wed Feb 13 08:49:54 1991, DSJ, Created.

Definition at line 342 of file intproto.cpp.

345 {
346  CLASS_PRUNER_STRUCT* Pruner;
347  uinT32 ClassMask;
348  uinT32 ClassCount;
349  uinT32 WordIndex;
350  int Level;
351  FLOAT32 EndPad, SidePad, AnglePad;
352  TABLE_FILLER TableFiller;
353  FILL_SPEC FillSpec;
354 
355  Pruner = CPrunerFor (Templates, ClassId);
356  WordIndex = CPrunerWordIndexFor (ClassId);
357  ClassMask = CPrunerMaskFor (MAX_LEVEL, ClassId);
358 
359  for (Level = classify_num_cp_levels - 1; Level >= 0; Level--) {
360  GetCPPadsForLevel(Level, &EndPad, &SidePad, &AnglePad);
361  ClassCount = CPrunerMaskFor (Level, ClassId);
362  InitTableFiller(EndPad, SidePad, AnglePad, Proto, &TableFiller);
363 
364  while (!FillerDone (&TableFiller)) {
365  GetNextFill(&TableFiller, &FillSpec);
366  DoFill(&FillSpec, Pruner, ClassMask, ClassCount, WordIndex);
367  }
368  }
369 } /* AddProtoToClassPruner */
void InitTableFiller(FLOAT32 EndPad, FLOAT32 SidePad, FLOAT32 AnglePad, PROTO Proto, TABLE_FILLER *Filler)
Definition: intproto.cpp:1528
void DoFill(FILL_SPEC *FillSpec, CLASS_PRUNER_STRUCT *Pruner, register uinT32 ClassMask, register uinT32 ClassCount, register uinT32 WordIndex)
Definition: intproto.cpp:1181
#define CPrunerWordIndexFor(c)
Definition: intproto.h:185
int classify_num_cp_levels
Definition: intproto.cpp:188
uint32_t uinT32
Definition: host.h:39
#define CPrunerFor(T, c)
Definition: intproto.h:184
void GetCPPadsForLevel(int Level, FLOAT32 *EndPad, FLOAT32 *SidePad, FLOAT32 *AnglePad)
Definition: intproto.cpp:1409
float FLOAT32
Definition: host.h:42
void GetNextFill(TABLE_FILLER *Filler, FILL_SPEC *Fill)
Definition: intproto.cpp:1476
#define CPrunerMaskFor(L, c)
Definition: intproto.h:187
BOOL8 FillerDone(TABLE_FILLER *Filler)
Definition: intproto.cpp:1223
#define MAX_LEVEL

◆ 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
Returns
none
Note
Exceptions: none
History: Fri Feb 8 13:07:19 1991, DSJ, Created.

Definition at line 384 of file intproto.cpp.

385  {
386  FLOAT32 Angle, X, Y, Length;
387  FLOAT32 Pad;
388  int Index;
389  PROTO_SET ProtoSet;
390 
391  if (ProtoId >= Class->NumProtos)
392  cprintf("AddProtoToProtoPruner:assert failed: %d < %d",
393  ProtoId, Class->NumProtos);
394  assert(ProtoId < Class->NumProtos);
395 
396  Index = IndexForProto (ProtoId);
397  ProtoSet = Class->ProtoSets[SetForProto (ProtoId)];
398 
399  Angle = Proto->Angle;
400 #ifndef _WIN32
401  assert(!isnan(Angle));
402 #endif
403 
404  FillPPCircularBits (ProtoSet->ProtoPruner[PRUNER_ANGLE], Index,
405  Angle + ANGLE_SHIFT, classify_pp_angle_pad / 360.0,
406  debug);
407 
408  Angle *= 2.0 * PI;
409  Length = Proto->Length;
410 
411  X = Proto->X + X_SHIFT;
412  Pad = MAX (fabs (cos (Angle)) * (Length / 2.0 +
415  fabs (sin (Angle)) * (classify_pp_side_pad *
417 
418  FillPPLinearBits(ProtoSet->ProtoPruner[PRUNER_X], Index, X, Pad, debug);
419 
420  Y = Proto->Y + Y_SHIFT;
421  Pad = MAX (fabs (sin (Angle)) * (Length / 2.0 +
424  fabs (cos (Angle)) * (classify_pp_side_pad *
426 
427  FillPPLinearBits(ProtoSet->ProtoPruner[PRUNER_Y], Index, Y, Pad, debug);
428 } /* AddProtoToProtoPruner */
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
Definition: intproto.h:111
#define PRUNER_ANGLE
Definition: intproto.h:36
#define PRUNER_Y
Definition: intproto.h:35
void FillPPCircularBits(uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, FLOAT32 Center, FLOAT32 Spread, bool debug)
Definition: intproto.cpp:1252
uinT16 NumProtos
Definition: intproto.h:108
double classify_pp_side_pad
Definition: intproto.cpp:203
PROTO_PRUNER ProtoPruner
Definition: intproto.h:96
FLOAT32 Length
Definition: protos.h:50
#define PI
Definition: const.h:19
#define Y_SHIFT
Definition: intproto.h:41
#define X_SHIFT
Definition: intproto.h:40
#define IndexForProto(P)
Definition: intproto.h:170
#define isnan(x)
Definition: mathfix.h:31
FLOAT32 Y
Definition: protos.h:48
FLOAT32 X
Definition: protos.h:47
#define ANGLE_SHIFT
Definition: intproto.h:39
#define MAX(x, y)
Definition: ndminx.h:24
#define SetForProto(P)
Definition: intproto.h:169
float FLOAT32
Definition: host.h:42
#define PRUNER_X
Definition: intproto.h:34
FLOAT32 Angle
Definition: protos.h:49
void cprintf(const char *format,...)
Definition: callcpp.cpp:40
double classify_pp_angle_pad
Definition: intproto.cpp:201
void FillPPLinearBits(uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, FLOAT32 Center, FLOAT32 Spread, bool debug)
Definition: intproto.cpp:1295
#define GetPicoFeatureLength()
Definition: picofeat.h:59
double classify_pp_end_pad
Definition: intproto.cpp:202

◆ Bucket16For()

uinT16 Bucket16For ( FLOAT32  param,
FLOAT32  offset,
int  num_buckets 
)

Definition at line 439 of file intproto.cpp.

439  {
440  int bucket = IntCastRounded(MapParam(param, offset, num_buckets));
441  return static_cast<uinT16>(ClipToRange(bucket, 0, num_buckets - 1));
442 }
voidpf uLong offset
Definition: ioapi.h:42
#define MapParam(P, O, N)
Definition: intproto.cpp:123
int IntCastRounded(double x)
Definition: helpers.h:179
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:122
uint16_t uinT16
Definition: host.h:37

◆ Bucket8For()

uinT8 Bucket8For ( FLOAT32  param,
FLOAT32  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 435 of file intproto.cpp.

435  {
436  int bucket = IntCastRounded(MapParam(param, offset, num_buckets));
437  return static_cast<uinT8>(ClipToRange(bucket, 0, num_buckets - 1));
438 }
voidpf uLong offset
Definition: ioapi.h:42
#define MapParam(P, O, N)
Definition: intproto.cpp:123
int IntCastRounded(double x)
Definition: helpers.h:179
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:122
uint8_t uinT8
Definition: host.h:35

◆ CircBucketFor()

uinT8 CircBucketFor ( FLOAT32  param,
FLOAT32  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 449 of file intproto.cpp.

449  {
450  int bucket = IntCastRounded(MapParam(param, offset, num_buckets));
451  return static_cast<uinT8>(Modulo(bucket, num_buckets));
452 } /* CircBucketFor */
voidpf uLong offset
Definition: ioapi.h:42
#define MapParam(P, O, N)
Definition: intproto.cpp:123
int IntCastRounded(double x)
Definition: helpers.h:179
uint8_t uinT8
Definition: host.h:35
int Modulo(int a, int b)
Definition: helpers.h:164

◆ 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
Returns
none
Note
Globals: none
Exceptions: none
History: Mon Feb 11 14:57:31 1991, DSJ, Created.

Definition at line 487 of file intproto.cpp.

487  {
488  int ProtoId;
489  INT_PROTO Proto;
490  int TotalLength;
491 
492  for (ProtoId = 0, TotalLength = 0;
493  ProtoId < Class->NumProtos; ProtoId++) {
494  if (test_bit(Config, ProtoId)) {
495  Proto = ProtoForProtoId(Class, ProtoId);
496  SET_BIT(Proto->Configs, ConfigId);
497  TotalLength += Class->ProtoLengths[ProtoId];
498  }
499  }
500  Class->ConfigLengths[ConfigId] = TotalLength;
501 } /* ConvertConfig */
uinT16 NumProtos
Definition: intproto.h:108
CLUSTERCONFIG Config
uinT8 * ProtoLengths
Definition: intproto.h:112
#define ProtoForProtoId(C, P)
Definition: intproto.h:171
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
Definition: intproto.h:113
uinT32 Configs[WERDS_PER_CONFIG_VEC]
Definition: intproto.h:86
#define test_bit(array, bit)
Definition: bitvec.h:61
#define SET_BIT(array, bit)
Definition: bitvec.h:57

◆ 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 1858 of file intproto.cpp.

1858  {
1859  return new ScrollView(name, xpos, ypos, 520, 520, 260, 260, true);
1860 }

◆ DisplayIntFeature()

void DisplayIntFeature ( const INT_FEATURE_STRUCT Feature,
FLOAT32  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)
    Returns
    none
    Note
    Exceptions: none
    History: Thu Mar 21 14:45:04 1991, DSJ, Created.

Definition at line 623 of file intproto.cpp.

623  {
624  ScrollView::Color color = GetMatchColorFor(Evidence);
625  RenderIntFeature(IntMatchWindow, Feature, color);
626  if (FeatureDisplayWindow) {
627  RenderIntFeature(FeatureDisplayWindow, Feature, color);
628  }
629 } /* DisplayIntFeature */
ScrollView * IntMatchWindow
Definition: intproto.cpp:179
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
Definition: intproto.cpp:1693
ScrollView * FeatureDisplayWindow
Definition: intproto.cpp:180
ScrollView::Color GetMatchColorFor(FLOAT32 Evidence)
Definition: intproto.cpp:1450

◆ DisplayIntProto()

void DisplayIntProto ( INT_CLASS  Class,
PROTO_ID  ProtoId,
FLOAT32  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)
    Returns
    none
    Note
    Exceptions: none
    History: Thu Mar 21 14:45:04 1991, DSJ, Created.

Definition at line 644 of file intproto.cpp.

644  {
645  ScrollView::Color color = GetMatchColorFor(Evidence);
646  RenderIntProto(IntMatchWindow, Class, ProtoId, color);
647  if (ProtoDisplayWindow) {
648  RenderIntProto(ProtoDisplayWindow, Class, ProtoId, color);
649  }
650 } /* DisplayIntProto */
ScrollView * IntMatchWindow
Definition: intproto.cpp:179
void RenderIntProto(ScrollView *window, INT_CLASS Class, PROTO_ID ProtoId, ScrollView::Color color)
Definition: intproto.cpp:1729
ScrollView::Color GetMatchColorFor(FLOAT32 Evidence)
Definition: intproto.cpp:1450
ScrollView * ProtoDisplayWindow
Definition: intproto.cpp:181

◆ free_int_templates()

void free_int_templates ( INT_TEMPLATES  templates)

Definition at line 739 of file intproto.cpp.

739  {
740  int i;
741 
742  for (i = 0; i < templates->NumClasses; i++)
743  free_int_class(templates->Class[i]);
744  for (i = 0; i < templates->NumClassPruners; i++)
745  delete templates->ClassPruners[i];
746  Efree(templates);
747 }
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
Definition: intproto.h:125
void free_int_class(INT_CLASS int_class)
Definition: intproto.cpp:703
INT_CLASS Class[MAX_NUM_CLASSES]
Definition: intproto.h:124
void Efree(void *ptr)
Definition: emalloc.cpp:79

◆ InitFeatureDisplayWindowIfReqd()

void InitFeatureDisplayWindowIfReqd ( )

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

Definition at line 1849 of file intproto.cpp.

1849  {
1850  if (FeatureDisplayWindow == NULL) {
1851  FeatureDisplayWindow = CreateFeatureSpaceWindow("FeatureDisplayWindow",
1852  50, 700);
1853  }
1854 }
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
Definition: intproto.cpp:1858
ScrollView * FeatureDisplayWindow
Definition: intproto.cpp:180

◆ InitIntMatchWindowIfReqd()

void InitIntMatchWindowIfReqd ( )

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

Definition at line 1817 of file intproto.cpp.

1817  {
1818  if (IntMatchWindow == NULL) {
1819  IntMatchWindow = CreateFeatureSpaceWindow("IntMatchWindow", 50, 200);
1820  SVMenuNode* popup_menu = new SVMenuNode();
1821 
1822  popup_menu->AddChild("Debug Adapted classes", IDA_ADAPTIVE,
1823  "x", "Class to debug");
1824  popup_menu->AddChild("Debug Static classes", IDA_STATIC,
1825  "x", "Class to debug");
1826  popup_menu->AddChild("Debug Both", IDA_BOTH,
1827  "x", "Class to debug");
1828  popup_menu->AddChild("Debug Shape Index", IDA_SHAPE_INDEX,
1829  "0", "Index to debug");
1830  popup_menu->BuildMenu(IntMatchWindow, false);
1831  }
1832 }
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
Definition: intproto.cpp:1858
ScrollView * IntMatchWindow
Definition: intproto.cpp:179
SVMenuNode * AddChild(const char *txt)
Definition: svmnode.cpp:59
void BuildMenu(ScrollView *sv, bool menu_bar=true)
Definition: svmnode.cpp:121

◆ InitProtoDisplayWindowIfReqd()

void InitProtoDisplayWindowIfReqd ( )

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

Definition at line 1838 of file intproto.cpp.

1838  {
1839  if (ProtoDisplayWindow == NULL) {
1840  ProtoDisplayWindow = CreateFeatureSpaceWindow("ProtoDisplayWindow",
1841  550, 200);
1842  }
1843 }
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
Definition: intproto.cpp:1858
ScrollView * ProtoDisplayWindow
Definition: intproto.cpp:181

◆ 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
Exceptions: none
History: Fri Feb 8 10:51:23 1991, DSJ, Created.

Definition at line 664 of file intproto.cpp.

664  {
665  INT_CLASS Class;
666  PROTO_SET ProtoSet;
667  int i;
668 
669  assert(MaxNumConfigs <= MAX_NUM_CONFIGS);
670 
671  Class = (INT_CLASS) Emalloc(sizeof(INT_CLASS_STRUCT));
672  Class->NumProtoSets = ((MaxNumProtos + PROTOS_PER_PROTO_SET - 1) /
674 
675  assert(Class->NumProtoSets <= MAX_NUM_PROTO_SETS);
676 
677  Class->NumProtos = 0;
678  Class->NumConfigs = 0;
679 
680  for (i = 0; i < Class->NumProtoSets; i++) {
681  /* allocate space for a proto set, install in class, and initialize */
682  ProtoSet = (PROTO_SET) Emalloc(sizeof(PROTO_SET_STRUCT));
683  memset(ProtoSet, 0, sizeof(*ProtoSet));
684  Class->ProtoSets[i] = ProtoSet;
685 
686  /* allocate space for the proto lengths and install in class */
687  }
688  if (MaxNumIntProtosIn (Class) > 0) {
689  Class->ProtoLengths =
690  (uinT8 *)Emalloc(MaxNumIntProtosIn (Class) * sizeof (uinT8));
691  memset(Class->ProtoLengths, 0,
692  MaxNumIntProtosIn(Class) * sizeof(*Class->ProtoLengths));
693  } else {
694  Class->ProtoLengths = NULL;
695  }
696  memset(Class->ConfigLengths, 0, sizeof(Class->ConfigLengths));
697 
698  return (Class);
699 
700 } /* NewIntClass */
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
Definition: intproto.h:111
uinT8 NumProtoSets
Definition: intproto.h:109
uinT8 NumConfigs
Definition: intproto.h:110
struct PROTO_SET_STRUCT * PROTO_SET
void * Emalloc(int Size)
Definition: emalloc.cpp:47
uinT16 NumProtos
Definition: intproto.h:108
uinT8 * ProtoLengths
Definition: intproto.h:112
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
Definition: intproto.h:113
#define MAX_NUM_PROTO_SETS
Definition: intproto.h:49
struct INT_CLASS_STRUCT * INT_CLASS
#define PROTOS_PER_PROTO_SET
Definition: intproto.h:48
uint8_t uinT8
Definition: host.h:35
#define MAX_NUM_CONFIGS
Definition: intproto.h:46
#define MaxNumIntProtosIn(C)
Definition: intproto.h:168

◆ 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
Exceptions: none
History: Fri Feb 8 08:38:51 1991, DSJ, Created.

Definition at line 723 of file intproto.cpp.

723  {
724  INT_TEMPLATES T;
725  int i;
726 
727  T = (INT_TEMPLATES) Emalloc (sizeof (INT_TEMPLATES_STRUCT));
728  T->NumClasses = 0;
729  T->NumClassPruners = 0;
730 
731  for (i = 0; i < MAX_NUM_CLASSES; i++)
732  ClassForClassId (T, i) = NULL;
733 
734  return (T);
735 } /* NewIntTemplates */
void * Emalloc(int Size)
Definition: emalloc.cpp:47
#define ClassForClassId(T, c)
Definition: intproto.h:181
struct INT_TEMPLATES_STRUCT * INT_TEMPLATES
#define MAX_NUM_CLASSES
Definition: matchdefs.h:31

◆ 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
Exceptions: none
History: Thu Mar 21 14:57:41 1991, DSJ, Created.

Definition at line 1693 of file intproto.cpp.

1694  {
1695  FLOAT32 X, Y, Dx, Dy, Length;
1696 
1697  window->Pen(color);
1698  assert(Feature != NULL);
1699  assert(color != 0);
1700 
1701  X = Feature->X;
1702  Y = Feature->Y;
1703  Length = GetPicoFeatureLength() * 0.7 * INT_CHAR_NORM_RANGE;
1704  // The -PI has no significant effect here, but the value of Theta is computed
1705  // using BinaryAnglePlusPi in intfx.cpp.
1706  Dx = (Length / 2.0) * cos((Feature->Theta / 256.0) * 2.0 * PI - PI);
1707  Dy = (Length / 2.0) * sin((Feature->Theta / 256.0) * 2.0 * PI - PI);
1708 
1709  window->SetCursor(X, Y);
1710  window->DrawTo(X + Dx, Y + Dy);
1711 } /* RenderIntFeature */
void SetCursor(int x, int y)
Definition: scrollview.cpp:525
#define PI
Definition: const.h:19
#define INT_CHAR_NORM_RANGE
Definition: intproto.h:133
float FLOAT32
Definition: host.h:42
#define GetPicoFeatureLength()
Definition: picofeat.h:59
void Pen(Color color)
Definition: scrollview.cpp:726
void DrawTo(int x, int y)
Definition: scrollview.cpp:531

◆ ShowMatchDisplay()

void ShowMatchDisplay ( )

◆ UpdateMatchDisplay()

void UpdateMatchDisplay ( )

This routine clears the global feature and proto display lists.

Globals:

  • FeatureShapes display list for features
  • ProtoShapes display list for protos
    Returns
    none
    Note
    Exceptions: none
    History: Thu Mar 21 15:40:19 1991, DSJ, Created.

Definition at line 467 of file intproto.cpp.

467  {
468  if (IntMatchWindow != NULL)
470 } /* ClearMatchDisplay */
ScrollView * IntMatchWindow
Definition: intproto.cpp:179
static void Update()
Definition: scrollview.cpp:715