Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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   (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   (~(~0 << 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_STRUCT
INT_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)
 
int BucketFor (FLOAT32 Param, FLOAT32 Offset, int NumBuckets)
 
int CircBucketFor (FLOAT32 Param, FLOAT32 Offset, int NumBuckets)
 
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

#define ANGLE_SHIFT   (0.0)

Definition at line 37 of file intproto.h.

#define BITS_PER_CP_VECTOR   (CLASSES_PER_CP * NUM_BITS_PER_CLASS)

Definition at line 56 of file intproto.h.

#define BITS_PER_WERD   (8 * sizeof (uinT32))

Definition at line 42 of file intproto.h.

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

Definition at line 53 of file intproto.h.

#define CLASSES_PER_CP   32

Definition at line 51 of file intproto.h.

#define CLASSES_PER_CP_WERD   (CLASSES_PER_CP / NUM_BITS_PER_CLASS)

Definition at line 54 of file intproto.h.

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

Definition at line 173 of file intproto.h.

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

Definition at line 174 of file intproto.h.

#define CLIP_MATCH_EVIDENCE   0x020

Definition at line 187 of file intproto.h.

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

Definition at line 195 of file intproto.h.

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

Definition at line 178 of file intproto.h.

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

Definition at line 176 of file intproto.h.

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

Definition at line 175 of file intproto.h.

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

Definition at line 179 of file intproto.h.

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

Definition at line 177 of file intproto.h.

#define DISPLAY_FEATURE_MATCHES   0x002

Definition at line 183 of file intproto.h.

#define DISPLAY_PROTO_MATCHES   0x004

Definition at line 184 of file intproto.h.

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

Definition at line 191 of file intproto.h.

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

Definition at line 192 of file intproto.h.

#define IndexForProto (   P)    (P % PROTOS_PER_PROTO_SET)

Definition at line 162 of file intproto.h.

#define INT_CHAR_NORM_RANGE   256

Definition at line 131 of file intproto.h.

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

Definition at line 171 of file intproto.h.

#define MatchDebuggingOn (   D)    (D)

Definition at line 189 of file intproto.h.

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

Definition at line 57 of file intproto.h.

#define MAX_NUM_CONFIGS   64

Definition at line 44 of file intproto.h.

#define MAX_NUM_INT_FEATURES   512

Definition at line 130 of file intproto.h.

#define MAX_NUM_PROTO_SETS   (MAX_NUM_PROTOS / PROTOS_PER_PROTO_SET)

Definition at line 47 of file intproto.h.

#define MAX_NUM_PROTOS   512

Definition at line 45 of file intproto.h.

#define MAX_PROTO_INDEX   24

Definition at line 41 of file intproto.h.

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

Definition at line 170 of file intproto.h.

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

Macros

Definition at line 160 of file intproto.h.

#define NUM_BITS_PER_CLASS   2

Definition at line 52 of file intproto.h.

#define NUM_CP_BUCKETS   24

Definition at line 50 of file intproto.h.

#define NUM_PP_BUCKETS   64

Definition at line 49 of file intproto.h.

#define NUM_PP_PARAMS   3

Definition at line 48 of file intproto.h.

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

Definition at line 167 of file intproto.h.

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

Definition at line 168 of file intproto.h.

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

Definition at line 165 of file intproto.h.

#define PRINT_FEATURE_MATCHES   0x008

Definition at line 185 of file intproto.h.

#define PRINT_MATCH_SUMMARY   0x001

Definition at line 182 of file intproto.h.

#define PRINT_PROTO_MATCHES   0x010

Definition at line 186 of file intproto.h.

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

Definition at line 193 of file intproto.h.

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

Definition at line 190 of file intproto.h.

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

Definition at line 194 of file intproto.h.

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

Definition at line 163 of file intproto.h.

#define PROTOS_PER_PP_WERD   BITS_PER_WERD

Definition at line 55 of file intproto.h.

#define PROTOS_PER_PROTO_SET   64

Definition at line 46 of file intproto.h.

#define PRUNER_ANGLE   2

Definition at line 34 of file intproto.h.

#define PRUNER_X   0

Include Files and Type Defines

Definition at line 32 of file intproto.h.

#define PRUNER_Y   1

Definition at line 33 of file intproto.h.

#define SetForProto (   P)    (P / PROTOS_PER_PROTO_SET)

Definition at line 161 of file intproto.h.

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

Definition at line 172 of file intproto.h.

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

Definition at line 66 of file intproto.h.

#define WERDS_PER_CP
Value:
#define NUM_CP_BUCKETS
Definition: intproto.h:50
#define WERDS_PER_CP_VECTOR
Definition: intproto.h:59

Definition at line 64 of file intproto.h.

#define WERDS_PER_CP_VECTOR   (BITS_PER_CP_VECTOR / BITS_PER_WERD)

Definition at line 59 of file intproto.h.

#define WERDS_PER_PP
Value:
#define WERDS_PER_PP_VECTOR
Definition: intproto.h:60
#define NUM_PP_PARAMS
Definition: intproto.h:48
#define NUM_PP_BUCKETS
Definition: intproto.h:49

Definition at line 62 of file intproto.h.

#define WERDS_PER_PP_VECTOR
Value:
#define BITS_PER_WERD
Definition: intproto.h:42
#define PROTOS_PER_PROTO_SET
Definition: intproto.h:46

Definition at line 60 of file intproto.h.

#define X_SHIFT   (0.5)

Definition at line 38 of file intproto.h.

#define Y_SHIFT   (0.5)

Definition at line 39 of file intproto.h.

Typedef Documentation

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

Definition at line 101 of file intproto.h.

typedef struct INT_CLASS_STRUCT * INT_CLASS

Definition at line 145 of file intproto.h.

typedef INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]

Definition at line 147 of file intproto.h.

typedef struct INT_PROTO_STRUCT * INT_PROTO

Definition at line 90 of file intproto.h.

typedef struct PROTO_SET_STRUCT * PROTO_SET

Enumeration Type Documentation

Enumerator
IDA_ADAPTIVE 
IDA_STATIC 
IDA_SHAPE_INDEX 
IDA_BOTH 

Definition at line 149 of file intproto.h.

149  {
150  IDA_ADAPTIVE,
151  IDA_STATIC,
153  IDA_BOTH
154 };

Function Documentation

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

224  {
225  int Pruner;
226 
227  assert (LegalClassId (ClassId));
228  if (ClassId != Templates->NumClasses) {
229  fprintf(stderr, "Please make sure that classes are added to templates");
230  fprintf(stderr, " in increasing order of ClassIds\n");
231  exit(1);
232  }
233  ClassForClassId (Templates, ClassId) = Class;
234  Templates->NumClasses++;
235 
236  if (Templates->NumClasses > MaxNumClassesIn (Templates)) {
237  Pruner = Templates->NumClassPruners++;
238  Templates->ClassPruners[Pruner] = new CLASS_PRUNER_STRUCT;
239  memset(Templates->ClassPruners[Pruner], 0, sizeof(CLASS_PRUNER_STRUCT));
240  }
241 } /* AddIntClass */
#define ClassForClassId(T, c)
Definition: intproto.h:173
#define MaxNumClassesIn(T)
Definition: intproto.h:170
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
Definition: intproto.h:123
#define LegalClassId(c)
Definition: intproto.h:171
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 257 of file intproto.cpp.

257  {
258  int Index;
259 
260  assert(Class->NumConfigs < MAX_NUM_CONFIGS);
261 
262  Index = Class->NumConfigs++;
263  Class->ConfigLengths[Index] = 0;
264  return Index;
265 } /* AddIntConfig */
#define MAX_NUM_CONFIGS
Definition: intproto.h:44
uinT8 NumConfigs
Definition: intproto.h:108
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
Definition: intproto.h:111
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 281 of file intproto.cpp.

281  {
282  int Index;
283  int ProtoSetId;
284  PROTO_SET ProtoSet;
285  INT_PROTO Proto;
286  register uinT32 *Word;
287 
288  if (Class->NumProtos >= MAX_NUM_PROTOS)
289  return (NO_PROTO);
290 
291  Index = Class->NumProtos++;
292 
293  if (Class->NumProtos > MaxNumIntProtosIn(Class)) {
294  ProtoSetId = Class->NumProtoSets++;
295 
296  ProtoSet = (PROTO_SET) Emalloc(sizeof(PROTO_SET_STRUCT));
297  Class->ProtoSets[ProtoSetId] = ProtoSet;
298  memset(ProtoSet, 0, sizeof(*ProtoSet));
299 
300  /* reallocate space for the proto lengths and install in class */
301  Class->ProtoLengths =
302  (uinT8 *)Erealloc(Class->ProtoLengths,
303  MaxNumIntProtosIn(Class) * sizeof(uinT8));
304  memset(&Class->ProtoLengths[Index], 0,
305  sizeof(*Class->ProtoLengths) * (MaxNumIntProtosIn(Class) - Index));
306  }
307 
308  /* initialize proto so its length is zero and it isn't in any configs */
309  Class->ProtoLengths[Index] = 0;
310  Proto = ProtoForProtoId (Class, Index);
311  for (Word = Proto->Configs;
312  Word < Proto->Configs + WERDS_PER_CONFIG_VEC; *Word++ = 0);
313 
314  return (Index);
315 
316 } /* AddIntProto */
uinT32 Configs[WERDS_PER_CONFIG_VEC]
Definition: intproto.h:84
void * Erealloc(void *ptr, size_t size)
Definition: emalloc.cpp:70
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
Definition: intproto.h:109
#define MAX_NUM_PROTOS
Definition: intproto.h:45
struct PROTO_SET_STRUCT * PROTO_SET
uinT8 * ProtoLengths
Definition: intproto.h:110
void * Emalloc(size_t Size)
Definition: emalloc.cpp:35
#define NO_PROTO
Definition: matchdefs.h:42
#define MaxNumIntProtosIn(C)
Definition: intproto.h:160
unsigned char uinT8
Definition: host.h:99
uinT16 NumProtos
Definition: intproto.h:106
unsigned int uinT32
Definition: host.h:103
#define WERDS_PER_CONFIG_VEC
Definition: intproto.h:66
uinT8 NumProtoSets
Definition: intproto.h:107
#define ProtoForProtoId(C, P)
Definition: intproto.h:163
void AddProtoToClassPruner ( PROTO  Proto,
CLASS_ID  ClassId,
INT_TEMPLATES  Templates 
)

Definition at line 320 of file intproto.cpp.

336 {
337  CLASS_PRUNER_STRUCT* Pruner;
338  uinT32 ClassMask;
339  uinT32 ClassCount;
340  uinT32 WordIndex;
341  int Level;
342  FLOAT32 EndPad, SidePad, AnglePad;
343  TABLE_FILLER TableFiller;
344  FILL_SPEC FillSpec;
345 
346  Pruner = CPrunerFor (Templates, ClassId);
347  WordIndex = CPrunerWordIndexFor (ClassId);
348  ClassMask = CPrunerMaskFor (MAX_LEVEL, ClassId);
349 
350  for (Level = classify_num_cp_levels - 1; Level >= 0; Level--) {
351  GetCPPadsForLevel(Level, &EndPad, &SidePad, &AnglePad);
352  ClassCount = CPrunerMaskFor (Level, ClassId);
353  InitTableFiller(EndPad, SidePad, AnglePad, Proto, &TableFiller);
354 
355  while (!FillerDone (&TableFiller)) {
356  GetNextFill(&TableFiller, &FillSpec);
357  DoFill(&FillSpec, Pruner, ClassMask, ClassCount, WordIndex);
358  }
359  }
360 } /* AddProtoToClassPruner */
void InitTableFiller(FLOAT32 EndPad, FLOAT32 SidePad, FLOAT32 AnglePad, PROTO Proto, TABLE_FILLER *Filler)
Definition: intproto.cpp:1654
#define CPrunerFor(T, c)
Definition: intproto.h:176
int classify_num_cp_levels
Definition: intproto.cpp:189
BOOL8 FillerDone(TABLE_FILLER *Filler)
Definition: intproto.cpp:1324
float FLOAT32
Definition: host.h:111
#define CPrunerWordIndexFor(c)
Definition: intproto.h:177
void GetNextFill(TABLE_FILLER *Filler, FILL_SPEC *Fill)
Definition: intproto.cpp:1586
#define MAX_LEVEL
#define CPrunerMaskFor(L, c)
Definition: intproto.h:179
void DoFill(FILL_SPEC *FillSpec, CLASS_PRUNER_STRUCT *Pruner, register uinT32 ClassMask, register uinT32 ClassCount, register uinT32 WordIndex)
Definition: intproto.cpp:1274
unsigned int uinT32
Definition: host.h:103
void GetCPPadsForLevel(int Level, FLOAT32 *EndPad, FLOAT32 *SidePad, FLOAT32 *AnglePad)
Definition: intproto.cpp:1508
void AddProtoToProtoPruner ( PROTO  Proto,
int  ProtoId,
INT_CLASS  Class,
bool  debug 
)

Definition at line 364 of file intproto.cpp.

365  {
366 /*
367  ** Parameters:
368  ** Proto floating-pt proto to be added to proto pruner
369  ** ProtoId id of proto
370  ** Class integer class that contains desired proto pruner
371  ** Globals: none
372  ** Operation: This routine updates the proto pruner lookup tables
373  ** for Class to include a new proto identified by ProtoId
374  ** and described by Proto.
375  ** Return: none
376  ** Exceptions: none
377  ** History: Fri Feb 8 13:07:19 1991, DSJ, Created.
378  */
379  FLOAT32 Angle, X, Y, Length;
380  FLOAT32 Pad;
381  int Index;
382  PROTO_SET ProtoSet;
383 
384  if (ProtoId >= Class->NumProtos)
385  cprintf("AddProtoToProtoPruner:assert failed: %d < %d",
386  ProtoId, Class->NumProtos);
387  assert(ProtoId < Class->NumProtos);
388 
389  Index = IndexForProto (ProtoId);
390  ProtoSet = Class->ProtoSets[SetForProto (ProtoId)];
391 
392  Angle = Proto->Angle;
393 #ifndef _WIN32
394  assert(!isnan(Angle));
395 #endif
396 
397  FillPPCircularBits (ProtoSet->ProtoPruner[PRUNER_ANGLE], Index,
398  Angle + ANGLE_SHIFT, classify_pp_angle_pad / 360.0,
399  debug);
400 
401  Angle *= 2.0 * PI;
402  Length = Proto->Length;
403 
404  X = Proto->X + X_SHIFT;
405  Pad = MAX (fabs (cos (Angle)) * (Length / 2.0 +
408  fabs (sin (Angle)) * (classify_pp_side_pad *
410 
411  FillPPLinearBits(ProtoSet->ProtoPruner[PRUNER_X], Index, X, Pad, debug);
412 
413  Y = Proto->Y + Y_SHIFT;
414  Pad = MAX (fabs (sin (Angle)) * (Length / 2.0 +
417  fabs (cos (Angle)) * (classify_pp_side_pad *
419 
420  FillPPLinearBits(ProtoSet->ProtoPruner[PRUNER_Y], Index, Y, Pad, debug);
421 } /* AddProtoToProtoPruner */
void FillPPCircularBits(uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, FLOAT32 Center, FLOAT32 Spread, bool debug)
Definition: intproto.cpp:1348
#define PRUNER_Y
Definition: intproto.h:33
FLOAT32 Length
Definition: protos.h:50
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
Definition: intproto.h:109
FLOAT32 Y
Definition: protos.h:48
double classify_pp_side_pad
Definition: intproto.cpp:204
#define PI
Definition: const.h:19
#define PRUNER_ANGLE
Definition: intproto.h:34
double classify_pp_end_pad
Definition: intproto.cpp:203
float FLOAT32
Definition: host.h:111
#define X_SHIFT
Definition: intproto.h:38
#define ANGLE_SHIFT
Definition: intproto.h:37
FLOAT32 Angle
Definition: protos.h:49
#define PRUNER_X
Definition: intproto.h:32
void FillPPLinearBits(uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, FLOAT32 Center, FLOAT32 Spread, bool debug)
Definition: intproto.cpp:1392
#define SetForProto(P)
Definition: intproto.h:161
double classify_pp_angle_pad
Definition: intproto.cpp:202
#define Y_SHIFT
Definition: intproto.h:39
FLOAT32 X
Definition: protos.h:47
uinT16 NumProtos
Definition: intproto.h:106
PROTO_PRUNER ProtoPruner
Definition: intproto.h:94
#define GetPicoFeatureLength()
Definition: picofeat.h:59
#define MAX(x, y)
Definition: ndminx.h:24
void cprintf(const char *format,...)
Definition: callcpp.cpp:41
#define IndexForProto(P)
Definition: intproto.h:162
int BucketFor ( FLOAT32  Param,
FLOAT32  Offset,
int  NumBuckets 
)

Definition at line 425 of file intproto.cpp.

425  {
426 /*
427  ** Parameters:
428  ** Param parameter value to map into a bucket number
429  ** Offset amount to shift param before mapping it
430  ** NumBuckets number of buckets to map param into
431  ** Globals: none
432  ** Operation: This routine maps a parameter value into a bucket between
433  ** 0 and NumBuckets-1. Offset is added to the parameter
434  ** before mapping it. Values which map to buckets outside
435  ** the range are truncated to fit within the range. Mapping
436  ** is done by truncating rather than rounding.
437  ** Return: Bucket number corresponding to Param + Offset.
438  ** Exceptions: none
439  ** History: Thu Feb 14 13:24:33 1991, DSJ, Created.
440  */
441  return ClipToRange(static_cast<int>(MapParam(Param, Offset, NumBuckets)),
442  0, NumBuckets - 1);
443 } /* BucketFor */
#define MapParam(P, O, N)
Definition: intproto.cpp:124
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:64
int CircBucketFor ( FLOAT32  Param,
FLOAT32  Offset,
int  NumBuckets 
)

Definition at line 447 of file intproto.cpp.

447  {
448 /*
449  ** Parameters:
450  ** Param parameter value to map into a circular bucket
451  ** Offset amount to shift param before mapping it
452  ** NumBuckets number of buckets to map param into
453  ** Globals: none
454  ** Operation: This routine maps a parameter value into a bucket between
455  ** 0 and NumBuckets-1. Offset is added to the parameter
456  ** before mapping it. Values which map to buckets outside
457  ** the range are wrapped to a new value in a circular fashion.
458  ** Mapping is done by truncating rather than rounding.
459  ** Return: Bucket number corresponding to Param + Offset.
460  ** Exceptions: none
461  ** History: Thu Feb 14 13:24:33 1991, DSJ, Created.
462  */
463  int Bucket;
464 
465  Bucket = static_cast<int>(MapParam(Param, Offset, NumBuckets));
466  if (Bucket < 0)
467  Bucket += NumBuckets;
468  else if (Bucket >= NumBuckets)
469  Bucket -= NumBuckets;
470  return Bucket;
471 } /* CircBucketFor */
#define MapParam(P, O, N)
Definition: intproto.cpp:124
void ConvertConfig ( BIT_VECTOR  Config,
int  ConfigId,
INT_CLASS  Class 
)

Definition at line 494 of file intproto.cpp.

494  {
495 /*
496  ** Parameters:
497  ** Config config to be added to class
498  ** ConfigId id to be used for new config
499  ** Class class to add new config to
500  ** Globals: none
501  ** Operation: This operation updates the config vectors of all protos
502  ** in Class to indicate that the protos with 1's in Config
503  ** belong to a new configuration identified by ConfigId.
504  ** It is assumed that the length of the Config bit vector is
505  ** equal to the number of protos in Class.
506  ** Return: none
507  ** Exceptions: none
508  ** History: Mon Feb 11 14:57:31 1991, DSJ, Created.
509  */
510  int ProtoId;
511  INT_PROTO Proto;
512  int TotalLength;
513 
514  for (ProtoId = 0, TotalLength = 0;
515  ProtoId < Class->NumProtos; ProtoId++) {
516  if (test_bit(Config, ProtoId)) {
517  Proto = ProtoForProtoId(Class, ProtoId);
518  SET_BIT(Proto->Configs, ConfigId);
519  TotalLength += Class->ProtoLengths[ProtoId];
520  }
521  }
522  Class->ConfigLengths[ConfigId] = TotalLength;
523 } /* ConvertConfig */
uinT32 Configs[WERDS_PER_CONFIG_VEC]
Definition: intproto.h:84
uinT8 * ProtoLengths
Definition: intproto.h:110
#define test_bit(array, bit)
Definition: bitvec.h:61
CLUSTERCONFIG Config
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
Definition: intproto.h:111
uinT16 NumProtos
Definition: intproto.h:106
#define SET_BIT(array, bit)
Definition: bitvec.h:57
#define ProtoForProtoId(C, P)
Definition: intproto.h:163
ScrollView* CreateFeatureSpaceWindow ( const char *  name,
int  xpos,
int  ypos 
)

Definition at line 1990 of file intproto.cpp.

1990  {
1991  return new ScrollView(name, xpos, ypos, 520, 520, 260, 260, true);
1992 }
void DisplayIntFeature ( const INT_FEATURE_STRUCT Feature,
FLOAT32  Evidence 
)

Definition at line 638 of file intproto.cpp.

638  {
639 /*
640  ** Parameters:
641  ** Feature pico-feature to be displayed
642  ** Evidence best evidence for this feature (0-1)
643  ** Globals:
644  ** FeatureShapes global display list for features
645  ** Operation: This routine renders the specified feature into a
646  ** global display list.
647  ** Return: none
648  ** Exceptions: none
649  ** History: Thu Mar 21 14:45:04 1991, DSJ, Created.
650  */
651  ScrollView::Color color = GetMatchColorFor(Evidence);
652  RenderIntFeature(IntMatchWindow, Feature, color);
653  if (FeatureDisplayWindow) {
654  RenderIntFeature(FeatureDisplayWindow, Feature, color);
655  }
656 } /* DisplayIntFeature */
ScrollView * FeatureDisplayWindow
Definition: intproto.cpp:181
ScrollView * IntMatchWindow
Definition: intproto.cpp:180
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
Definition: intproto.cpp:1822
ScrollView::Color GetMatchColorFor(FLOAT32 Evidence)
Definition: intproto.cpp:1560
void DisplayIntProto ( INT_CLASS  Class,
PROTO_ID  ProtoId,
FLOAT32  Evidence 
)

Definition at line 660 of file intproto.cpp.

660  {
661 /*
662  ** Parameters:
663  ** Class class to take proto from
664  ** ProtoId id of proto in Class to be displayed
665  ** Evidence total evidence for proto (0-1)
666  ** Globals:
667  ** ProtoShapes global display list for protos
668  ** Operation: This routine renders the specified proto into a
669  ** global display list.
670  ** Return: none
671  ** Exceptions: none
672  ** History: Thu Mar 21 14:45:04 1991, DSJ, Created.
673  */
674  ScrollView::Color color = GetMatchColorFor(Evidence);
675  RenderIntProto(IntMatchWindow, Class, ProtoId, color);
676  if (ProtoDisplayWindow) {
677  RenderIntProto(ProtoDisplayWindow, Class, ProtoId, color);
678  }
679 } /* DisplayIntProto */
void RenderIntProto(ScrollView *window, INT_CLASS Class, PROTO_ID ProtoId, ScrollView::Color color)
Definition: intproto.cpp:1859
ScrollView * IntMatchWindow
Definition: intproto.cpp:180
ScrollView * ProtoDisplayWindow
Definition: intproto.cpp:182
ScrollView::Color GetMatchColorFor(FLOAT32 Evidence)
Definition: intproto.cpp:1560
void free_int_templates ( INT_TEMPLATES  templates)

Definition at line 774 of file intproto.cpp.

774  {
775  int i;
776 
777  for (i = 0; i < templates->NumClasses; i++)
778  free_int_class(templates->Class[i]);
779  for (i = 0; i < templates->NumClassPruners; i++)
780  delete templates->ClassPruners[i];
781  Efree(templates);
782 }
void Efree(void *ptr)
Definition: emalloc.cpp:85
void free_int_class(INT_CLASS int_class)
Definition: intproto.cpp:735
INT_CLASS Class[MAX_NUM_CLASSES]
Definition: intproto.h:122
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
Definition: intproto.h:123
void InitFeatureDisplayWindowIfReqd ( )

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

Definition at line 1981 of file intproto.cpp.

1981  {
1982  if (FeatureDisplayWindow == NULL) {
1983  FeatureDisplayWindow = CreateFeatureSpaceWindow("FeatureDisplayWindow",
1984  50, 700);
1985  }
1986 }
#define NULL
Definition: host.h:144
ScrollView * FeatureDisplayWindow
Definition: intproto.cpp:181
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
Definition: intproto.cpp:1990
void InitIntMatchWindowIfReqd ( )

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

Definition at line 1949 of file intproto.cpp.

1949  {
1950  if (IntMatchWindow == NULL) {
1951  IntMatchWindow = CreateFeatureSpaceWindow("IntMatchWindow", 50, 200);
1952  SVMenuNode* popup_menu = new SVMenuNode();
1953 
1954  popup_menu->AddChild("Debug Adapted classes", IDA_ADAPTIVE,
1955  "x", "Class to debug");
1956  popup_menu->AddChild("Debug Static classes", IDA_STATIC,
1957  "x", "Class to debug");
1958  popup_menu->AddChild("Debug Both", IDA_BOTH,
1959  "x", "Class to debug");
1960  popup_menu->AddChild("Debug Shape Index", IDA_SHAPE_INDEX,
1961  "0", "Index to debug");
1962  popup_menu->BuildMenu(IntMatchWindow, false);
1963  }
1964 }
void BuildMenu(ScrollView *sv, bool menu_bar=true)
Definition: svmnode.cpp:132
SVMenuNode * AddChild(const char *txt)
Definition: svmnode.cpp:64
#define NULL
Definition: host.h:144
ScrollView * IntMatchWindow
Definition: intproto.cpp:180
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
Definition: intproto.cpp:1990
void InitProtoDisplayWindowIfReqd ( )

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

Definition at line 1970 of file intproto.cpp.

1970  {
1971  if (ProtoDisplayWindow == NULL) {
1972  ProtoDisplayWindow = CreateFeatureSpaceWindow("ProtoDisplayWindow",
1973  550, 200);
1974  }
1975 }
#define NULL
Definition: host.h:144
ScrollView * ProtoDisplayWindow
Definition: intproto.cpp:182
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
Definition: intproto.cpp:1990
INT_CLASS NewIntClass ( int  MaxNumProtos,
int  MaxNumConfigs 
)

Definition at line 683 of file intproto.cpp.

683  {
684 /*
685  ** Parameters:
686  ** MaxNumProtos number of protos to allocate space for
687  ** MaxNumConfigs number of configs to allocate space for
688  ** Globals: none
689  ** Operation: This routine creates a new integer class data structure
690  ** and returns it. Sufficient space is allocated
691  ** to handle the specified number of protos and configs.
692  ** Return: New class created.
693  ** Exceptions: none
694  ** History: Fri Feb 8 10:51:23 1991, DSJ, Created.
695  */
696  INT_CLASS Class;
697  PROTO_SET ProtoSet;
698  int i;
699 
700  assert(MaxNumConfigs <= MAX_NUM_CONFIGS);
701 
702  Class = (INT_CLASS) Emalloc(sizeof(INT_CLASS_STRUCT));
703  Class->NumProtoSets = ((MaxNumProtos + PROTOS_PER_PROTO_SET - 1) /
705 
706  assert(Class->NumProtoSets <= MAX_NUM_PROTO_SETS);
707 
708  Class->NumProtos = 0;
709  Class->NumConfigs = 0;
710 
711  for (i = 0; i < Class->NumProtoSets; i++) {
712  /* allocate space for a proto set, install in class, and initialize */
713  ProtoSet = (PROTO_SET) Emalloc(sizeof(PROTO_SET_STRUCT));
714  memset(ProtoSet, 0, sizeof(*ProtoSet));
715  Class->ProtoSets[i] = ProtoSet;
716 
717  /* allocate space for the proto lengths and install in class */
718  }
719  if (MaxNumIntProtosIn (Class) > 0) {
720  Class->ProtoLengths =
721  (uinT8 *)Emalloc(MaxNumIntProtosIn (Class) * sizeof (uinT8));
722  memset(Class->ProtoLengths, 0,
723  MaxNumIntProtosIn(Class) * sizeof(*Class->ProtoLengths));
724  } else {
725  Class->ProtoLengths = NULL;
726  }
727  memset(Class->ConfigLengths, 0, sizeof(Class->ConfigLengths));
728 
729  return (Class);
730 
731 } /* NewIntClass */
#define MAX_NUM_CONFIGS
Definition: intproto.h:44
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
Definition: intproto.h:109
uinT8 NumConfigs
Definition: intproto.h:108
#define NULL
Definition: host.h:144
struct PROTO_SET_STRUCT * PROTO_SET
uinT8 * ProtoLengths
Definition: intproto.h:110
struct INT_CLASS_STRUCT * INT_CLASS
#define PROTOS_PER_PROTO_SET
Definition: intproto.h:46
void * Emalloc(size_t Size)
Definition: emalloc.cpp:35
#define MaxNumIntProtosIn(C)
Definition: intproto.h:160
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
Definition: intproto.h:111
unsigned char uinT8
Definition: host.h:99
uinT16 NumProtos
Definition: intproto.h:106
uinT8 NumProtoSets
Definition: intproto.h:107
#define MAX_NUM_PROTO_SETS
Definition: intproto.h:47
INT_TEMPLATES NewIntTemplates ( )

Definition at line 749 of file intproto.cpp.

749  {
750 /*
751  ** Parameters: none
752  ** Globals: none
753  ** Operation: This routine allocates a new set of integer templates
754  ** initialized to hold 0 classes.
755  ** Return: The integer templates created.
756  ** Exceptions: none
757  ** History: Fri Feb 8 08:38:51 1991, DSJ, Created.
758  */
759  INT_TEMPLATES T;
760  int i;
761 
762  T = (INT_TEMPLATES) Emalloc (sizeof (INT_TEMPLATES_STRUCT));
763  T->NumClasses = 0;
764  T->NumClassPruners = 0;
765 
766  for (i = 0; i < MAX_NUM_CLASSES; i++)
767  ClassForClassId (T, i) = NULL;
768 
769  return (T);
770 } /* NewIntTemplates */
#define ClassForClassId(T, c)
Definition: intproto.h:173
#define NULL
Definition: host.h:144
struct INT_TEMPLATES_STRUCT * INT_TEMPLATES
#define MAX_NUM_CLASSES
Definition: matchdefs.h:31
void * Emalloc(size_t Size)
Definition: emalloc.cpp:35
void RenderIntFeature ( ScrollView window,
const INT_FEATURE_STRUCT Feature,
ScrollView::Color  color 
)

Definition at line 1822 of file intproto.cpp.

1823  {
1824  FLOAT32 X, Y, Dx, Dy, Length;
1825 
1826  window->Pen(color);
1827  assert(Feature != NULL);
1828  assert(color != 0);
1829 
1830  X = Feature->X;
1831  Y = Feature->Y;
1832  Length = GetPicoFeatureLength() * 0.7 * INT_CHAR_NORM_RANGE;
1833  // The -PI has no significant effect here, but the value of Theta is computed
1834  // using BinaryAnglePlusPi in intfx.cpp.
1835  Dx = (Length / 2.0) * cos((Feature->Theta / 256.0) * 2.0 * PI - PI);
1836  Dy = (Length / 2.0) * sin((Feature->Theta / 256.0) * 2.0 * PI - PI);
1837 
1838  window->SetCursor(X, Y);
1839  window->DrawTo(X + Dx, Y + Dy);
1840 } /* RenderIntFeature */
#define INT_CHAR_NORM_RANGE
Definition: intproto.h:131
void SetCursor(int x, int y)
Definition: scrollview.cpp:520
void Pen(Color color)
Definition: scrollview.cpp:721
#define NULL
Definition: host.h:144
#define PI
Definition: const.h:19
float FLOAT32
Definition: host.h:111
void DrawTo(int x, int y)
Definition: scrollview.cpp:526
#define GetPicoFeatureLength()
Definition: picofeat.h:59
void ShowMatchDisplay ( )
void UpdateMatchDisplay ( )

Definition at line 476 of file intproto.cpp.

476  {
477 /*
478  ** Parameters: none
479  ** Globals:
480  ** FeatureShapes display list for features
481  ** ProtoShapes display list for protos
482  ** Operation: This routine clears the global feature and proto
483  ** display lists.
484  ** Return: none
485  ** Exceptions: none
486  ** History: Thu Mar 21 15:40:19 1991, DSJ, Created.
487  */
488  if (IntMatchWindow != NULL)
490 } /* ClearMatchDisplay */
#define NULL
Definition: host.h:144
static void Update()
Definition: scrollview.cpp:710
ScrollView * IntMatchWindow
Definition: intproto.cpp:180