void apply_in_ardop_params_to_ardop_params(struct INPUT_ARDOP_PARAMS *in,
                                           struct ARDOP_PARAMS *a)
{
    strcpy(a->in1, in->in1);
    strcpy(a->out, in->out);
    strcpy(a->status, in->status);

    if (in->CALPRMS)
        strcpy(a->CALPRMS, in->CALPRMS);

#define ApplyField(field) if (in->field) a->field = *(in->field);

    ApplyField(pwrFlag);
    ApplyField(sigmaFlag);
    ApplyField(gammaFlag);
    ApplyField(betaFlag);
    ApplyField(hamFlag);
    ApplyField(kaiFlag);
    ApplyField(ifirstline);
    ApplyField(npatches);
    ApplyField(isave);
    ApplyField(ifirst);
    ApplyField(nla);
    ApplyField(azres);
    ApplyField(deskew);
    ApplyField(na_valid);
    ApplyField(sloper);
    ApplyField(interr);
    ApplyField(slopea);
    ApplyField(intera);
    ApplyField(dsloper);
    ApplyField(dinterr);
    ApplyField(dslopea);
    ApplyField(dintera);
    ApplyField(fd);
    ApplyField(fdd);
    ApplyField(fddd);
    ApplyField(iflag);

#undef ApplyField
}
Beispiel #2
0
void KVReader2::ApplyStruct(KeyValue* parent, ntroStruct* str, char* dataH, rerlHeader* rerlH, ntroHeader* ntroH)
{
	// variable prepare
	char* data = dataH;
	ntroStruct* sEntries = (ntroStruct*) (((char*) &ntroH->structOffset) + ntroH->structOffset);
	ntroStruct* baseStruct = 0;
	
	// Apply base struct structure
	if(str->baseStructId != 0)
	{
		// Find it in NTRO block (move this to its own function?)
		for(int s=1;s<ntroH->structCount;s++)
		{
			ntroStruct* checking = sEntries + s;
			if(checking->id == str->baseStructId)
			{
				baseStruct = checking;
				break;
			}
		}
		// Now apply it
		ApplyStruct(parent, baseStruct, data, rerlH, ntroH);
		// Don't need to apply size to data because diskOffset of field in derived struct
		// already include this padding
	}
	// Apply our structure
	ntroField* fEntry = (ntroField*) (((char*) &str->fieldOffset) + str->fieldOffset);
	for(int k=0;k<str->fieldCount;k++)
	{
		// variable prepare
		ntroField* f = fEntry + k;
		char* dataF = data + f->diskOffset;
		// create node, assign name, hash, type
		KeyValue* node = new KeyValue();
		char* fieldName = ((char*) &f->nameOffset) + f->nameOffset;
		node->key = fieldName;
		node->CalcHash();
		node->type = f->type;
		parent->Attach(node);
		
		node->childCountAddress = dataF;
		
		// prepare just in case
		char* indirect =  ((char*) &f->indirectOffset) + f->indirectOffset;
		
		// check for special type
		if(f->indirectLevel > 0)
		{
			// Array of data
			
			// structure: { 4:offset, 4:count }
			unsigned int elemPointerOffset = *((unsigned int*) dataF);
			char* elemPointer = dataF + elemPointerOffset;
			node->childCountAddress = dataF + 4;
			unsigned int elemCount = *((unsigned int*) (node->childCountAddress));
			if(indirect[0] == 0x03) 
			{
				elemCount = 1;
				node->childCountAddress = dataF;
			}
			
			node->realChildCount = elemCount;
			
			if(elemPointerOffset == 0)
			{
				//printf("Indirect pointer is 0, skippping\n");
				continue;
			}
			
			//printf("%s is %d deep with i[0] = %d and have %d child\n",node->key,f->indirectLevel,indirect[0],elemCount);
			
			if(elemCount<=0)
			{
				//printf("Got %d size array, skippping\n",elemCount);
				continue;
			}
			
			if(elemCount>1000)
			{
				// why it has to put all vertex in structure ...
				elemCount = 1000;
			}
			
			node->value = 0;
			
			if(f->type==0x01)
			{
				// finding the structure used for this data from NTRO blocks
				baseStruct = 0;
				for(int s=1;s<ntroH->structCount;s++)
				{
					ntroStruct* checking = sEntries + s;
					if(checking->id == f->typeData)
					{
						baseStruct = checking;
						break;
					}
				}
				// loop over each element
				for(int e=0;e<elemCount;e++)
				{
					// new element node
					KeyValue* elemNode = new KeyValue();
					node->Attach(elemNode);
					elemNode->childCountAddress = elemPointer;
					// apply it
					ApplyStruct(elemNode, baseStruct, elemPointer, rerlH, ntroH);
					// move pointer to next element
					elemPointer += baseStruct->size;
				}
			}
			else
			{
				//printf("field %s type %d count %d\n",((char*) (&f->nameOffset)) + f->nameOffset,f->type,elemCount);
			
				// Apply current field over array
				int fieldSize = 0;
				if(f->type==NTRO_DATA_TYPE_HANDLE)
				{
					fieldSize = 8;
				}
				else if(f->type==NTRO_DATA_TYPE_NAME)
				{
					fieldSize = 4;
				}
				else if(f->type==NTRO_DATA_TYPE_SHORT || f->type==NTRO_DATA_TYPE_USHORT)
				{
					fieldSize = 2;
				}
				else if(f->type==NTRO_DATA_TYPE_INTEGER || f->type==NTRO_DATA_TYPE_UINTEGER || f->type==NTRO_DATA_TYPE_FLOAT)
				{
					fieldSize = 4;
				}
				else if(f->type==NTRO_DATA_TYPE_BYTE || f->type==NTRO_DATA_TYPE_BOOLEAN)
				{
					fieldSize = 1;
				}
				else if(f->type==NTRO_DATA_TYPE_VECTOR3)
				{
					fieldSize = 12;
				}
				else if(f->type==NTRO_DATA_TYPE_VECTOR4 || f->type==NTRO_DATA_TYPE_QUATERNION || f->type==NTRO_DATA_TYPE_COLOR)
				{
					fieldSize = 16;
				}
				if(fieldSize==0)
				{
					fieldSize = 8;
					//printf("Need field type for non-handle %d!!\n",f->type);
				}
				for(int e=0;e<elemCount;e++)
				{
					// new element node
					KeyValue* elemNode = new KeyValue();
					node->Attach(elemNode);
					elemNode->type = f->type;
					elemNode->key = 0;
					elemNode->childCountAddress = elemPointer;
					// apply it
					ApplyField(elemNode, f, elemPointer, rerlH, ntroH);
					// move pointer to next element
					elemPointer += fieldSize;
				}
			}
		}
		else
		{
			
			if(f->type==0x01)
			{
				// child struct
				for(int s=1;s<ntroH->structCount;s++)
				{
					ntroStruct* checking = sEntries + s;
					if(checking->id == f->typeData)
					{
						baseStruct = checking;
						break;
					}
				}
				// Now apply it
				node->value = 0;
				node->childCountAddress = dataF;
				ApplyStruct(node, baseStruct, dataF, rerlH, ntroH);
			}
			else
			{
				// Direct value
				ApplyField(node, f, dataF,rerlH,ntroH);
				// add node to parent
			}
		}
	}
}