00001 /* 00002 PROJETO USPDesigner 00003 MODULO: EUL (Operadores de Euler) 00004 Copyright (C) 1989 a 2008, Marcos Tsuzuki, All rights reserved 00005 Universidade de Sao Paulo, EPUSP-PMR 00006 00007 NOME DO ARQUIVO: eulread_.cpp 00008 Coded by Marcos Tsuzuki 00009 00010 Redistribution and use in source and binary forms, with or without 00011 modification, are permitted provided that the following conditions 00012 are met: 00013 00014 1. Redistributions of source code must retain the above copyright 00015 notice, this list of conditions and the following disclaimer. 00016 00017 2. Redistributions in binary form must reproduce the above copyright 00018 notice, this list of conditions and the following disclaimer in the 00019 documentation and/or other materials provided with the distribution. 00020 00021 3. The names of its contributors may not be used to endorse or promote 00022 products derived from this software without specific prior written 00023 permission. 00024 00025 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00026 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00027 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00028 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00029 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 00037 00038 Any feedback is very welcome. 00039 email: mtsuzuki at usp.br (remove space) 00040 */ 00041 #include <stdio.h> 00042 #include <string.h> 00043 #include "mensagem.h" 00044 #include "memvirtu.h" 00045 #include "lowparam.h" 00046 #include "lowsolid.h" 00047 #include "curvgeom.h" 00048 #include "eulerops.h" 00049 #include "mancommd.h" 00050 00051 typedef struct eulercod EuCode; 00052 00053 struct eulercod 00054 { 00055 OpCode ecode; 00056 char *eop; 00057 int (*xeop)(EulerOp *op); 00058 void (*peop)(FILE *f, EulerOp *op); 00059 int (*reop)(FILE *f, EulerOp *op); 00060 int (*meop)(EulerOp *op); 00061 int num; 00062 }; 00063 00064 extern EuCode ematrix[]; 00065 00066 /* Read an ASCII Euler Operator. Construct an Euler operator from a printed */ 00067 /* operator. The identical format to that of printop() is used. */ 00068 int MSD_lowScanEulerOperator(FILE *f, EulerOp *op) 00069 { 00070 EuCode *p; 00071 char name[20]; 00072 short n; 00073 00074 if (((n = fscanf(f, "%s", name)) == EOF) || (n != 1)) 00075 { 00076 return(0); 00077 } 00078 strupper((unsigned char *)name); 00079 for (p = ematrix; *p->eop; ++p) 00080 { 00081 if (!strncmp(p->eop, name, strlen(name))) 00082 { 00083 break; 00084 } 00085 } 00086 00087 op->opcode = p->ecode; 00088 if ((*p->reop)(f, op) == ERROR) 00089 { 00090 fprintf(stderr, MEN_ParametrosIncorretos, NAM_ScanEulerOp); 00091 return(ERROR); 00092 } 00093 return(SUCCESS); 00094 } 00095 00096 int MSD_readStructError(FILE *f, EulerOp *op) 00097 { 00098 MSD_lowNaoUtilizado(f); 00099 MSD_lowNaoUtilizado(op); 00100 00101 fprintf(stderr, MEN_ParametrosIncorretos, NAM_ScanEulerOp); 00102 return(ERROR); 00103 }