#include <cstdio>
#include "intproto.h"
#include "oldlist.h"
Go to the source code of this file.
◆ ConfigIsPermanent
#define ConfigIsPermanent |
( |
|
Class, |
|
|
|
ConfigId |
|
) |
| (test_bit((Class)->PermConfigs, ConfigId)) |
◆ IncreaseConfidence
#define IncreaseConfidence |
( |
|
TempConfig | ) |
((TempConfig)->NumTimesSeen++) |
◆ IsEmptyAdaptedClass
#define IsEmptyAdaptedClass |
( |
|
Class | ) |
((Class)->NumPermConfigs == 0 && (Class)->TempProtos == NIL_LIST) |
◆ MakeConfigPermanent
#define MakeConfigPermanent |
( |
|
Class, |
|
|
|
ConfigId |
|
) |
| (SET_BIT((Class)->PermConfigs, ConfigId)) |
◆ MakeProtoPermanent
#define MakeProtoPermanent |
( |
|
Class, |
|
|
|
ProtoId |
|
) |
| (SET_BIT((Class)->PermProtos, ProtoId)) |
◆ NumNonEmptyClassesIn
#define NumNonEmptyClassesIn |
( |
|
Template | ) |
((Template)->NumNonEmptyClasses) |
◆ PermConfigFor
#define PermConfigFor |
( |
|
Class, |
|
|
|
ConfigId |
|
) |
| ((Class)->Config[ConfigId].Perm) |
◆ TempConfigFor
#define TempConfigFor |
( |
|
Class, |
|
|
|
ConfigId |
|
) |
| ((Class)->Config[ConfigId].Temp) |
◆ ADAPT_CLASS
◆ ADAPT_TEMPLATES
◆ PERM_CONFIG
◆ TEMP_CONFIG
◆ TEMP_PROTO
◆ AddAdaptedClass()
This routine adds a new adapted class to an existing set of adapted templates.
- Parameters
-
Templates | set of templates to add new class to |
Class | new class to add to templates |
ClassId | class id to associate with new class |
- Note
- Globals: none
Definition at line 45 of file adaptive.cpp.
50 assert (Templates !=
nullptr);
51 assert (Class !=
nullptr);
59 assert (Templates->
Class[ClassId] ==
nullptr);
60 Templates->
Class[ClassId] = Class;
◆ free_adapted_class()
◆ free_adapted_templates()
Definition at line 182 of file adaptive.cpp.
184 if (templates !=
nullptr) {
185 for (
int i = 0; i < (templates->
Templates)->NumClasses; i++)
◆ FreeTempConfig()
This routine frees all memory consumed by a temporary configuration.
- Parameters
-
- Note
- Globals: none
Definition at line 74 of file adaptive.cpp.
75 assert (
Config !=
nullptr);
76 FreeBitVector (
Config->Protos);
◆ FreeTempProto()
void FreeTempProto |
( |
void * |
arg | ) |
|
Definition at line 81 of file adaptive.cpp.
82 auto proto = static_cast<PROTO>(arg);
◆ NewAdaptedClass()
This operation allocates and initializes a new adapted class data structure and returns a ptr to it.
- Returns
- Ptr to new class data structure.
- Note
- Globals: none
Definition at line 102 of file adaptive.cpp.
◆ NewTempConfig()
TEMP_CONFIG NewTempConfig |
( |
int |
MaxProtoId, |
|
|
int |
FontinfoId |
|
) |
| |
This routine allocates and returns a new temporary config.
- Parameters
-
MaxProtoId | max id of any proto in new config |
FontinfoId | font information from pre-trained templates |
- Returns
- Ptr to new temp config.
- Note
- Globals: none
Definition at line 203 of file adaptive.cpp.
204 int NumProtos = MaxProtoId + 1;
207 Config->Protos = NewBitVector (NumProtos);
210 Config->MaxProtoId = MaxProtoId;
211 Config->ProtoVectorSize = WordsInVectorOfSize (NumProtos);
212 zero_all_bits (
Config->Protos,
Config->ProtoVectorSize);
213 Config->FontinfoId = FontinfoId;
◆ NewTempProto()
This routine allocates and returns a new temporary proto.
- Returns
- Ptr to new temporary proto.
- Note
- Globals: none
Definition at line 228 of file adaptive.cpp.
◆ ReadAdaptedClass()
Read an adapted class description from file and return a ptr to the adapted class.
- Parameters
-
fp | open file to read adapted class from |
- Returns
- Ptr to new adapted class.
- Note
- Globals: none
Definition at line 281 of file adaptive.cpp.
300 fp->
FRead(&NumTempProtos,
sizeof(
int), 1);
302 for (i = 0; i < NumTempProtos; i++) {
309 fp->
FRead(&NumConfigs,
sizeof(
int), 1);
310 for (i = 0; i < NumConfigs; i++)
◆ ReadPermConfig()
Read a permanent configuration description from file and return a ptr to it.
- Parameters
-
fp | open file to read permanent config from |
- Returns
- Ptr to new permanent configuration description.
- Note
- Globals: none
Definition at line 362 of file adaptive.cpp.
365 fp->
FRead(&NumAmbigs,
sizeof(NumAmbigs), 1);
368 Config->Ambigs[NumAmbigs] = -1;
◆ ReadTempConfig()
Read a temporary configuration description from file and return a ptr to it.
- Parameters
-
fp | open file to read temporary config from |
- Returns
- Ptr to new temporary configuration description.
- Note
- Globals: none
Definition at line 386 of file adaptive.cpp.
◆ WriteAdaptedClass()
void WriteAdaptedClass |
( |
FILE * |
File, |
|
|
ADAPT_CLASS |
Class, |
|
|
int |
NumConfigs |
|
) |
| |
This routine writes a binary representation of Class to File.
- Parameters
-
File | open file to write Class to |
Class | adapted class to write to File |
NumConfigs | number of configs in Class |
- Note
- Globals: none
Definition at line 409 of file adaptive.cpp.
425 fwrite(&NumTempProtos,
sizeof(
int), 1, File);
433 fwrite(&NumConfigs,
sizeof(
int), 1, File);
434 for (i = 0; i < NumConfigs; i++)
◆ WritePermConfig()
void WritePermConfig |
( |
FILE * |
File, |
|
|
PERM_CONFIG |
Config |
|
) |
| |
This routine writes a binary representation of a permanent configuration to File.
- Parameters
-
File | open file to write Config to |
Config | permanent config to write to File |
- Note
- Globals: none
Definition at line 481 of file adaptive.cpp.
482 uint8_t NumAmbigs = 0;
484 assert (
Config !=
nullptr);
485 while (
Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs;
487 fwrite(&NumAmbigs,
sizeof(uint8_t), 1, File);
489 fwrite(&(
Config->FontinfoId),
sizeof(
int), 1, File);
◆ WriteTempConfig()
void WriteTempConfig |
( |
FILE * |
File, |
|
|
TEMP_CONFIG |
Config |
|
) |
| |
This routine writes a binary representation of a temporary configuration to File.
- Parameters
-
File | open file to write Config to |
Config | temporary config to write to File |
- Note
- Globals: none
Definition at line 503 of file adaptive.cpp.
504 assert (
Config !=
nullptr);
507 fwrite(
Config->Protos, sizeof (uint32_t),
Config->ProtoVectorSize, File);