home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
READER
/
FRMREAD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-12
|
4KB
|
188 lines
/*
* 形状ファイル入力関数
*
* Copyright T.Kobayashi 1993.1.17
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include "_reader.h"
#include "word.h"
#include "matrix.h"
#define NOT_FOUND 11
#define BAD_EXIST 12
#define NOT_FRM_FILE 13
#define NOT_IMPLIMENTED 14
#define LESS_POINT 15
#define MAT_STACK_OVERFLOW 17
#define UNEXPECTED_EOF 21
#define NOT_OBJ_FILE 22
#define MAT_STACK_MAX 20
static Matrix MatStack[MAT_STACK_MAX+1] ;
static int MatSP ;
static Matrix CurMat ;
static int UnitFlag;
static void frmerror( int, char* );
extern int lasterror;
int FrmReadOpen( filename )
const char *filename ;
{
lasterror = 0;
/* ファイルのオープン */
if ( fileopen( filename ) == 0 )
return FALSE ;
if (wordid != WORD_FRAM) {
frmerror(NOT_FRM_FILE,"");
return FALSE;
}
get();
if (wordid != WORD_OPEN2) {
frmerror(NOT_FRM_FILE,"");
return FALSE;
}
MatSP = 0 ;
MatUnit( MatStack[MatSP] );
MatCopy( CurMat, MatStack[MatSP] );
UnitFlag = TRUE;
return TRUE ;
}
int FrmReadClose()
{
fileclose() ;
return TRUE ;
}
int FrmReadObj( char *objname, Matrix Conv)
{
if ( end_of_file )
return FALSE ;
while( wordid != WORD_OBJ && MatSP > -1 )
{
if (end_of_file) return FALSE;
switch( wordid )
{
case WORD_OPEN2 :
get() ;
MatCopy( MatStack[MatSP+1], MatStack[MatSP] );
if ( MatSP >= MAT_STACK_MAX ) {
frmerror( MAT_STACK_OVERFLOW, "" );
return FALSE;
}
else
{
MatSP ++ ;
MatCopy( CurMat, MatStack[MatSP] );
}
break ;
case WORD_CLOSE2 :
get() ;
MatSP -- ;
if ( MatSP > 0 )
MatCopy( CurMat, MatStack[MatSP] );
break ;
case WORD_LIGHT :
get();
if (wordid != WORD_PAL) {
frmerror(NOT_IMPLIMENTED, nextword);
} else {
Color tmp;
isopen1();
getcolor(&tmp);
getfloat();
getfloat();
getfloat();
isclose1();
}
break;
case WORD_EYE :
get();
if (wordid != WORD_DEG) {
frmerror(BAD_EXIST, nextword);
} else {
isopen1();
getfloat();
isclose1();
}
break;
case WORD_TARGET :
get();
break;
default :
getmat( MatStack[MatSP] );
MatCopy( CurMat, MatStack[MatSP] );
UnitFlag = FALSE;
break ;
}
if (lasterror) return FALSE;
}
if (lasterror) return FALSE;
if ( MatSP == -1 )
return FALSE ;
get() ;
MatCopy( Conv, CurMat );
strcpy( objname, nextword ) ;
get() ;
return TRUE ;
}
static void frmerror( n, arg )
int n ;
char *arg ;
{
char *msg ;
int level ;
switch( n )
{
case NOT_FOUND :
msg = " %s がありません。" ;
level = 10 ;
break ;
case BAD_EXIST :
msg = " %s が存在します。" ;
level = 10 ;
break ;
case NOT_IMPLIMENTED :
msg = " %s はサポートしていません。" ;
level = 10 ;
break ;
case NOT_FRM_FILE :
msg = "メカデザインファイルではありません。" ;
level = 10 ;
case LESS_POINT :
msg = "多角形の頂点が2つ以下しかありません。" ;
level = 10 ;
break ;
case MAT_STACK_OVERFLOW :
msg = "構\造定義が複雑すぎます。" ;
level = 10 ;
break ;
case UNEXPECTED_EOF :
msg = "エンドオブファイルになりました" ;
level = 20 ;
break ;
default :
msg = "エラーコードの誤り。( objread.c )" ;
level = 20 ;
break ;
}
errormessage( level, msg, arg );
}