DGtal  0.9.3beta
Public Member Functions | Data Fields
DGtal::Viewer3D< Space, KSpace >::GLTextureImage Struct Reference
Collaboration diagram for DGtal::Viewer3D< Space, KSpace >::GLTextureImage:
[legend]

Public Member Functions

 ~GLTextureImage ()
 
 GLTextureImage (const GLTextureImage &aGLImg)
 
 GLTextureImage (const typename Viewer3D< Space, KSpace >::TextureImage &aGSImage)
 

Data Fields

RealPoint point1
 
RealPoint point2
 
RealPoint point3
 
RealPoint point4
 
Viewer3D< Space, KSpace >::ImageDirection myDirection
 
unsigned int myImageWidth
 
unsigned int myImageHeight
 
unsigned int myBufferWidth
 
unsigned int myBufferHeight
 
GLuint myTextureName
 
Viewer3D< Space, KSpace >::TextureMode myMode
 
unsigned char * myTextureImageBufferGS
 
unsigned char * myTextureImageBufferRGB
 
double vectNormal [3]
 
double myTextureFitX
 
double myTextureFitY
 

Detailed Description

template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
struct DGtal::Viewer3D< Space, KSpace >::GLTextureImage

Used to display in OPENGL an image as a textured quad image.

Definition at line 1038 of file Viewer3D.h.

Constructor & Destructor Documentation

template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
DGtal::Viewer3D< Space, KSpace >::GLTextureImage::~GLTextureImage ( )
inline

Definition at line 1065 of file Viewer3D.h.

References DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureImageBufferGS, and DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureImageBufferRGB.

1066  {
1067  if(myMode== 1)
1068  {
1069  if(myTextureImageBufferGS!=0)
1070  delete [] myTextureImageBufferGS;
1071  }
1072  if(myMode== Viewer3D<Space, KSpace>::RGBMode)
1073  {
1075  delete [] myTextureImageBufferRGB;
1076  }
1077 
1078  }
Viewer3D< Space, KSpace >::TextureMode myMode
Definition: Viewer3D.h:1053
unsigned char * myTextureImageBufferGS
Definition: Viewer3D.h:1054
unsigned char * myTextureImageBufferRGB
Definition: Viewer3D.h:1055
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
DGtal::Viewer3D< Space, KSpace >::GLTextureImage::GLTextureImage ( const GLTextureImage aGLImg)
inline

Definition at line 1081 of file Viewer3D.h.

References DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myBufferWidth, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myDirection, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myImageHeight, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myImageWidth, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureImageBufferGS, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureImageBufferRGB, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point1, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point2, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point3, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point4, and DGtal::Viewer3D< Space, KSpace >::GLTextureImage::vectNormal.

1081  : myBufferWidth(aGLImg.myBufferWidth),
1082  myBufferHeight(aGLImg.myBufferHeight),
1083  myTextureName(aGLImg.myTextureName),
1084  myMode(aGLImg.myMode),
1085  myTextureFitX(aGLImg.myTextureFitX),
1086  myTextureFitY(aGLImg.myTextureFitY)
1087 
1088  {
1089  point1[0]=aGLImg.point1[0]; point1[1]=aGLImg.point1[1]; point1[2]=aGLImg.point1[2];
1090  point2[0]=aGLImg.point2[0]; point2[1]=aGLImg.point2[1]; point2[2]=aGLImg.point2[2];
1091  point3[0]=aGLImg.point3[0]; point3[1]=aGLImg.point3[1]; point3[2]=aGLImg.point3[2];
1092  point4[0]=aGLImg.point4[0]; point4[1]=aGLImg.point4[1]; point4[2]=aGLImg.point4[2];
1093  myImageWidth=aGLImg.myImageWidth; myImageHeight=aGLImg.myImageHeight;
1094  myDirection = aGLImg.myDirection;
1095  vectNormal[0]=aGLImg.vectNormal[0];
1096  vectNormal[1]=aGLImg.vectNormal[1];
1097  vectNormal[2]=aGLImg.vectNormal[2];
1098 
1099  if(myMode== 1)
1100  {
1101  myTextureImageBufferGS = new unsigned char [myBufferHeight*myBufferWidth];
1102  for(unsigned int i=0; i<myBufferHeight*myBufferWidth;i++)
1103  {
1104  myTextureImageBufferGS[i]=aGLImg.myTextureImageBufferGS[i];
1105  }
1106  }else if(myMode==Viewer3D<Space, KSpace>::RGBMode)
1107  {
1108  myTextureImageBufferRGB = new unsigned char [3*myBufferHeight*myBufferWidth];
1109  for(unsigned int i=0; i<3*myBufferHeight*myBufferWidth;i+=3)
1110  {
1111  myTextureImageBufferRGB[i]=aGLImg.myTextureImageBufferRGB[i];
1112  myTextureImageBufferRGB[i+1]=aGLImg.myTextureImageBufferRGB[i+1];
1113  myTextureImageBufferRGB[i+2]=aGLImg.myTextureImageBufferRGB[i+2];
1114  }
1115  }
1116  }
Viewer3D< Space, KSpace >::ImageDirection myDirection
Definition: Viewer3D.h:1046
Viewer3D< Space, KSpace >::TextureMode myMode
Definition: Viewer3D.h:1053
unsigned char * myTextureImageBufferGS
Definition: Viewer3D.h:1054
unsigned char * myTextureImageBufferRGB
Definition: Viewer3D.h:1055
RealPoint point1
coordinates
Definition: Viewer3D.h:1041
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
DGtal::Viewer3D< Space, KSpace >::GLTextureImage::GLTextureImage ( const typename Viewer3D< Space, KSpace >::TextureImage aGSImage)
inline

Definition at line 1120 of file Viewer3D.h.

References DGtal::Color::blue(), DGtal::Color::green(), DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myBufferHeight, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myBufferWidth, DGtal::Viewer3D< Space, KSpace >::TextureImage::myDirection, DGtal::Viewer3D< Space, KSpace >::TextureImage::myImageHeight, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myImageHeight, DGtal::Viewer3D< Space, KSpace >::TextureImage::myImageWidth, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myImageWidth, DGtal::Viewer3D< Space, KSpace >::TextureImage::myMode, DGtal::Viewer3D< Space, KSpace >::TextureImage::myTabImage, DGtal::Viewer3D< Space, KSpace >::TextureImage::point1, DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point1, DGtal::Viewer3D< Space, KSpace >::TextureImage::point2, DGtal::Viewer3D< Space, KSpace >::TextureImage::point3, DGtal::Viewer3D< Space, KSpace >::TextureImage::point4, DGtal::Color::red(), DGtal::functions::roundToUpperPowerOfTwo(), and DGtal::Viewer3D< Space, KSpace >::undefDirection.

1121  {
1122  point1[0]=aGSImage.point1[0]; point1[1]=aGSImage.point1[1]; point1[2]=aGSImage.point1[2];
1123  point2[0]=aGSImage.point2[0]; point2[1]=aGSImage.point2[1]; point2[2]=aGSImage.point2[2];
1124  point3[0]=aGSImage.point3[0]; point3[1]=aGSImage.point3[1]; point3[2]=aGSImage.point3[2];
1125  point4[0]=aGSImage.point4[0]; point4[1]=aGSImage.point4[1]; point4[2]=aGSImage.point4[2];
1126  myImageWidth=aGSImage.myImageWidth; myImageHeight=aGSImage.myImageHeight;
1127  myDirection = aGSImage.myDirection;
1128  myMode= aGSImage.myMode;
1129  vectNormal[0]= (myDirection == Viewer3D<Space, KSpace>::xDirection)? 1.0: 0.0;
1130  vectNormal[1]= (myDirection == Viewer3D<Space, KSpace>::yDirection)? -1.0: 0.0;
1131  vectNormal[2]= (myDirection == Viewer3D<Space, KSpace>::zDirection)? 1.0: 0.0;
1133  RealPoint v1 = point2-point1;
1134  RealPoint v2 = point4-point1;
1135  vectNormal[0] = v1[1]*v2[2] - v1[2]*v2[1];
1136  vectNormal[1] = v1[2]*v2[0] - v1[0]*v2[2];
1137  vectNormal[2] = v1[0]*v2[1] - v1[1]*v2[0];
1138  double norm = sqrt(vectNormal[0]*vectNormal[0]+vectNormal[1]*vectNormal[1]+vectNormal[2]*vectNormal[2]);
1139  vectNormal[0] /=norm; vectNormal[1] /=norm; vectNormal[2] /=norm;
1140  }
1141 
1144 
1145  if(myMode== 1)
1146  {
1147  myTextureImageBufferGS = new unsigned char [myBufferHeight*myBufferWidth];
1148  unsigned int pos=0;
1149  for (unsigned int i=0; i<myBufferHeight; i++)
1150  {
1151  for (unsigned int j=0; j<myBufferWidth; j++)
1152  {
1153  if(i<myImageHeight && j< myImageWidth)
1154  {
1155  myTextureImageBufferGS[pos]= aGSImage.myTabImage[i*myImageWidth+j];
1156  }else{
1157  myTextureImageBufferGS[pos]=0;
1158  }
1159  pos++;
1160  }
1161  }
1162  }else if(myMode==Viewer3D<Space, KSpace>::RGBMode)
1163  {
1164  myTextureImageBufferRGB = new unsigned char [3*myBufferHeight*myBufferWidth];
1165  unsigned int pos=0;
1166  for (unsigned int i=0; i<myBufferHeight; i++)
1167  {
1168  for (unsigned int j=0; j<myBufferWidth; j++)
1169  {
1170  if(i<myImageHeight && j< myImageWidth)
1171  {
1172  DGtal::Color aCol(aGSImage.myTabImage[i*myImageWidth+j]);
1173  myTextureImageBufferRGB[pos]= aCol.red();
1174  myTextureImageBufferRGB[pos+1]= aCol.green();
1175  myTextureImageBufferRGB[pos+2]= aCol.blue();
1176  }else{
1177  myTextureImageBufferRGB[pos]=0;
1178  myTextureImageBufferRGB[pos+1]=0;
1179  myTextureImageBufferRGB[pos+2]=0;
1180  }
1181  pos+=3;
1182  }
1183  }
1184  }
1185 
1186  myTextureFitX = 1.0-((myBufferWidth-myImageWidth)/(double)myBufferWidth);
1187  myTextureFitY = 1.0-((myBufferHeight-myImageHeight)/(double)myBufferHeight);
1188  }
Viewer3D< Space, KSpace >::ImageDirection myDirection
Definition: Viewer3D.h:1046
Viewer3D< Space, KSpace >::TextureMode myMode
Definition: Viewer3D.h:1053
unsigned char * myTextureImageBufferGS
Definition: Viewer3D.h:1054
Display::RealPoint RealPoint
Definition: Viewer3D.h:145
unsigned char * myTextureImageBufferRGB
Definition: Viewer3D.h:1055
T roundToUpperPowerOfTwo(const T &n)
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
RealPoint point1
coordinates
Definition: Viewer3D.h:1041

Field Documentation

template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
unsigned int DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myBufferHeight
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
unsigned int DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myBufferWidth
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
Viewer3D<Space, KSpace>::ImageDirection DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myDirection
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
unsigned int DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myImageHeight
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
unsigned int DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myImageWidth
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
Viewer3D<Space, KSpace>::TextureMode DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myMode

Definition at line 1053 of file Viewer3D.h.

template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
double DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureFitX

Definition at line 1060 of file Viewer3D.h.

template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
double DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureFitY

Definition at line 1061 of file Viewer3D.h.

template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
unsigned char* DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureImageBufferGS
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
unsigned char* DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureImageBufferRGB
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
GLuint DGtal::Viewer3D< Space, KSpace >::GLTextureImage::myTextureName

Definition at line 1052 of file Viewer3D.h.

template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
RealPoint DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point1

coordinates

Definition at line 1041 of file Viewer3D.h.

Referenced by DGtal::Viewer3D< Space, KSpace >::GLTextureImage::GLTextureImage().

template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
RealPoint DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point2
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
RealPoint DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point3
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
RealPoint DGtal::Viewer3D< Space, KSpace >::GLTextureImage::point4
template<typename Space = SpaceND<3>, typename KSpace = KhalimskySpaceND<3>>
double DGtal::Viewer3D< Space, KSpace >::GLTextureImage::vectNormal[3]

The documentation for this struct was generated from the following file: