2007-03-08 04:03:40 +08:00
|
|
|
/* -*-C-*-
|
|
|
|
********************************************************************************
|
|
|
|
*
|
|
|
|
* File: protos.c (Formerly protos.c)
|
|
|
|
* Description:
|
|
|
|
* Author: Mark Seaman, OCR Technology
|
|
|
|
* Created: Fri Oct 16 14:37:00 1987
|
|
|
|
* Modified: Mon Mar 4 14:51:24 1991 (Dan Johnson) danj@hpgrlj
|
|
|
|
* Language: C
|
|
|
|
* Package: N/A
|
|
|
|
* Status: Reusable Software Component
|
|
|
|
*
|
|
|
|
* (c) Copyright 1987, Hewlett-Packard Company.
|
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
*
|
|
|
|
*********************************************************************************/
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
I n c l u d e s
|
|
|
|
----------------------------------------------------------------------*/
|
|
|
|
#include "protos.h"
|
|
|
|
#include "const.h"
|
|
|
|
#include "emalloc.h"
|
|
|
|
#include "freelist.h"
|
|
|
|
#include "callcpp.h"
|
2008-02-01 08:21:49 +08:00
|
|
|
#include "tprintf.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
#include "adaptmatch.h"
|
|
|
|
#include "scanutils.h"
|
2007-07-18 09:15:07 +08:00
|
|
|
#include "globals.h"
|
2009-07-11 10:17:36 +08:00
|
|
|
#include "classify.h"
|
|
|
|
#include "varable.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#define PROTO_INCREMENT 32
|
|
|
|
#define CONFIG_INCREMENT 16
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
V a r i a b l e s
|
|
|
|
----------------------------------------------------------------------*/
|
|
|
|
CLASS_STRUCT TrainingData[NUMBER_OF_CLASSES];
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
STRING_VAR(classify_training_file, "MicroFeatures", "Training file");
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
F u n c t i o n s
|
|
|
|
----------------------------------------------------------------------*/
|
|
|
|
/**********************************************************************
|
|
|
|
* AddConfigToClass
|
|
|
|
*
|
|
|
|
* Add a new config to this class. Malloc new space and copy the
|
|
|
|
* old configs if necessary. Return the config id for the new config.
|
|
|
|
**********************************************************************/
|
|
|
|
int AddConfigToClass(CLASS_TYPE Class) {
|
|
|
|
int NewNumConfigs;
|
|
|
|
int NewConfig;
|
|
|
|
int MaxNumProtos;
|
|
|
|
BIT_VECTOR Config;
|
|
|
|
|
|
|
|
MaxNumProtos = Class->MaxNumProtos;
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
if (Class->NumConfigs >= Class->MaxNumConfigs) {
|
2007-03-08 04:03:40 +08:00
|
|
|
/* add configs in CONFIG_INCREMENT chunks at a time */
|
|
|
|
NewNumConfigs = (((Class->MaxNumConfigs + CONFIG_INCREMENT) /
|
|
|
|
CONFIG_INCREMENT) * CONFIG_INCREMENT);
|
|
|
|
|
|
|
|
Class->Configurations =
|
|
|
|
(CONFIGS) Erealloc (Class->Configurations,
|
|
|
|
sizeof (BIT_VECTOR) * NewNumConfigs);
|
|
|
|
|
|
|
|
Class->MaxNumConfigs = NewNumConfigs;
|
|
|
|
}
|
2009-07-11 10:17:36 +08:00
|
|
|
NewConfig = Class->NumConfigs++;
|
2007-03-08 04:03:40 +08:00
|
|
|
Config = NewBitVector (MaxNumProtos);
|
2009-03-11 03:03:06 +08:00
|
|
|
Class->Configurations[NewConfig] = Config;
|
2007-03-08 04:03:40 +08:00
|
|
|
zero_all_bits (Config, WordsInVectorOfSize (MaxNumProtos));
|
|
|
|
|
|
|
|
return (NewConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* AddProtoToClass
|
|
|
|
*
|
|
|
|
* Add a new proto to this class. Malloc new space and copy the
|
|
|
|
* old protos if necessary. Return the proto id for the new proto.
|
|
|
|
**********************************************************************/
|
|
|
|
int AddProtoToClass(CLASS_TYPE Class) {
|
|
|
|
int i;
|
|
|
|
int Bit;
|
|
|
|
int NewNumProtos;
|
|
|
|
int NewProto;
|
|
|
|
BIT_VECTOR Config;
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
if (Class->NumProtos >= Class->MaxNumProtos) {
|
2007-03-08 04:03:40 +08:00
|
|
|
/* add protos in PROTO_INCREMENT chunks at a time */
|
|
|
|
NewNumProtos = (((Class->MaxNumProtos + PROTO_INCREMENT) /
|
|
|
|
PROTO_INCREMENT) * PROTO_INCREMENT);
|
|
|
|
|
|
|
|
Class->Prototypes = (PROTO) Erealloc (Class->Prototypes,
|
|
|
|
sizeof (PROTO_STRUCT) *
|
|
|
|
NewNumProtos);
|
|
|
|
|
|
|
|
Class->MaxNumProtos = NewNumProtos;
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (i = 0; i < Class->NumConfigs; i++) {
|
|
|
|
Config = Class->Configurations[i];
|
|
|
|
Class->Configurations[i] = ExpandBitVector (Config, NewNumProtos);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (Bit = Class->NumProtos; Bit < NewNumProtos; Bit++)
|
2007-03-08 04:03:40 +08:00
|
|
|
reset_bit(Config, Bit);
|
|
|
|
}
|
|
|
|
}
|
2009-03-11 03:03:06 +08:00
|
|
|
NewProto = Class->NumProtos++;
|
|
|
|
if (Class->NumProtos > MAX_NUM_PROTOS) {
|
2008-02-01 08:21:49 +08:00
|
|
|
tprintf("Ouch! number of protos = %d, vs max of %d!",
|
2009-03-11 03:03:06 +08:00
|
|
|
Class->NumProtos, MAX_NUM_PROTOS);
|
2008-02-01 08:21:49 +08:00
|
|
|
}
|
2007-03-08 04:03:40 +08:00
|
|
|
return (NewProto);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ClassConfigLength
|
|
|
|
*
|
|
|
|
* Return the length of all the protos in this class.
|
|
|
|
**********************************************************************/
|
|
|
|
FLOAT32 ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config) {
|
2008-04-22 08:23:04 +08:00
|
|
|
inT16 Pid;
|
2007-03-08 04:03:40 +08:00
|
|
|
FLOAT32 TotalLength = 0;
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
|
2007-03-08 04:03:40 +08:00
|
|
|
if (test_bit (Config, Pid)) {
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
TotalLength += (ProtoIn (Class, Pid))->Length;
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return (TotalLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ClassProtoLength
|
|
|
|
*
|
|
|
|
* Return the length of all the protos in this class.
|
|
|
|
**********************************************************************/
|
|
|
|
FLOAT32 ClassProtoLength(CLASS_TYPE Class) {
|
2008-04-22 08:23:04 +08:00
|
|
|
inT16 Pid;
|
2007-03-08 04:03:40 +08:00
|
|
|
FLOAT32 TotalLength = 0;
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
|
|
|
|
TotalLength += (ProtoIn (Class, Pid))->Length;
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
return (TotalLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CopyProto
|
|
|
|
*
|
|
|
|
* Copy the first proto into the second.
|
|
|
|
**********************************************************************/
|
|
|
|
void CopyProto(PROTO Src, PROTO Dest) {
|
2009-03-11 03:03:06 +08:00
|
|
|
Dest->X = Src->X;
|
|
|
|
Dest->Y = Src->Y;
|
|
|
|
Dest->Length = Src->Length;
|
|
|
|
Dest->Angle = Src->Angle;
|
|
|
|
Dest->A = Src->A;
|
|
|
|
Dest->B = Src->B;
|
|
|
|
Dest->C = Src->C;
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* FillABC
|
|
|
|
*
|
|
|
|
* Fill in Protos A, B, C fields based on the X, Y, Angle fields.
|
|
|
|
**********************************************************************/
|
|
|
|
void FillABC(PROTO Proto) {
|
|
|
|
FLOAT32 Slope, Intercept, Normalizer;
|
|
|
|
|
|
|
|
Slope = tan (Proto->Angle * 2.0 * PI);
|
|
|
|
Intercept = Proto->Y - Slope * Proto->X;
|
|
|
|
Normalizer = 1.0 / sqrt (Slope * Slope + 1.0);
|
|
|
|
Proto->A = Slope * Normalizer;
|
|
|
|
Proto->B = -Normalizer;
|
|
|
|
Proto->C = Intercept * Normalizer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* FreeClass
|
|
|
|
*
|
|
|
|
* Deallocate the memory consumed by the specified class.
|
|
|
|
**********************************************************************/
|
|
|
|
void FreeClass(CLASS_TYPE Class) {
|
|
|
|
if (Class) {
|
|
|
|
FreeClassFields(Class);
|
2009-07-11 10:17:36 +08:00
|
|
|
delete Class;
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* FreeClassFields
|
|
|
|
*
|
|
|
|
* Deallocate the memory consumed by subfields of the specified class.
|
|
|
|
**********************************************************************/
|
|
|
|
void FreeClassFields(CLASS_TYPE Class) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (Class) {
|
|
|
|
if (Class->MaxNumProtos > 0)
|
|
|
|
memfree (Class->Prototypes);
|
|
|
|
if (Class->MaxNumConfigs > 0) {
|
2009-03-11 03:03:06 +08:00
|
|
|
for (i = 0; i < Class->NumConfigs; i++)
|
|
|
|
FreeBitVector (Class->Configurations[i]);
|
2007-03-08 04:03:40 +08:00
|
|
|
memfree (Class->Configurations);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* NewClass
|
|
|
|
*
|
|
|
|
* Allocate a new class with enough memory to hold the specified number
|
|
|
|
* of prototypes and configurations.
|
|
|
|
**********************************************************************/
|
|
|
|
CLASS_TYPE NewClass(int NumProtos, int NumConfigs) {
|
|
|
|
CLASS_TYPE Class;
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
Class = new CLASS_STRUCT;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
if (NumProtos > 0)
|
|
|
|
Class->Prototypes = (PROTO) Emalloc (NumProtos * sizeof (PROTO_STRUCT));
|
|
|
|
|
|
|
|
if (NumConfigs > 0)
|
|
|
|
Class->Configurations = (CONFIGS) Emalloc (NumConfigs *
|
|
|
|
sizeof (BIT_VECTOR));
|
|
|
|
Class->MaxNumProtos = NumProtos;
|
|
|
|
Class->MaxNumConfigs = NumConfigs;
|
|
|
|
Class->NumProtos = 0;
|
|
|
|
Class->NumConfigs = 0;
|
|
|
|
return (Class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* PrintProtos
|
|
|
|
*
|
|
|
|
* Print the list of prototypes in this class type.
|
|
|
|
**********************************************************************/
|
|
|
|
void PrintProtos(CLASS_TYPE Class) {
|
2008-04-22 08:23:04 +08:00
|
|
|
inT16 Pid;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
|
2007-03-08 04:03:40 +08:00
|
|
|
cprintf ("Proto %d:\t", Pid);
|
|
|
|
PrintProto (ProtoIn (Class, Pid));
|
|
|
|
cprintf ("\t");
|
|
|
|
PrintProtoLine (ProtoIn (Class, Pid));
|
|
|
|
new_line();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ReadClassFile
|
|
|
|
*
|
|
|
|
* Read in the training data from a file. All of the classes are read
|
|
|
|
* in. The results are stored in the global variable, 'TrainingData'.
|
|
|
|
**********************************************************************/
|
2009-07-11 10:17:36 +08:00
|
|
|
namespace tesseract {
|
|
|
|
void Classify::ReadClassFile() {
|
2007-07-18 09:15:07 +08:00
|
|
|
FILE *File;
|
|
|
|
char TextLine[CHARS_PER_LINE];
|
|
|
|
char unichar[CHARS_PER_LINE];
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
cprintf ("Reading training data from '%s' ...",
|
|
|
|
static_cast<STRING>(classify_training_file).string());
|
2007-07-18 09:15:07 +08:00
|
|
|
fflush(stdout);
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
File = open_file(static_cast<STRING>(classify_training_file).string(), "r");
|
2007-07-18 09:15:07 +08:00
|
|
|
while (fgets (TextLine, CHARS_PER_LINE, File) != NULL) {
|
|
|
|
|
|
|
|
sscanf(TextLine, "%s", unichar);
|
|
|
|
ReadClassFromFile (File, unicharset.unichar_to_id(unichar));
|
|
|
|
fgets(TextLine, CHARS_PER_LINE, File);
|
|
|
|
fgets(TextLine, CHARS_PER_LINE, File);
|
|
|
|
}
|
|
|
|
fclose(File);
|
|
|
|
new_line();
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
2009-07-11 10:17:36 +08:00
|
|
|
} // namespace tesseract
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ReadClassFromFile
|
|
|
|
*
|
|
|
|
* Read in a class description (protos and configs) from a file. Update
|
|
|
|
* the class structure record.
|
|
|
|
**********************************************************************/
|
2007-07-18 09:15:07 +08:00
|
|
|
void ReadClassFromFile(FILE *File, UNICHAR_ID unichar_id) {
|
2007-03-08 04:03:40 +08:00
|
|
|
CLASS_TYPE Class;
|
|
|
|
|
2007-07-18 09:15:07 +08:00
|
|
|
Class = &TrainingData[unichar_id];
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
ReadProtos(File, Class);
|
|
|
|
|
|
|
|
ReadConfigs(File, Class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ReadConfigs
|
|
|
|
*
|
|
|
|
* Read the prototype configurations for this class from a file. Read
|
|
|
|
* the requested number of lines.
|
|
|
|
**********************************************************************/
|
|
|
|
void ReadConfigs(register FILE *File, CLASS_TYPE Class) {
|
2008-04-22 08:23:04 +08:00
|
|
|
inT16 Cid;
|
|
|
|
register inT16 Wid;
|
2007-03-08 04:03:40 +08:00
|
|
|
register BIT_VECTOR ThisConfig;
|
|
|
|
int NumWords;
|
|
|
|
int NumConfigs;
|
|
|
|
|
|
|
|
fscanf (File, "%d %d\n", &NumConfigs, &NumWords);
|
2009-03-11 03:03:06 +08:00
|
|
|
Class->NumConfigs = NumConfigs;
|
2007-03-08 04:03:40 +08:00
|
|
|
Class->MaxNumConfigs = NumConfigs;
|
|
|
|
Class->Configurations =
|
|
|
|
(CONFIGS) Emalloc (sizeof (BIT_VECTOR) * NumConfigs);
|
2009-03-11 03:03:06 +08:00
|
|
|
NumWords = WordsInVectorOfSize (Class->NumProtos);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
for (Cid = 0; Cid < NumConfigs; Cid++) {
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
ThisConfig = NewBitVector (Class->NumProtos);
|
2007-03-08 04:03:40 +08:00
|
|
|
for (Wid = 0; Wid < NumWords; Wid++)
|
|
|
|
fscanf (File, "%x", &ThisConfig[Wid]);
|
2009-03-11 03:03:06 +08:00
|
|
|
Class->Configurations[Cid] = ThisConfig;
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ReadProtos
|
|
|
|
*
|
|
|
|
* Read in all the prototype information from a file. Read the number
|
|
|
|
* of lines requested.
|
|
|
|
**********************************************************************/
|
|
|
|
void ReadProtos(register FILE *File, CLASS_TYPE Class) {
|
2008-04-22 08:23:04 +08:00
|
|
|
register inT16 Pid;
|
2007-03-08 04:03:40 +08:00
|
|
|
register PROTO Proto;
|
|
|
|
int NumProtos;
|
|
|
|
|
|
|
|
fscanf (File, "%d\n", &NumProtos);
|
2009-03-11 03:03:06 +08:00
|
|
|
Class->NumProtos = NumProtos;
|
2007-03-08 04:03:40 +08:00
|
|
|
Class->MaxNumProtos = NumProtos;
|
|
|
|
Class->Prototypes = (PROTO) Emalloc (sizeof (PROTO_STRUCT) * NumProtos);
|
|
|
|
|
|
|
|
for (Pid = 0; Pid < NumProtos; Pid++) {
|
|
|
|
Proto = ProtoIn (Class, Pid);
|
|
|
|
fscanf (File, "%f %f %f %f %f %f %f\n",
|
2009-03-11 03:03:06 +08:00
|
|
|
&Proto->X,
|
|
|
|
&Proto->Y,
|
|
|
|
&Proto->Length,
|
|
|
|
&Proto->Angle,
|
|
|
|
&Proto->A,
|
|
|
|
&Proto->B, &Proto->C);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* SplitProto
|
|
|
|
*
|
|
|
|
* Add a new proto to this class. Malloc new space and copy the
|
|
|
|
* old protos if necessary. Return the proto id for the new proto.
|
|
|
|
* Update all configurations so that each config which contained the
|
|
|
|
* specified old proto will also contain the new proto. The caller
|
|
|
|
* is responsible for actually filling in the appropriate proto params.
|
|
|
|
**********************************************************************/
|
|
|
|
int SplitProto(CLASS_TYPE Class, int OldPid) {
|
|
|
|
int i;
|
|
|
|
int NewPid;
|
|
|
|
BIT_VECTOR Config;
|
|
|
|
|
|
|
|
NewPid = AddProtoToClass (Class);
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (i = 0; i < Class->NumConfigs; i++) {
|
|
|
|
Config = Class->Configurations[i];
|
2007-03-08 04:03:40 +08:00
|
|
|
if (test_bit (Config, OldPid))
|
|
|
|
SET_BIT(Config, NewPid);
|
|
|
|
}
|
|
|
|
return (NewPid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* WriteOldConfigFile
|
|
|
|
*
|
|
|
|
* Write the configs in the given class to the specified file in the
|
|
|
|
* old config format.
|
|
|
|
**********************************************************************/
|
|
|
|
void WriteOldConfigFile(FILE *File, CLASS_TYPE Class) {
|
|
|
|
int Cid, Pid;
|
|
|
|
BIT_VECTOR Config;
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
fprintf (File, "%d %d\n", Class->NumConfigs, Class->NumProtos);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (Cid = 0; Cid < Class->NumConfigs; Cid++) {
|
2007-03-08 04:03:40 +08:00
|
|
|
fprintf (File, "1 ");
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
Config = Class->Configurations[Cid];
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
|
2007-03-08 04:03:40 +08:00
|
|
|
if (test_bit (Config, Pid))
|
|
|
|
fprintf (File, "1");
|
|
|
|
else
|
|
|
|
fprintf (File, "0");
|
|
|
|
}
|
|
|
|
fprintf (File, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* WriteOldProtoFile
|
|
|
|
*
|
|
|
|
* Write the protos in the given class to the specified file in the
|
|
|
|
* old proto format.
|
|
|
|
**********************************************************************/
|
|
|
|
void WriteOldProtoFile(FILE *File, CLASS_TYPE Class) {
|
|
|
|
int Pid;
|
|
|
|
PROTO Proto;
|
|
|
|
|
|
|
|
/* print old header */
|
|
|
|
fprintf (File, "6\n");
|
|
|
|
fprintf (File, "linear essential -0.500000 0.500000\n");
|
|
|
|
fprintf (File, "linear essential -0.250000 0.750000\n");
|
|
|
|
fprintf (File, "linear essential 0.000000 1.000000\n");
|
|
|
|
fprintf (File, "circular essential 0.000000 1.000000\n");
|
|
|
|
fprintf (File, "linear non-essential -0.500000 0.500000\n");
|
|
|
|
fprintf (File, "linear non-essential -0.500000 0.500000\n");
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
|
2007-03-08 04:03:40 +08:00
|
|
|
Proto = ProtoIn (Class, Pid);
|
|
|
|
|
|
|
|
fprintf (File, "significant elliptical 1\n");
|
|
|
|
fprintf (File, " %9.6f %9.6f %9.6f %9.6f %9.6f %9.6f\n",
|
2009-03-11 03:03:06 +08:00
|
|
|
Proto->X, Proto->Y,
|
|
|
|
Proto->Length, Proto->Angle, 0.0, 0.0);
|
2007-03-08 04:03:40 +08:00
|
|
|
fprintf (File, " %9.6f %9.6f %9.6f %9.6f %9.6f %9.6f\n",
|
|
|
|
0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001);
|
|
|
|
}
|
|
|
|
}
|