TPCCLIB
Loading...
Searching...
No Matches
tacname.c File Reference

Working with TAC names in TAC structure. More...

#include "tpcclibConfig.h"
#include "tpcift.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "tpctac.h"

Go to the source code of this file.

Functions

int tacIndividualNames (TAC *tac)
void tacEnsureNames (TAC *tac)

Detailed Description

Working with TAC names in TAC structure.

Definition in file tacname.c.

Function Documentation

◆ tacEnsureNames()

void tacEnsureNames ( TAC * tac)

Ensure that TAC structure contains a name for each TAC. If not available, then TAC index+1 is written as name.

See also
tacIndividualNames, tacSelectTACs, tacSelectBestReference, roinameMatch
Author
Vesa Oikonen
Parameters
tacPointer to TAC structure.

Definition at line 50 of file tacname.c.

53 {
54 if(tac==NULL || tac->tacNr<1) return;
55 int ri, u, n;
56 u=tac->tacNr; n=1; while((u/=10)>=1) n++;
58 for(ri=0; ri<tac->tacNr; ri++) {
59 if(!roinameExists(tac->c[ri].name))
60 sprintf(tac->c[ri].name, "%0*d", n, 1+ri);
61 }
62 return;
63}
int roinameExists(char *roiname)
Verifies whether TAC name exists or not.
Definition roiname.c:158
char name[MAX_TACNAME_LEN+1]
Definition tpctac.h:81
TACC * c
Definition tpctac.h:117
int tacNr
Definition tpctac.h:91
#define MAX_TACNAME_LEN
Max length of TAC ID name (not including trailing zero).

Referenced by tacWriteCSV(), tacWriteDFT(), tacWritePMOD(), tacWriteSheetIntoXML(), and tacWriteXML().

◆ tacIndividualNames()

int tacIndividualNames ( TAC * tac)

Verifies that TAC structure contains a name for each TAC, and no other TAC has the same name.

Returns
1 if individual names exist, 0 if not.
Author
Vesa Oikonen
See also
tacSelectTACs, tacSelectBestReference, roinameMatch, tacEnsureNames
Parameters
tacPointer to TAC structure.

Definition at line 24 of file tacname.c.

27 {
28 if(tac==NULL || tac->tacNr<1) return(0);
29 int ri, rj;
30 /* First check that names do exist */
31 for(ri=0; ri<tac->tacNr; ri++) {
32 if(!roinameExists(tac->c[ri].name)) return(0);
33 }
34 /* If just one TAC, then its name is individual */
35 if(tac->tacNr==1) return(1);
36 /* Otherwise compare each of the names */
37 for(ri=0; ri<tac->tacNr-1; ri++)
38 for(rj=ri+1; rj<tac->tacNr; rj++)
39 if(strcasecmp(tac->c[ri].name, tac->c[rj].name)==0) return(0);
40 return(1);
41}