📄 attrproj.c
字号:
============================================================
DEVise Data Visualization Software
(c) Copyright 1992-1996
By the DEVise Development Group
Madison, Wisconsin
All Rights Reserved.
========================================================================
Under no circumstances is this software to be copied, distributed,
or altered in any way without prior permission from the DEVise
Development Group.
*/
/*
Implementation of AttrProj (attribute projection) class.
*/
/*
$Id: AttrProj.c,v 1.16 1996/12/03 20:26:03 jussi Exp $
$Log: AttrProj.c,v $
Revision 1.16 1996/12/03 20:26:03 jussi
Updated to reflect new TData interfaces.
Revision 1.15 1996/11/23 21:35:33 jussi
Minor change to reflect change in TData::GetRecs().
Revision 1.14 1996/11/05 19:46:48 wenger
Fixed some bugs in the attribute projection code (handles blanks lines
and much longer lines in projection files); removed unneeded -lpthread
from Makefile for solaris attribute projection.
Revision 1.13 1996/10/10 16:45:19 wenger
Changed function names, etc., in ApParseCat.c to get rid of name clashes
when Donko puts transformation engine code into DEVise.
Revision 1.12 1996/08/23 16:54:59 wenger
First version that allows the use of Dali to display images (more work
needs to be done on this); changed DevStatus to a class to make it work
better; various minor bug fixes.
Revision 1.11 1996/08/15 19:54:48 wenger
Added 'pure' targets for attrproj and devread; fixed some dynamic
memory problems. Found some bugs while demo'ing for soils science
people.
Revision 1.10 1996/08/02 15:53:36 wenger
Added AttrProj member functions for reading entire records (no projection).
Revision 1.9 1996/07/31 19:33:37 wenger
Added AttrProj member functions for reading entire records (no projection).
Revision 1.8 1996/06/27 18:12:04 wenger
Re-integrated most of the attribute projection code (most importantly,
all of the TData code) into the main code base (reduced the number of
modules used only in attribute projection).
Revision 1.7 1996/06/19 19:55:52 wenger
Improved UtilAtof() to increase speed; updated code for testing it.
Revision 1.6 1996/06/17 20:01:07 wenger
First version of 'show' program for dumping projections to stdout.
Revision 1.5 1996/05/14 15:34:48 wenger
Added GetDataSize method to AttrProj class; removed vector.o from
AttrProjLib.o; various cleanups.
Revision 1.4 1996/05/01 16:19:32 wenger
Initial version of code to project attributes now working.
Revision 1.3 1996/04/30 18:53:32 wenger
Attrproj now generates a single projection of all attributes of the
real data.
Revision 1.2 1996/04/30 15:31:50 wenger
Attrproj code now reads records via TData object; interface to Birch
code now in place (but not fully functional).
Revision 1.1 1996/04/25 19:25:22 wenger
Attribute projection code can now parse a schema, and create the
corresponding TData object.
*/
#define _AttrProj_c_
//#define DEBUG
#include <stdio.h>
#include <string.h>
#include "AttrProj.h"
#include "ApParseCat.h"
#include "Util.h"
#include "TData.h"
#include "AttrList.h"
#include "ProjectionList.h"
#include "DataSeg.h"
/* The type of data stored in a Vector. */
#define VECTOR_TYPE double
static double AttrToDouble(AttrType type, char *valP);
#if !defined(lint) && defined(RCSID)
static char rcsid[] = "$RCSfile: AttrProj.c,v $ $Revision: 1.16 $ $State: Exp $";
#endif
static char * srcFile = __FILE__;
/*------------------------------------------------------------------------------
* function: AttrProj::AttrProj
* AttrProj constructor.
*/
AttrProj::AttrProj(char *schemaFile, char *attrProjFile, char *dataFile)
{
DO_DEBUG(printf("AttrProj::AttrProj(%s, %s, %s)\n", schemaFile,
attrProjFile, dataFile));
DOASSERT(dataFile != NULL, "Can't have NULL datafile");
// Provision for having the schema in the data file.
if ((schemaFile == NULL) || !strcmp(schemaFile, ""))
{
schemaFile = dataFile;
}
// strdups because TData destructor will try to free all of these
// strings -- make sure they're dynamic.
schemaFile = strdup(schemaFile);
attrProjFile = strdup(attrProjFile);
dataFile = strdup(dataFile);
DataSeg::Set(schemaFile, dataFile, 0, 0);
char *schemaName = ApParseCat(schemaFile, dataFile, _tDataP);
DOASSERT(schemaName != NULL, "Can' parse schema");
DevStatus ppRes = ParseProjection(attrProjFile);
DOASSERT(ppRes.IsComplete(), "Can't parse projection");
_recBufSize = _tDataP->RecSize();
_recBuf = new char[_recBufSize];
_attrCounts = new int[_projList.GetProjCount()];
_projSizes = new int[_projList.GetProjCount()];
int projNum = 0;
Projection * projP = _projList.GetFirstProj();
while (projP != NULL)
{
_attrCounts[projNum] = projP->attrCount;
_projSizes[projNum] = projP->attrCount * sizeof(VECTOR_TYPE);
projP = _projList.GetNextProj();
projNum++;
}
}
/*------------------------------------------------------------------------------
* function: AttrProj::~AttrProj
* AttrProj destructor.
*/
AttrProj::~AttrProj()
{
DO_DEBUG(printf("AttrProj::~AttrProj()\n"));
delete _tDataP;
delete [] _recBuf;
delete [] _attrCounts;
delete [] _projSizes;
}
/*------------------------------------------------------------------------------
* function: AttrProj::FirstRecId
* Get the ID of the first record available.
*/
DevStatus
AttrProj::FirstRecId(RecId &recId)
{
DO_DEBUG(printf("AttrProj::FirstRecId()\n"));
DevStatus result = StatusOk;
if (!_tDataP->HeadID(recId)) result = StatusFailed;
return result;
}
/*------------------------------------------------------------------------------
* function: AttrProj::LastRecId
* Get the record ID of the last record available.
*/
DevStatus
AttrProj::LastRecId(RecId &recId)
{
DO_DEBUG(printf("AttrProj::LastRecId()\n"));
DevStatus result = StatusOk;
if (!_tDataP->LastID(recId)) result = StatusFailed;
return result;
}
/*------------------------------------------------------------------------------
* function: AttrProj::GetDataSize
* Returns information about the size of data that will be produced when
* a record is read.
*/
DevStatus
AttrProj::GetDataSize(int &projCount, const int *&attrCounts,
const int *&projSizes)
{
DO_DEBUG(printf("AttrProj::GetDataSize()\n"));
DevStatus result = StatusOk;
projCount = _projList.GetProjCount();
attrCounts = _attrCounts;
projSizes = _projSizes;
return result;
}
/*------------------------------------------------------------------------------
* function: AttrProj::GetWholeRecSize
* Returns information about the size of data that will be produced when
* an entire record (not its projections) is read.
*/
DevStatus
AttrProj::GetWholeRecSize(int &attrCount, int &recSize)
{
DO_DEBUG(printf("AttrProj::GetWholeRecSize()\n"));
DevStatus result = StatusOk;
attrCount = 0;
recSize = 0;
AttrList *attrListP = _tDataP->GetAttrList();
attrListP->InitIterator();
while (attrListP->More())
{
AttrInfo *attrInfoP = attrListP->Next();
attrCount++;
recSize += sizeof(VECTOR_TYPE);
}
attrListP->DoneIterator();
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -