#include <filereader.h>
Public Member Functions | |
FileReader () | |
The Constructor. | |
~FileReader () | |
The Destructor. | |
int | getColorFormat () |
return ColorFormat | |
int | getNRow () |
return number of rows | |
int | getNCol () |
return number of columns | |
int | getNp () |
return number of pixels | |
int | getEncoding () |
return encoding | |
int | getInfo2d () |
return color information of 3d point | |
char | getColor () |
return black and white color | |
char | getR () |
return red portion | |
char | getG () |
return green portion | |
char | getB () |
return blue portion | |
float | getX () |
return x coordinate | |
float | getY () |
return y coordinate | |
float | getZ () |
return z coordinate | |
QString | getColorText () |
return color format description | |
QString | getInfo () |
return s3d header information | |
void | readFile (QString &fileName) |
reading s3d file function | |
Public Attributes | |
GLubyte | imagePixels [MAXPIXELHEIGHT][MAXPIXELWIDTH][3] |
pixel array of reference image | |
float | pointArray [1048576][6] |
array for 3d points |
Definition at line 98 of file filereader.h.
|
The Constructor.
Definition at line 39 of file filereader.cpp.
|
|
The Destructor.
Definition at line 44 of file filereader.cpp.
|
|
return blue portion
Definition at line 281 of file filereader.cpp. References TPixelColor::b. 00282 { 00283 return image_color->b; 00284 }
|
|
return black and white color
Definition at line 254 of file filereader.cpp. References TPixelBW::color. 00255 { 00256 return image_bw->color; 00257 }
|
|
return ColorFormat
Definition at line 200 of file filereader.cpp. References S3DHead::colorFormat. 00201 { 00202 return head->colorFormat; 00203 }
|
|
return color format description
Definition at line 209 of file filereader.cpp. Referenced by MainWidget::openFile().
|
|
return encoding
Definition at line 245 of file filereader.cpp. References S3DHead::encoding. Referenced by MainWidget::openFile(), and Point3dWidget::paintGL(). 00246 { 00247 return head->encoding; 00248 }
|
|
return green portion
Definition at line 272 of file filereader.cpp. References TPixelColor::g. 00273 { 00274 return image_color->g; 00275 }
|
|
return s3d header information
Definition at line 191 of file filereader.cpp. References S3DHead::info. Referenced by MainWidget::openFile(). 00192 { 00193 return QString( head->info ); 00194 }
|
|
return color information of 3d point
Definition at line 317 of file filereader.cpp. References TPoint3D::info2d. 00318 { 00319 return points->info2d; 00320 }
|
|
return number of columns
Definition at line 227 of file filereader.cpp. References S3DHead::ncol. Referenced by MainWidget::openFile(), and RefImgWidget::paintGL(). 00228 { 00229 return head->ncol; 00230 }
|
|
return number of pixels
Definition at line 236 of file filereader.cpp. References S3DHead::np. Referenced by MainWidget::openFile(), and Point3dWidget::paintGL(). 00237 { 00238 return head->np; 00239 }
|
|
return number of rows
Definition at line 218 of file filereader.cpp. References S3DHead::nrow. Referenced by MainWidget::openFile(), and RefImgWidget::paintGL(). 00219 { 00220 return head->nrow; 00221 }
|
|
return red portion
Definition at line 263 of file filereader.cpp. References TPixelColor::r. 00264 { 00265 return image_color->r; 00266 }
|
|
return x coordinate
Definition at line 290 of file filereader.cpp. References TPoint3D::x. 00291 { 00292 return points->x; 00293 }
|
|
return y coordinate
Definition at line 299 of file filereader.cpp. References TPoint3D::y. 00300 { 00301 return points->y; 00302 }
|
|
return z coordinate
Definition at line 308 of file filereader.cpp. References TPoint3D::z. 00309 { 00310 return points->z; 00311 }
|
|
reading s3d file function
Definition at line 53 of file filereader.cpp. References TPixelColor::b, TPixelBW::color, S3DHead::colorFormat, S3DHead::encoding, TPixelColor::g, imagePixels, TPoint3D::info2d, S3DHead::ncol, S3DHead::np, S3DHead::nrow, pointArray, TPixelColor::r, TPoint3D::x, TPoint3D::y, and TPoint3D::z. Referenced by MainWidget::openFile(). 00054 { 00055 // convert fileName to string 00056 const char *file = fileName.toLatin1 (); 00057 00058 // open file under READ ONLY mode 00059 int fich=open(file,O_RDONLY); 00060 if(fich<0){ 00061 qDebug("Error: file not found."); 00062 return; 00063 } 00064 00065 // initiate head structure 00066 head=(S3DHead*)malloc(sizeof(S3DHead)); 00067 // number of bytes read 00068 int br=read(fich,head,sizeof(S3DHead)); 00069 00070 // error reading control 00071 if(br!=sizeof(S3DHead)){ 00072 qDebug("Error: file corrupt."); 00073 return; 00074 } 00075 00076 // Gray image (if the file contains it) 00077 if(head->encoding==0 && head->colorFormat==0){ 00078 int npix=head->nrow*head->ncol; 00079 image_bw=(TPixelBW*)malloc(sizeof(TPixelBW)*npix); 00080 br=read(fich,image_bw,sizeof(TPixelBW)*npix); 00081 00082 //error reading control 00083 if(br!=(int)sizeof(TPixelBW)*npix){ 00084 qDebug("Error: file corrupt."); 00085 return; 00086 } 00087 } 00088 00089 // color format for info purpose 00090 if(head->colorFormat == 0) 00091 colorFormatText = "Black and White"; 00092 else 00093 colorFormatText = "Color RGB"; 00094 00095 // Color image (if the file contains it) 00096 TPixelColor *image_color=NULL; 00097 if(head->encoding==0 && head->colorFormat==1){ 00098 int npix=head->nrow*head->ncol; 00099 image_color=(TPixelColor*)malloc(sizeof(TPixelColor)*npix); 00100 br=read(fich,image_color,sizeof(TPixelColor)*npix); 00101 00102 // error reading control 00103 if(br!=(int)sizeof(TPixelColor)*npix){ 00104 qDebug("Error: file corrupt."); 00105 return; 00106 } 00107 } 00108 00109 // 3D Points 00110 TPoint3D *points=NULL; 00111 if(head->np>0){ 00112 points=(TPoint3D*)malloc(sizeof(TPoint3D)*head->np); 00113 br=read(fich,points,sizeof(TPoint3D)*head->np); 00114 00115 //error reading control 00116 if(br!=(int)sizeof(TPoint3D)*head->np){ 00117 if(image_bw) free(image_bw); 00118 if(image_color) free(image_color); 00119 qDebug("Error: file corrupt."); 00120 return; 00121 } 00122 } 00123 00124 // At this point, we have read all of the file data 00125 close(fich); 00126 00127 // Image (if exists) 00128 if(head->encoding==0){ 00129 for(int i=0;i<head->nrow;i++){ 00130 for(int j=0;j<head->ncol;j++){ 00131 if(head->colorFormat==0){ //Black and white case 00132 TPixelBW p=image_bw[ i*head->ncol+j ]; 00133 imagePixels[i][j][0] = (GLubyte) ( p.color ); 00134 imagePixels[i][j][1] = (GLubyte) ( p.color ); 00135 imagePixels[i][j][2] = (GLubyte) ( p.color ); 00136 }else{ //Color RGB case 00137 TPixelColor p=image_color[ i*head->ncol+j ]; 00138 imagePixels[i][j][0] = (GLubyte) ( p.r ); 00139 imagePixels[i][j][1] = (GLubyte) ( p.g ); 00140 imagePixels[i][j][2] = (GLubyte) ( p.b ); 00141 } 00142 } 00143 } 00144 } 00145 00146 // 3D points 00147 if(head->encoding==0){ 00148 for(int i=0;i<head->np;i++){ 00149 // we show the 3D coordinates (XYZ) and the image coordinates (IJ) of the points 00150 TPoint3D p=points[i]; 00151 pointArray[i][0] = p.x; // x coord 00152 pointArray[i][1] = p.y; // y coord 00153 pointArray[i][2] = p.z; // z coord 00154 pointArray[i][3] = (int) p.info2d/head->ncol; // x reference image coord 00155 pointArray[i][4] = (int) ( p.info2d - pointArray[i][3] * head->ncol ); // y coord 00156 } 00157 }else{ 00158 if(head->colorFormat==0){ // point cloud with gray levels 00159 for(int i=0;i<head->np;i++){ 00160 TPoint3D p=points[i]; 00161 pointArray[i][0] = p.x; 00162 pointArray[i][1] = p.y; 00163 pointArray[i][2] = p.z; 00164 pointArray[i][3] = p.info2d; 00165 pointArray[i][4] = p.info2d; 00166 pointArray[i][5] = p.info2d; 00167 } 00168 }else{ // point cloud with color rgb values 00169 for(int i=0;i<head->np;i++){ 00170 TPoint3D p=points[i]; 00171 int r,g,b; 00172 r=(p.info2d & 0xff0000)>>16; 00173 g=(p.info2d & 0xff00)>>8; 00174 b=(p.info2d & 0xff); 00175 00176 pointArray[i][0] = p.x; 00177 pointArray[i][1] = p.y; 00178 pointArray[i][2] = p.z; 00179 pointArray[i][3] = r; 00180 pointArray[i][4] = g; 00181 pointArray[i][5] = b; 00182 } 00183 } 00184 } 00185 }
|
|
pixel array of reference image
Definition at line 121 of file filereader.h. Referenced by RefImgWidget::paintGL(), and readFile(). |
|
array for 3d points
Definition at line 122 of file filereader.h. Referenced by Point3dWidget::paintGL(), and readFile(). |