Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

bccline.cpp

Go to the documentation of this file.
00001 #include <iostream.h> // cgs@sfu.ca - April 2002, added the ".h" for IRIX
00002 #include <stdio.h>
00003 #include <math.h>
00004 
00005 #include "vuVector.h"
00006 
00007 //g++ bccline.cpp -o bccline -I ~/space/projects/vuVolume/proj/General ~/space/projects/vuVolume/proj/General/vuVector.o ~/space/projects/vuVolume/proj/General/vuMatrix.o
00008 #define MAXX    45
00009 #define MAXY    45
00010 #define MAXZ    90
00011 #define DATSIZE MAXX*MAXY*MAXZ
00012 #define FNAME   "line.bcc.vud"
00013 #define T       1.41421356
00014 
00015 // taken from vu1512
00016 vuVector getVoxelPosition(int x, int y, int z)
00017 {
00018   vuVector pos;
00019   if(z&0x01){
00020     //secondary grid
00021     pos[0] = (float(x)+0.5)*T;
00022     pos[1] = (float(y)+0.5)*T;
00023     pos[2] = (float(z))*(T*0.5);
00024   } else {
00025     //primary grid
00026     pos[0] = float(x)*T;
00027     pos[1] = float(y)*T;
00028     pos[2] = float(z)*T*0.5;
00029   }
00030 
00031   return pos;
00032 }
00033 
00034 
00035 void main(void)
00036 {
00037   FILE *f = fopen(FNAME,"wb");
00038   if(f) {
00039     fprintf(f,"# vu DataFile Version 1.0\n");
00040     fprintf(f,"Volume Data\n");
00041     fprintf(f,"BINARY\n");
00042     fprintf(f,"DATASET BCC_POINTS\n");
00043     fprintf(f,"UNIMODAL\n");
00044     fprintf(f,"DIMENSIONS %i %i %i 1\n",MAXX,MAXY,MAXZ);
00045     fprintf(f,"ORIGIN 0 0 0 0\n");
00046     fprintf(f,"SPACING 0 0 0 0\n");
00047     fprintf(f,"POINT_DATA %i\n",DATSIZE);
00048     fprintf(f,"SCALARS data byte\n");
00049     fprintf(f,"LOOKUP_TABLE default\n");
00050 
00051     vuVector center = getVoxelPosition(MAXX,MAXY,MAXZ)*0.5f;
00052     float radius = center[center.getDominantAxis()]*0.8f;
00053     int i,j,k;
00054     for(k=0;k<MAXZ;k++) {
00055       for(j=0;j<MAXY;j++) {
00056         for(i=0;i<MAXX;i++) {
00057           vuVector v = getVoxelPosition(i,j,k);
00058           if(v[0]==v[1] && v[1]==v[2])
00059             fputc(255,f);
00060           else
00061             fputc(0,f);
00062         }
00063       }
00064     }
00065     fclose(f);
00066   } else printf("Couldn't create file %s.\n",FNAME);
00067 
00068 }

Generated on Wed Dec 15 21:20:28 2004 for vuVolume by  doxygen 1.3.9.1