cuiktransform.c
Go to the documentation of this file.00001 #include "world.h"
00002 #include "error.h"
00003 #include "defines.h"
00004
00005 #include <string.h>
00006
00041 int main(int argc, char **arg)
00042 {
00043 if (argc>4)
00044 {
00045 Tcpolyhedron body;
00046 THTransform transform;
00047 Tfilename bodyIn;
00048 Tfilename bodyOut;
00049 Tcolor color;
00050 char *transforms[6]={"Tx","Ty","Tz","Rx","Ry","Rz"};
00051 unsigned int i;
00052 boolean found;
00053
00054 NewColor(1,1,1,&color);
00055
00056 CreateFileName(NULL,arg[1],NULL,NULL,&bodyIn);
00057 InitCPolyhedronFromFile(GetFileFullName(&bodyIn),&color,1,&body);
00058
00059 found=FALSE;
00060 i=0;
00061 while((!found)&&(i<6))
00062 {
00063 found=(strcmp(arg[2],transforms[i])==0);
00064 if (!found)
00065 i++;
00066 }
00067
00068 if (!found)
00069 Error("Unknown transform in cuiktransform");
00070
00071 switch(i)
00072 {
00073 case 0:
00074 HTransformTx(atof(arg[3]),&transform);
00075 break;
00076 case 1:
00077 HTransformTy(atof(arg[3]),&transform);
00078 break;
00079 case 2:
00080 HTransformTz(atof(arg[3]),&transform);
00081 break;
00082 case 3:
00083 HTransformRx(atof(arg[3])*DEG2RAD,&transform);
00084 break;
00085 case 4:
00086 HTransformRy(atof(arg[3])*DEG2RAD,&transform);
00087 break;
00088 case 5:
00089 HTransformRz(atof(arg[3])*DEG2RAD,&transform);
00090 break;
00091 }
00092
00093 TransformCPolyhedron(&transform,&body);
00094
00095 CreateFileName(NULL,arg[4],NULL,NULL,&bodyOut);
00096 SaveCPolyhedron(GetFileFullName(&bodyOut),&body);
00097
00098 HTransformDelete(&transform);
00099 DeleteCPolyhedron(&body);
00100 DeleteColor(&color);
00101 DeleteFileName(&bodyIn);
00102 DeleteFileName(&bodyOut);
00103 }
00104 else
00105 {
00106
00107 fprintf(stdout," Wrong number of parameters.\n");
00108 fprintf(stdout," Use:\n");
00109 fprintf(stdout," cuiktransform <body in> <transform> <value> <body out>\n");
00110 fprintf(stdout," Where:\n");
00111 fprintf(stdout," <body in>: File with the convex body to transform\n");
00112 fprintf(stdout," <transform>: Transform to apply (Tx,Ty,Tz,Rx,Ry,Rz)\n");
00113 fprintf(stdout," <value>: Parameter for the transform (angles in degrees!!).\n");
00114 fprintf(stdout," <body out>: Name of output file with the transformed convex body.\n");
00115 }
00116
00117 return(EXIT_SUCCESS);
00118 }