DGtal  1.3.beta
Viewer3D.h
1 
17 #pragma once
18 
31 #if defined(Viewer3D_RECURSES)
32 #error Recursive header files inclusion detected in Viewer3D.h
33 #else // defined(Viewer3D_RECURSES)
34 
35 #define Viewer3D_RECURSES
36 
37 #if !defined Viewer3D_h
38 
39 #define Viewer3D_h
40 
42 // Inclusions
43 #include "DGtal/base/Common.h"
44 
45 #include <iostream>
46 #include <vector>
47 #include <algorithm>
48 #ifdef WIN32
49 #include <windows.h>
50 #endif
51 
52 #ifdef APPLE
53 /* Defined before OpenGL and GLUT includes to avoid deprecation messages */
54 #define GL_SILENCE_DEPRECATION
55 #include <OpenGL/gl.h>
56 #include <OpenGL/glu.h>
57 #else
58 #include <GL/gl.h>
59 #include <GL/glu.h>
60 #endif
61 
62 #ifdef WITH_QT5
63  #include <QApplication>
64 #else
65  #include <QtGui/qapplication.h>
66 #endif
67 
68 #include <QGLViewer/qglviewer.h>
69 #include <QGLWidget>
70 #include <QKeyEvent>
71 
72 #include "DGtal/kernel/SpaceND.h"
73 #include "DGtal/topology/KhalimskySpaceND.h"
74 #include "DGtal/base/CountedPtr.h"
75 #include "DGtal/io/Display3D.h"
76 #include "DGtal/math/BasicMathFunctions.h"
77 
78 #include "DGtal/kernel/CSpace.h"
79 
81 
82 namespace DGtal
83 {
84 
86  // class Viewer3D
133  template <typename TSpace = SpaceND<3>,
134  typename TKSpace = KhalimskySpaceND<3>>
135  class Viewer3D : public QGLViewer, public Display3D<TSpace, TKSpace>
136  {
137 
139 
140  //---------------overwritting some functions of Display3D -------------------
141 
142  // ----------------------- public types ------------------------------
143  public:
144  typedef TSpace Space;
145  typedef TKSpace KSpace;
149  typedef typename Display::RealPoint RealPoint;
151 
153  {
158  };
159 
166  struct Extension
167  {
170 
171  virtual ~Extension() = default;
172 
181  virtual bool keyPressEvent( Viewer & viewer, QKeyEvent * event )
182  {
183  boost::ignore_unused_variable_warning( viewer );
184  boost::ignore_unused_variable_warning( event );
185  return false;
186  }
187 
193  virtual void drawWithNames( Viewer & viewer )
194  {
195  boost::ignore_unused_variable_warning( viewer );
196  }
197 
203  virtual void draw( Viewer & viewer )
204  {
205  boost::ignore_unused_variable_warning( viewer );
206  }
207 
212  virtual void init( Viewer & viewer )
213  {
214  boost::ignore_unused_variable_warning( viewer );
215  }
216 
223  virtual QString helpString( const Viewer & viewer ) const
224  {
225  boost::ignore_unused_variable_warning( viewer );
226  return "";
227  }
228 
238  virtual bool postSelection( const Viewer & viewer, const QPoint & point )
239  {
240  boost::ignore_unused_variable_warning( viewer );
241  boost::ignore_unused_variable_warning( point );
242  return false;
243  }
244 
253  virtual bool mouseMoveEvent( const Viewer & viewer, QMouseEvent * event )
254  {
255  boost::ignore_unused_variable_warning( viewer );
256  boost::ignore_unused_variable_warning( event );
257  return false;
258  }
259 
268  virtual bool mousePressEvent( const Viewer & viewer, QMouseEvent * event )
269  {
270  boost::ignore_unused_variable_warning( viewer );
271  boost::ignore_unused_variable_warning( event );
272  return false;
273  }
274 
284  virtual bool mouseReleaseEvent( const Viewer & viewer, QMouseEvent * event )
285  {
286  boost::ignore_unused_variable_warning( viewer );
287  boost::ignore_unused_variable_warning( event );
288  return false;
289  }
290  };
291 
292  // ----------------------- Standard services ------------------------------
293  public:
294 
298  Viewer3D() : QGLViewer(), Display3D<Space, KSpace>(), myExtension( 0 )
299  {
300  resize( 800, 600 );
301  };
302 
307  Viewer3D( const KSpace & KSEmb )
308  : QGLViewer(), Display3D<Space, KSpace>( KSEmb ), myExtension( 0 )
309  {
310  resize(800,600);
311  }
312 
316  void setExtension( Extension * ext )
317  {
318  if ( myExtension != 0 )
319  delete myExtension;
320  myExtension = ext;
321  }
322 
326  {
327  if ( myExtension != 0 )
328  delete myExtension;
329  myExtension = 0;
330  }
331 
338  void setCameraPosition(double ax, double ay, double az)
339  {
340  camera_position[0] = ax; camera_position[1] = ay; camera_position[2] = az;
341  }
342 
349  void setCameraDirection(double ax, double ay, double az)
350  {
351  camera_direction[0] = ax; camera_direction[1] = ay; camera_direction[2] = az;
352  }
353 
360  void setCameraUpVector(double ax, double ay, double az)
361  {
362  camera_upVector[0] = ax; camera_upVector[1] = ay; camera_upVector[2] = az;
363  }
364 
370  void setNearFar(double _near, double _far)
371  {
372  ZNear = _near; ZFar = _far;
373  }
374 
384  void setGLScale(float sx, float sy, float sz)
385  {
386  myGLScaleFactorX=sx;
387  myGLScaleFactorY=sy;
388  myGLScaleFactorZ=sz;
389  // In order to have the light source rendering the same as wtih the default scale 1.
390  glEnable(GL_NORMALIZE);
391  }
392 
393 
405  void setGLDoubleRenderingMode(bool doubleSidedRendering);
406 
407 
415  void setGLMaterialShininessCoefficient(const GLfloat matShininessCoeff);
416 
417 
426  void setGLLightAmbientCoefficients(const GLfloat lightAmbientCoeffs [4]);
427 
436  void setGLLightDiffuseCoefficients(const GLfloat lightDiffuseCoeffs [4]);
437 
438 
446  void setGLLightSpecularCoefficients(const GLfloat lightSpecularCoeffs [4]);
447 
448 
449 
460  void setUseGLPointForBalls(bool useOpenGLPt);
461 
462 
470  void updateRenderingCoefficients(const RenderingMode aRenderMode, bool displayState=true);
471 
472 
477 
486  double myGLPointMinWidth = 1.5;
487  double myGLLineMinWidth = 1.5;
488  bool myAutoSaveState;
490  // define the default rendering mode of the viewer
492 
498  {
499 
508  unsigned int myDomainWidth;
510  unsigned int myDomainHeight;
514  std::string myMode;
516  std::size_t myLineSetIndex;
517 
527  template<typename TDomain>
528  Image2DDomainD3D( TDomain aDomain, ImageDirection normalDir=zDirection,
529  double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0, std::string mode= "BoundingBox")
530  {
532  myMode = mode;
533  myDirection=normalDir;
534  myDomainWidth = (aDomain.upperBound())[0]-(aDomain.lowerBound())[0]+1;
535  myDomainHeight = (aDomain.upperBound())[1]-(aDomain.lowerBound())[1]+1;
536  updateDomainOrientation(normalDir, xBottomLeft, yBottomLeft, zBottomLeft);
537  }
538 
539 
549  void updateDomainOrientation( ImageDirection normalDir,
550  double xBottomLeft, double yBottomLeft, double zBottomLeft);
551 
552 
559  void translateDomain(double xTranslation=0.0,
560  double yTranslation=0.0, double zTranslation=0.0);
561 
562  };
563 
564 
570  {
571 
576 
578 
579  unsigned int myImageWidth;
580  unsigned int myImageHeight;
581  //TODO complete desc attribute
582  unsigned int * myTabImage;
583 
585  unsigned int myIndexDomain;
587 
592  {
593  delete [] myTabImage;
594  };
595 
601  point3(img.point3), point4(img.point4),
604  myTabImage(img.myTabImage),
607  myMode(img.myMode)
608  {
609 
610  if(img.myImageHeight>0 && img.myImageWidth>0)
611  {
612  myTabImage = new unsigned int [img.myImageWidth*img.myImageHeight];
613  for(unsigned int i=0; i<img.myImageWidth*img.myImageHeight; i++)
614  {
615  myTabImage[i] = img.myTabImage[i];
616  }
617  }else
618  {
619  myTabImage=img.myTabImage;
620  }
621  };
622 
623 
624 
644  template <typename TImageType, typename TFunctor>
645 
646  TextureImage( const TImageType & image, const TFunctor &aFunctor,
647  ImageDirection normalDir=zDirection,
648  double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0,
649  TextureMode aMode= GrayScaleMode)
650  {
653  myDrawDomain=false;
654  myDirection=normalDir;
655  myImageWidth = (image.domain().upperBound())[0]-(image.domain().lowerBound())[0]+1;
656  myImageHeight = (image.domain().upperBound())[1]-(image.domain().lowerBound())[1]+1;
657  myTabImage = new unsigned int [myImageWidth*myImageHeight];
658  updateImageOrientation(normalDir, xBottomLeft, yBottomLeft, zBottomLeft);
659  myMode=aMode;
660  updateImageDataAndParam(image, aFunctor);
661  }
662 
672  void updateImageOrientation( ImageDirection normalDir,
673  double xBottomLeft, double yBottomLeft, double zBottomLeft);
674 
675 
683  void
685  RealPoint aPoint2,
686  RealPoint aPoint3,
687  RealPoint aPoint4)
688  {
689  point1 = aPoint1; point2 = aPoint2; point3 = aPoint3; point4 = aPoint4;
691  }
692 
693 
709  template <typename TImageType, typename TFunctor>
710  void updateImageDataAndParam(const TImageType & image, const TFunctor &aFunctor, double xTranslation=0.0,
711  double yTranslation=0.0, double zTranslation=0.0)
712  {
715  assert ( (image.domain().upperBound())[0]-(image.domain().lowerBound())[0]+1== static_cast<int>(myImageWidth) &&
716  (image.domain().upperBound())[1]-(image.domain().lowerBound())[1]+1== static_cast<int>(myImageHeight));
717 
718  point1[0] += xTranslation; point1[1] += yTranslation; point1[2] += zTranslation;
719  point2[0] += xTranslation; point2[1] +=yTranslation; point2[2] += zTranslation;
720  point3[0] += xTranslation; point3[1] += yTranslation; point3[2] += zTranslation;
721  point4[0] += xTranslation; point4[1] += yTranslation; point4[2] += zTranslation;
722 
723  unsigned int pos=0;
724  for(typename TImageType::Domain::ConstIterator it = image.domain().begin(), itend=image.domain().end();
725  it!=itend; ++it)
726  {
727  myTabImage[pos]= aFunctor(image(*it));
728  pos++;
729  }
730  }
731 
735  std::string className() const;
736 
737  private:
743  {};
744  };
745 
752 
753 
760 
761 
765  void sortSurfelFromCamera();
766 
770  void sortTriangleFromCamera();
771 
775  void sortQuadFromCamera();
776 
780  void sortPolygonFromCamera();
781 
782 
783 
784  template <typename TDrawableWithViewer3D>
793  Viewer3D<Space, KSpace> & operator<< ( const TDrawableWithViewer3D & object );
794 
795 
796 
797  // ----------------------- Interface --------------------------------------
798  public:
799 
804  void selfDisplay ( std::ostream & out ) const;
805 
810  bool isValid() const;
811 
812 
813 
814  virtual unsigned int getCurrentDomainNumber();
815 
816  virtual unsigned int getCurrentGLImageNumber();
817 
818 
824  virtual void paintGL();
825 
826 
833  virtual void show();
834 
835 
841  void addTextureImage(const TextureImage &image);
842 
843 
856  template <typename TImageType, typename TFunctor>
857 
858  void updateTextureImage(unsigned int imageIndex, const TImageType & image, const TFunctor & aFunctor,
859  double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0,
860  double rotationAngle=0.0, ImageDirection rotationDir=zDirection);
861 
862 
863 
864 
874  void updateOrientationTextureImage(unsigned int imageIndex,
875  double xPosition, double yPosition,
876  double zPosition, ImageDirection newDirection);
877 
878 
879 
888  void updateEmbeddingTextureImage(unsigned int anImageIndex,
889  typename Space::Point aPoint1, typename Space::Point aPoint2,
890  typename Space::Point aPoint3, typename Space::Point aPoint4);
891 
892 
893 
900  template<typename TDomain>
901  void addImage2DDomainD3D(const TDomain &anImageDomain, std::string mode,
902  const DGtal::Color &aColor=DGtal::Color::Red );
903 
904 
913  void updateAn2DDomainOrientation(unsigned int imageIndex,
914  double xPosition, double yPosition,
915  double zPosition, ImageDirection newDirection);
916 
924  void translateAn2DDomain(unsigned int domainIndex, double xTranslation,
925  double yTranslation, double zTranslation);
926 
933  std::vector<typename DGtal::Viewer3D< Space , KSpace >::LineD3D>
934  compute2DDomainLineRepresentation( Image2DDomainD3D &anImageDomain, double delta );
935 
941  std::vector<typename DGtal::Viewer3D< Space , KSpace >::LineD3D>
942  compute2DDomainLineRepresentation( Image2DDomainD3D &anImageDomain);
943 
944 
953  template < typename TContainer >
955  double angleRotation, ImageDirection dirRotation);
956 
957 
958 
967  void rotateDomain(Image2DDomainD3D &anDom, double angle, ImageDirection rotationDir);
968 
969 
970 
971 
972 
973 
974  // ------------------------- Protected Datas ------------------------------
975  private:
976 
977 
978 
979  public:
981  void drawSomeLight( GLenum light ) const
982  {
983  QGLViewer::drawLight( light );
984  }
986  void drawSomeLight( GLenum light, float zoom ) const
987  {
988  QGLViewer::drawLight( light, zoom );
989  }
990 
991  // ------------------------- Hidden services ------------------------------
992  // protected:
993 
1000  void updateList( bool needToUpdateBoundingBox = true );
1001 
1006  void glDrawGLBall( const typename Viewer3D<Space, KSpace>::BallD3D & aBall );
1007 
1025  virtual void keyPressEvent( QKeyEvent * e );
1026 
1032  virtual void mouseMoveEvent( QMouseEvent * e );
1033 
1039  virtual void mousePressEvent( QMouseEvent * e );
1040 
1046  virtual void mouseReleaseEvent( QMouseEvent * e );
1047 
1052  {
1053  qglviewer::Vec posCam;
1055  typename Viewer3D<Space, KSpace>::CubeD3D s2 )
1056  {
1057  double dist1 =
1058  sqrt( ( posCam.x - s1.center[ 0 ] ) * ( posCam.x - s1.center[ 0 ] ) +
1059  ( posCam.y - s1.center[ 1 ] ) * ( posCam.y - s1.center[ 1 ] ) +
1060  ( posCam.z - s1.center[ 2 ] ) * ( posCam.z - s1.center[ 2 ] ) );
1061  double dist2 =
1062  sqrt( ( posCam.x - s2.center[ 0 ] ) * ( posCam.x - s2.center[ 0 ] ) +
1063  ( posCam.y - s2.center[ 1 ] ) * ( posCam.y - s2.center[ 1 ] ) +
1064  ( posCam.z - s2.center[ 2 ] ) * ( posCam.z - s2.center[ 2 ] ) );
1065  return dist1 > dist2;
1066  }
1067  };
1068 
1069 
1074  {
1075  qglviewer::Vec posCam;
1078  {
1079  qglviewer::Vec center1 ( ( t1.point1[0]+t1.point2[0]+t1.point3[0] ) /3.0, ( t1.point1[1]+t1.point2[1]+t1.point3[1] ) /3.0, ( t1.point1[2]+t1.point2[2]+t1.point3[2] ) /3.0 );
1080  qglviewer::Vec center2 ( ( t2.point1[0]+t2.point2[0]+t2.point3[0] ) /3.0, ( t2.point1[1]+t2.point2[1]+t2.point3[1] ) /3.0, ( t2.point1[2]+t2.point2[2]+t2.point3[2] ) /3.0 );
1081  double dist1= sqrt ( ( posCam.x-center1.x ) * ( posCam.x-center1.x ) + ( posCam.y-center1.y ) * ( posCam.y-center1.y ) + ( posCam.z-center1.z ) * ( posCam.z-center1.z ) );
1082  double dist2= sqrt ( ( posCam.x-center2.x ) * ( posCam.x-center2.x ) + ( posCam.y-center2.y ) * ( posCam.y-center2.y ) + ( posCam.z-center2.z ) * ( posCam.z-center2.z ) );
1083 
1084  return dist1>dist2;
1085  }
1086  };
1087 
1092  {
1093  qglviewer::Vec posCam;
1095  typename Viewer3D<Space,KSpace>::QuadD3D q2 )
1096  {
1097 
1098  qglviewer::Vec center1 ( ( q1.point1[0]+q1.point2[0]+q1.point3[0]+q1.point4[0] ) /4.0, ( q1.point1[1]+q1.point2[1]+q1.point3[1]+q1.point4[1] ) /4.0, ( q1.point1[2]+q1.point2[2]+q1.point3[2]+q1.point4[2] ) /4.0 );
1099  qglviewer::Vec center2 ( ( q2.point1[0]+q2.point2[0]+q2.point3[0]+q2.point4[0] ) /4.0, ( q2.point1[1]+q2.point2[1]+q2.point3[1]+q2.point4[1] ) /4.0, ( q2.point1[2]+q2.point2[2]+q2.point3[2]+q2.point4[2] ) /4.0 );
1100 
1101  double dist1= sqrt ( ( posCam.x-center1.x ) * ( posCam.x-center1.x ) + ( posCam.y-center1.y ) * ( posCam.y-center1.y ) + ( posCam.z-center1.z ) * ( posCam.z-center1.z ) );
1102  double dist2= sqrt ( ( posCam.x-center2.x ) * ( posCam.x-center2.x ) + ( posCam.y-center2.y ) * ( posCam.y-center2.y ) + ( posCam.z-center2.z ) * ( posCam.z-center2.z ) );
1103  return dist1>dist2;
1104  }
1105  };
1106 
1111  {
1112  qglviewer::Vec posCam;
1115  {
1116  double c1x=0.0, c1y=0.0, c1z=0.0;
1117  double c2x=0.0, c2y=0.0, c2z=0.0;
1118  for(unsigned int i=0; i< q1.vertices.size(); i++){
1119  c1x+=q1.vertices.at(i)[0];
1120  c1y+=q1.vertices.at(i)[1];
1121  c1z+=q1.vertices.at(i)[2];
1122  }
1123  for(unsigned int i=0; i< q2.vertices.size(); i++){
1124  c2x+=q2.vertices.at(i)[0];
1125  c2y+=q2.vertices.at(i)[1];
1126  c2z+=q2.vertices.at(i)[2];
1127  }
1128 
1129  qglviewer::Vec center1 ( c1x/(double)q1.vertices.size(),c1y/(double)q1.vertices.size(), c1z/(double)q1.vertices.size() );
1130  qglviewer::Vec center2 ( c2x/(double)q2.vertices.size(),c2y/(double)q2.vertices.size(), c2z/(double)q2.vertices.size() );
1131 
1132  double dist1= sqrt ( ( posCam.x-center1.x ) * ( posCam.x-center1.x ) + ( posCam.y-center1.y ) * ( posCam.y-center1.y ) + ( posCam.z-center1.z ) * ( posCam.z-center1.z ) );
1133  double dist2= sqrt ( ( posCam.x-center2.x ) * ( posCam.x-center2.x ) + ( posCam.y-center2.y ) * ( posCam.y-center2.y ) + ( posCam.z-center2.z ) * ( posCam.z-center2.z ) );
1134  return dist1>dist2;
1135  }
1136  };
1137 
1138 
1139 
1143  virtual void drawWithNames();
1144 
1148  virtual void draw();
1149 
1153  virtual void init();
1154 
1158  virtual QString helpString() const;
1159 
1164  virtual void postSelection ( const QPoint& point );
1165 
1166 
1167 
1177  virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
1178 
1179 
1190  virtual void initFromDOMElement(const QDomElement& element);
1191 
1192 
1200  protected: virtual void closeEvent ( QCloseEvent * e );
1201 
1202 
1203 
1204  // ------------------------- Internals ------------------------------------
1205  private:
1206 
1207 
1213  {
1219 
1221  unsigned int myImageWidth;
1222  unsigned int myImageHeight;
1223 
1224  unsigned int myBufferWidth;
1225  unsigned int myBufferHeight;
1228  unsigned char * myTextureImageBufferGS;
1229  unsigned char * myTextureImageBufferRGB;
1230  double vectNormal[3];
1231 
1232 
1233  // By definition in OpenGL the image size of texture should power of 2
1236 
1237 
1238  // Destructor
1240  {
1241  if(myMode== 1)
1242  {
1243  if(myTextureImageBufferGS!=0)
1244  delete [] myTextureImageBufferGS;
1245  }
1247  {
1249  delete [] myTextureImageBufferRGB;
1250  }
1251 
1252  }
1253 
1254  //Copy constructor from a GLTextureImage
1257  myTextureName(aGLImg.myTextureName),
1258  myMode(aGLImg.myMode),
1259  myTextureFitX(aGLImg.myTextureFitX),
1261 
1262  {
1263  point1[0]=aGLImg.point1[0]; point1[1]=aGLImg.point1[1]; point1[2]=aGLImg.point1[2];
1264  point2[0]=aGLImg.point2[0]; point2[1]=aGLImg.point2[1]; point2[2]=aGLImg.point2[2];
1265  point3[0]=aGLImg.point3[0]; point3[1]=aGLImg.point3[1]; point3[2]=aGLImg.point3[2];
1266  point4[0]=aGLImg.point4[0]; point4[1]=aGLImg.point4[1]; point4[2]=aGLImg.point4[2];
1268  myDirection = aGLImg.myDirection;
1269  vectNormal[0]=aGLImg.vectNormal[0];
1270  vectNormal[1]=aGLImg.vectNormal[1];
1271  vectNormal[2]=aGLImg.vectNormal[2];
1272 
1273  if(myMode== 1)
1274  {
1275  myTextureImageBufferGS = new unsigned char [myBufferHeight*myBufferWidth];
1276  for(unsigned int i=0; i<myBufferHeight*myBufferWidth;i++)
1277  {
1279  }
1281  {
1282  myTextureImageBufferRGB = new unsigned char [3*myBufferHeight*myBufferWidth];
1283  for(unsigned int i=0; i<3*myBufferHeight*myBufferWidth;i+=3)
1284  {
1288  }
1289  }
1290  }
1291 
1292 
1293  //Copy constructor from a TextureImage
1295  {
1296  point1[0]=aGSImage.point1[0]; point1[1]=aGSImage.point1[1]; point1[2]=aGSImage.point1[2];
1297  point2[0]=aGSImage.point2[0]; point2[1]=aGSImage.point2[1]; point2[2]=aGSImage.point2[2];
1298  point3[0]=aGSImage.point3[0]; point3[1]=aGSImage.point3[1]; point3[2]=aGSImage.point3[2];
1299  point4[0]=aGSImage.point4[0]; point4[1]=aGSImage.point4[1]; point4[2]=aGSImage.point4[2];
1300  myImageWidth=aGSImage.myImageWidth; myImageHeight=aGSImage.myImageHeight;
1301  myDirection = aGSImage.myDirection;
1302  myMode= aGSImage.myMode;
1307  RealPoint v1 = point2-point1;
1308  RealPoint v2 = point4-point1;
1309  vectNormal[0] = v1[1]*v2[2] - v1[2]*v2[1];
1310  vectNormal[1] = v1[2]*v2[0] - v1[0]*v2[2];
1311  vectNormal[2] = v1[0]*v2[1] - v1[1]*v2[0];
1312  double norm = sqrt(vectNormal[0]*vectNormal[0]+vectNormal[1]*vectNormal[1]+vectNormal[2]*vectNormal[2]);
1313  vectNormal[0] /=norm; vectNormal[1] /=norm; vectNormal[2] /=norm;
1314  }
1315 
1318 
1319  if(myMode== 1)
1320  {
1321  myTextureImageBufferGS = new unsigned char [myBufferHeight*myBufferWidth];
1322  unsigned int pos=0;
1323  for (unsigned int i=0; i<myBufferHeight; i++)
1324  {
1325  for (unsigned int j=0; j<myBufferWidth; j++)
1326  {
1327  if(i<myImageHeight && j< myImageWidth)
1328  {
1329  myTextureImageBufferGS[pos]= aGSImage.myTabImage[i*myImageWidth+j];
1330  }else{
1331  myTextureImageBufferGS[pos]=0;
1332  }
1333  pos++;
1334  }
1335  }
1337  {
1338  myTextureImageBufferRGB = new unsigned char [3*myBufferHeight*myBufferWidth];
1339  unsigned int pos=0;
1340  for (unsigned int i=0; i<myBufferHeight; i++)
1341  {
1342  for (unsigned int j=0; j<myBufferWidth; j++)
1343  {
1344  if(i<myImageHeight && j< myImageWidth)
1345  {
1346  DGtal::Color aCol(aGSImage.myTabImage[i*myImageWidth+j]);
1347  myTextureImageBufferRGB[pos]= aCol.red();
1348  myTextureImageBufferRGB[pos+1]= aCol.green();
1349  myTextureImageBufferRGB[pos+2]= aCol.blue();
1350  }else{
1351  myTextureImageBufferRGB[pos]=0;
1352  myTextureImageBufferRGB[pos+1]=0;
1353  myTextureImageBufferRGB[pos+2]=0;
1354  }
1355  pos+=3;
1356  }
1357  }
1358  }
1359 
1362  }
1363  };
1364 
1365 
1366 
1372  typedef typename std::vector<typename Viewer3D<Space, KSpace>::CubeD3D> VectorCubes;
1373  typedef typename std::vector<typename Viewer3D<Space, KSpace>::QuadD3D> VectorQuad;
1374  typedef typename std::vector<typename Viewer3D<Space, KSpace>::LineD3D> VectorLine;
1375  typedef typename std::vector<typename Viewer3D<Space, KSpace>::BallD3D> VectorBall;
1376  typedef typename std::vector<typename Viewer3D<Space, KSpace>::TriangleD3D> VectorTriangle;
1377  typedef typename std::vector<typename Viewer3D<Space, KSpace>::PolygonD3D> VectorPolygon;
1378  typedef typename std::vector<typename Viewer3D<Space, KSpace>::TextureImage> VectorTextureImage;
1379 
1380 
1381  typedef typename VectorCubes::iterator ItCube;
1382 
1383 
1393  void glCreateListCubesMaps(const typename Display3D<Space, KSpace>::CubesMap &aCubeMap, unsigned int idList);
1394 
1395 
1396 
1402  void glCreateListQuadD3D(const VectorQuad &aVectQuad, unsigned int idList);
1403 
1404 
1410  void glCreateListLines(const VectorLine &aVectLine, unsigned int idList);
1411 
1412 
1418  void glCreateListBalls(const VectorBall &aVectBall, unsigned int idList);
1419 
1420 
1430  void glCreateListQuadMaps(const typename Display3D<Space, KSpace>::QuadsMap &aQuadMap, unsigned int idList);
1431 
1432 
1442  void glCreateListQuadMapsWired(const typename Display3D<Space, KSpace>::QuadsMap &aQuadMap, unsigned int idList);
1443 
1444 
1453  void glCreateListTriangles(const std::vector<VectorTriangle> &aVectTriangle, unsigned int idList);
1454 
1455 
1464  void glCreateListTrianglesWired(const std::vector<VectorTriangle> &aVectTriangle, unsigned int idList);
1465 
1466 
1475  void glCreateListPolygons(const std::vector<VectorPolygon> &aVectPolygon, unsigned int idList);
1476 
1477 
1486  void glCreateListPolygonsWired(const std::vector<VectorPolygon> &aVectPolygon, unsigned int idList);
1487 
1488 
1494  void glUpdateTextureImages(const VectorTextureImage &aVectImage);
1495 
1496 
1503  void glUpdateLightRenderingMode() const;
1504 
1509  void glUpdateBackground() ;
1510 
1518 
1526 
1527 
1528 
1529  public:
1541  template<typename TImageORDomain>
1542  static
1543  void
1544  rotateImageVertex(TImageORDomain &anImageOrDom, double angle, ImageDirection rotationDir){
1545  double xB = (anImageOrDom.point1[0]+anImageOrDom.point2[0]+anImageOrDom.point3[0]+anImageOrDom.point4[0])/4.0;
1546  double yB = (anImageOrDom.point1[1]+anImageOrDom.point2[1]+anImageOrDom.point3[1]+anImageOrDom.point4[1])/4.0;
1547  double zB = (anImageOrDom.point1[2]+anImageOrDom.point2[2]+anImageOrDom.point3[2]+anImageOrDom.point4[2])/4.0;
1548  rotatePoint( anImageOrDom.point1[0], anImageOrDom.point1[1], anImageOrDom.point1[2], xB, yB, zB, angle, rotationDir);
1549  rotatePoint( anImageOrDom.point2[0], anImageOrDom.point2[1], anImageOrDom.point2[2], xB, yB, zB, angle, rotationDir);
1550  rotatePoint( anImageOrDom.point3[0], anImageOrDom.point3[1], anImageOrDom.point3[2], xB, yB, zB, angle, rotationDir);
1551  rotatePoint( anImageOrDom.point4[0], anImageOrDom.point4[1], anImageOrDom.point4[2], xB, yB, zB, angle, rotationDir);
1552 
1553  }
1554 
1568  template <typename TValues>
1569  static
1570  void rotatePoint(TValues &x, TValues &y, TValues &z,
1571  double cx, double cy, double cz,
1572  double rotationAngle, ImageDirection rotationDir);
1573 
1574 
1575 
1576 
1577 
1578  // ------------------------- Private Datas --------------------------------
1579  private:
1580 
1582  //GLuint myListToAff;
1583 
1586 
1589 
1593 
1596 
1599 
1601 
1602  unsigned int myNbListe;
1603  unsigned int myNbLineSetList;
1604  unsigned int myNbBallSetList;
1605  unsigned int myNbPrismSetList;
1606 
1609  unsigned char mySelectionColorShift = 150;
1610 
1616  std::vector<GLTextureImage> myVectTextureImage;
1617 
1619 
1620  double camera_position[3];
1621  double camera_direction[3];
1622  double camera_upVector[3];
1623 
1624  bool myLightPositionFixToCamera = true; // when false the light position is fix according to the scene.
1625  double myLightTheta;
1626  double myLightPhi;
1627  double myLightR;
1628  GLfloat myLightPosition [4] = {0.0f, 0.0f, 1.0f, 1.0f}; // the light position in cartesian coordinate
1629  GLfloat myLightPositionRefCameraDefault [3] = {-100.0f, 100.0f, 0.0f}; // the light default position according to the camera position
1630  GLfloat myLightPositionRefCamera [3] = {0.0f, 0.0f, 0.0f}; // the light position according to the camera position
1631  GLfloat myMaterialShininessCoeff[1] = {50.0f} ; // the material shininess coefficient used in opengl rendering
1632  GLfloat myMaterialSpecularCoeffs[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; // the light specular coefficients used in opengl rendering
1633  GLfloat myLightSpecularCoeffs[4] = { 0.3f, 0.3f, 0.3f, 1.0f }; // the light specular coefficients used in opengl rendering
1634  GLfloat myLightAmbientCoeffs[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; // the material ambient coefficients used in opengl rendering
1635  GLfloat myLightDiffuseCoeffs[4] = { 0.7f, 0.7f, 0.7f, 1.0f }; // the material diffuse coefficients used in opengl rendering
1636 
1637  const GLfloat myDefaultRenderSpec = 0.3f; // default specular coefficients for default mode rendering
1638  const GLfloat myDefaultRenderDiff = 0.7f; // default diffuse coefficients for metallic mode rendering
1639  const GLfloat myLambertRenderSpec = 0.0f; // default specular coefficients for default mode rendering
1640  const GLfloat myLambertRenderDiff = 0.9f; // default diffuse coefficients for metallic mode rendering
1641  const GLfloat myMetallicRenderSpec = 0.5f; // default specular coefficients for metallic mode rendering
1642  const GLfloat myMetallicRenderDiff = 0.5f; // default diffuse coefficients for metallic mode rendering
1643  const GLfloat myPlasticRenderSpec = 0.8f; // default specular coefficients for platic mode rendering
1644  const GLfloat myPlasticRenderDiff = 0.2f; // default diffuse coefficients for platic mode rendering
1645 
1646  bool myUseGLPointsForBalls = false; // to display balls with GL points (instead real ball)
1647 
1648  double ZNear;
1649  double ZFar;
1650 
1651  //the default width of the mesh line
1653 
1654  // To apply openGL ajustment only on visualisation
1655  float myGLScaleFactorX=1.0;
1656  float myGLScaleFactorY=1.0;
1657  float myGLScaleFactorZ=1.0;
1658 
1659  // Used to apply interactive light rotation
1664 
1666  std::vector<TextureImage> myGSImageList;
1668  std::vector<Image2DDomainD3D> myImageDomainList;
1670  Extension * myExtension;
1671 
1672  }; // end of class Viewer3D
1673 
1674  template <typename TSpace, typename TKSpace>
1681  std::ostream & operator<<( std::ostream & out,
1682  const Viewer3D<TSpace, TKSpace> & object );
1683 } // namespace DGtal
1684 
1685 
1687 // Includes inline functions.
1688 #include "DGtal/io/viewers/Viewer3D.ih"
1689 
1690 // //
1692 
1693 #endif // !defined Viewer3D_h
1694 
1695 #undef Viewer3D_RECURSES
1696 #endif // else defined(Viewer3D_RECURSES)
DGtal::Viewer3D::TextureImage::point1
RealPoint point1
Definition: Viewer3D.h:572
DGtal::Viewer3D::SelectCallbackFct
Display::SelectCallbackFct SelectCallbackFct
Definition: Viewer3D.h:148
DGtal::Viewer3D::GLTextureImage::myTextureName
GLuint myTextureName
Definition: Viewer3D.h:1226
ConstIterator
MyDigitalSurface::ConstIterator ConstIterator
Definition: greedy-plane-segmentation-ex2.cpp:93
DGtal::Viewer3D::Space
TSpace Space
Definition: Viewer3D.h:144
DGtal::Viewer3D::sortTriangleFromCamera
void sortTriangleFromCamera()
DGtal::Viewer3D::TextureImage::TextureImage
TextureImage()
Definition: Viewer3D.h:742
DGtal::Viewer3D::TextureImage::TextureImage
TextureImage(const TextureImage &img)
Copy constructor (needed due to myTabImage)
Definition: Viewer3D.h:600
DGtal::Viewer3D::setCameraPosition
void setCameraPosition(double ax, double ay, double az)
Definition: Viewer3D.h:338
DGtal::Viewer3D::myGLScaleFactorY
float myGLScaleFactorY
Definition: Viewer3D.h:1656
DGtal::Viewer3D::myPolygonSetListWiredId
GLuint myPolygonSetListWiredId
Definition: Viewer3D.h:1588
DGtal::Viewer3D::rotateLineD3D
void rotateLineD3D(typename DGtal::Display3D< Space, KSpace >::LineD3D &aLine, DGtal::PointVector< 3, int, TContainer > pt, double angleRotation, ImageDirection dirRotation)
DGtal::Viewer3D::RGBMode
@ RGBMode
Definition: Viewer3D.h:476
DGtal::Viewer3D::CompFarthestVoxelFromCamera::posCam
qglviewer::Vec posCam
Definition: Viewer3D.h:1053
DGtal::Viewer3D::Extension::mouseReleaseEvent
virtual bool mouseReleaseEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:284
image
Image image(domain)
DGtal::Viewer3D::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
DGtal::Viewer3D::myCubesMapId
GLuint myCubesMapId
Definition: Viewer3D.h:1597
DGtal::concepts::CSpace
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:105
DGtal::Display3D
Aim: This semi abstract class defines the stream mechanism to display 3d primitive (like BallVector,...
Definition: Common.h:158
DGtal::Viewer3D::glCreateListPolygons
void glCreateListPolygons(const std::vector< VectorPolygon > &aVectPolygon, unsigned int idList)
DGtal::Viewer3D::glUpdateLightRenderingMode
void glUpdateLightRenderingMode() const
DGtal::Display3D::getSelectCallback3D
SelectCallbackFct getSelectCallback3D(DGtal::int32_t aName, void *&data) const
DGtal::Viewer3D::Extension::Viewer
Viewer3D< Space, KSpace > Viewer
The associated viewer.
Definition: Viewer3D.h:169
DGtal::Viewer3D::camera_direction
double camera_direction[3]
camera direction
Definition: Viewer3D.h:1621
DGtal::Viewer3D::VectorTriangle
std::vector< typename Viewer3D< Space, KSpace >::TriangleD3D > VectorTriangle
Definition: Viewer3D.h:1376
DGtal::Viewer3D::myLineSetListId
GLuint myLineSetListId
Definition: Viewer3D.h:1590
DGtal::Viewer3D::glDrawGLBall
void glDrawGLBall(const typename Viewer3D< Space, KSpace >::BallD3D &aBall)
DGtal::Viewer3D::GLTextureImage::myDirection
Viewer3D< Space, KSpace >::ImageDirection myDirection
Definition: Viewer3D.h:1220
DGtal::Viewer3D::Extension::postSelection
virtual bool postSelection(const Viewer &viewer, const QPoint &point)
Definition: Viewer3D.h:238
DGtal::Viewer3D::myQuadsMapWiredId
GLuint myQuadsMapWiredId
Definition: Viewer3D.h:1595
DGtal::Viewer3D::undefDirection
@ undefDirection
Definition: Viewer3D.h:474
DGtal::Viewer3D::myNbListe
unsigned int myNbListe
number of lists in myListToAff
Definition: Viewer3D.h:1602
DGtal::Viewer3D::glUpdateTextureImages
void glUpdateTextureImages(const VectorTextureImage &aVectImage)
DGtal::Viewer3D::GLTextureImage::myBufferWidth
unsigned int myBufferWidth
Definition: Viewer3D.h:1224
DGtal::Viewer3D::myLightPositionRefCamera
GLfloat myLightPositionRefCamera[3]
Definition: Viewer3D.h:1630
DGtal::Viewer3D::VectorTextureImage
std::vector< typename Viewer3D< Space, KSpace >::TextureImage > VectorTextureImage
Definition: Viewer3D.h:1378
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
DGtal::Viewer3D::CompFarthestVoxelFromCamera::operator()
bool operator()(typename Viewer3D< Space, KSpace >::CubeD3D s1, typename Viewer3D< Space, KSpace >::CubeD3D s2)
Definition: Viewer3D.h:1054
DGtal::Viewer3D::myAutoSaveState
bool myAutoSaveState
flag to save automatically or not the Viewer3d state when closing the viewer
Definition: Viewer3D.h:489
DGtal::Viewer3D::drawSomeLight
void drawSomeLight(GLenum light) const
To call the protected method drawLight.
Definition: Viewer3D.h:981
DGtal::Viewer3D::myLambertRenderSpec
const GLfloat myLambertRenderSpec
Definition: Viewer3D.h:1639
DGtal::Viewer3D::CompFarthestPolygonFromCamera
Definition: Viewer3D.h:1110
DGtal::Viewer3D::Image2DDomainD3D
Definition: Viewer3D.h:497
DGtal::Viewer3D::TextureImage::myDirection
ImageDirection myDirection
Definition: Viewer3D.h:577
DGtal::Viewer3D::Image2DDomainD3D::myLineSetIndex
std::size_t myLineSetIndex
the index of the line of the domain in the lineSetList of the viewer
Definition: Viewer3D.h:516
DGtal::Viewer3D::sortPolygonFromCamera
void sortPolygonFromCamera()
DGtal::Viewer3D::TextureImage::TextureImage
TextureImage(const TImageType &image, const TFunctor &aFunctor, ImageDirection normalDir=zDirection, double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0, TextureMode aMode=GrayScaleMode)
Definition: Viewer3D.h:646
DGtal::Viewer3D::GrayScaleMode
@ GrayScaleMode
Definition: Viewer3D.h:476
DGtal::Viewer3D::myNbLineSetList
unsigned int myNbLineSetList
Definition: Viewer3D.h:1603
DGtal::Viewer3D::TextureImage
Definition: Viewer3D.h:569
DGtal::Viewer3D::Image2DDomainD3D::point4
RealPoint point4
Definition: Viewer3D.h:504
DGtal::Viewer3D::myExtension
Extension * myExtension
Stored a possible extension to the viewer (pointer owned).
Definition: Viewer3D.h:1670
DGtal::Viewer3D::myLightAmbientCoeffs
GLfloat myLightAmbientCoeffs[4]
Definition: Viewer3D.h:1634
DGtal::Viewer3D::Extension::mouseMoveEvent
virtual bool mouseMoveEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:253
DGtal::Viewer3D::addImage2DDomainD3D
void addImage2DDomainD3D(const TDomain &anImageDomain, std::string mode, const DGtal::Color &aColor=DGtal::Color::Red)
DGtal::Viewer3D::domElement
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
Overload of the QGLViewer method which returns an XML QDomElement representing the QGLViewer state....
DGtal::functions::roundToUpperPowerOfTwo
T roundToUpperPowerOfTwo(const T &n)
Definition: BasicMathFunctions.h:102
DGtal::Viewer3D::VectorQuad
std::vector< typename Viewer3D< Space, KSpace >::QuadD3D > VectorQuad
Definition: Viewer3D.h:1373
DGtal::Viewer3D::myPlasticRenderSpec
const GLfloat myPlasticRenderSpec
Definition: Viewer3D.h:1643
DGtal::Viewer3D::TextureImage::myImageWidth
unsigned int myImageWidth
direction of the image (x, y or z axe)
Definition: Viewer3D.h:579
DGtal::Viewer3D::Extension::draw
virtual void draw(Viewer &viewer)
Definition: Viewer3D.h:203
DGtal::Viewer3D::compute2DDomainLineRepresentation
std::vector< typename DGtal::Viewer3D< Space, KSpace >::LineD3D > compute2DDomainLineRepresentation(Image2DDomainD3D &anImageDomain, double delta)
DGtal::Viewer3D::paintGL
virtual void paintGL()
Overload of the QGLViewer method in order to change the order of display (to fix the QGLViewer axis d...
DGtal::Viewer3D::CompFarthestSurfelFromCamera::posCam
qglviewer::Vec posCam
Definition: Viewer3D.h:1093
DGtal::Viewer3D::CompFarthestSurfelFromCamera
Definition: Viewer3D.h:1091
DGtal::Viewer3D::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *e)
DGtal::Viewer3D::GLTextureImage::myTextureImageBufferGS
unsigned char * myTextureImageBufferGS
Definition: Viewer3D.h:1228
DGtal::Viewer3D::GLTextureImage::GLTextureImage
GLTextureImage(const GLTextureImage &aGLImg)
Definition: Viewer3D.h:1255
DGtal::Viewer3D::setCameraUpVector
void setCameraUpVector(double ax, double ay, double az)
Definition: Viewer3D.h:360
DGtal::Viewer3D::myLightPhi
double myLightPhi
the light position (inclination)
Definition: Viewer3D.h:1626
DGtal::Viewer3D::GLTextureImage::point1
RealPoint point1
coordinates
Definition: Viewer3D.h:1215
DGtal::Viewer3D::myMetallicRenderSpec
const GLfloat myMetallicRenderSpec
Definition: Viewer3D.h:1641
DGtal::Viewer3D::mySelectedElementId
int mySelectedElementId
used to displayed selected elements
Definition: Viewer3D.h:1608
DGtal::Viewer3D::CompFarthestTriangleFromCamera
Definition: Viewer3D.h:1073
DGtal::Viewer3D::addTextureImage
void addTextureImage(const TextureImage &image)
DGtal::Viewer3D::updateRenderingCoefficients
void updateRenderingCoefficients(const RenderingMode aRenderMode, bool displayState=true)
DGtal::Viewer3D::myCubeSetListWiredId
GLuint myCubeSetListWiredId
Definition: Viewer3D.h:1598
DGtal::Viewer3D::Extension
Definition: Viewer3D.h:166
DGtal::Viewer3D::glCreateListTriangles
void glCreateListTriangles(const std::vector< VectorTriangle > &aVectTriangle, unsigned int idList)
DGtal::Viewer3D::myMaterialShininessCoeff
GLfloat myMaterialShininessCoeff[1]
Definition: Viewer3D.h:1631
DGtal::Viewer3D::VectorCubes
std::vector< typename Viewer3D< Space, KSpace >::CubeD3D > VectorCubes
Definition: Viewer3D.h:1372
DGtal::Viewer3D::Extension::init
virtual void init(Viewer &viewer)
Definition: Viewer3D.h:212
DGtal::Viewer3D::translateAn2DDomain
void translateAn2DDomain(unsigned int domainIndex, double xTranslation, double yTranslation, double zTranslation)
DGtal::Viewer3D::myPrismListId
GLuint myPrismListId
Definition: Viewer3D.h:1592
DGtal::Viewer3D::myLambertRenderDiff
const GLfloat myLambertRenderDiff
Definition: Viewer3D.h:1640
DGtal::Viewer3D::myRefMouseXPos
int myRefMouseXPos
the angle rotation increment used for interactive light move
Definition: Viewer3D.h:1661
DGtal::Viewer3D::VectorBall
std::vector< typename Viewer3D< Space, KSpace >::BallD3D > VectorBall
Definition: Viewer3D.h:1375
DGtal::Viewer3D::RenderingLambertian
@ RenderingLambertian
Definition: Viewer3D.h:157
DGtal::Viewer3D::setExtension
void setExtension(Extension *ext)
Definition: Viewer3D.h:316
DGtal::Viewer3D::camera_upVector
double camera_upVector[3]
camera up-vector
Definition: Viewer3D.h:1622
DGtal::Viewer3D::myViewWire
bool myViewWire
objects have shadows which follow the camera if false
Definition: Viewer3D.h:485
DGtal::Viewer3D::CompFarthestTriangleFromCamera::posCam
qglviewer::Vec posCam
Definition: Viewer3D.h:1075
DGtal::Viewer3D::myDirSelector
qglviewer::Vec myDirSelector
Definition: Viewer3D.h:1612
DGtal::Viewer3D::myIsBackgroundDefault
bool myIsBackgroundDefault
true if the background is default
Definition: Viewer3D.h:483
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::Viewer3D::glCreateListQuadMaps
void glCreateListQuadMaps(const typename Display3D< Space, KSpace >::QuadsMap &aQuadMap, unsigned int idList)
DGtal::Viewer3D::Image2DDomainD3D::point3
RealPoint point3
Definition: Viewer3D.h:503
DGtal::Viewer3D::glCreateListPolygonsWired
void glCreateListPolygonsWired(const std::vector< VectorPolygon > &aVectPolygon, unsigned int idList)
DGtal::Viewer3D::yDirection
@ yDirection
Definition: Viewer3D.h:474
DGtal::Viewer3D::myIsMovingLight
bool myIsMovingLight
the reference mouse y-position used to determince the light position change (inclination)
Definition: Viewer3D.h:1663
DGtal::Viewer3D::camera_position
double camera_position[3]
camera position
Definition: Viewer3D.h:1620
DGtal::Viewer3D::zDirection
@ zDirection
Definition: Viewer3D.h:474
DGtal::Viewer3D::drawSomeLight
void drawSomeLight(GLenum light, float zoom) const
To call the protected method drawLight.
Definition: Viewer3D.h:986
DGtal::Viewer3D::RealPoint
Display::RealPoint RealPoint
Definition: Viewer3D.h:149
DGtal::Viewer3D::updateRelativeCameraFromLightPosition
void updateRelativeCameraFromLightPosition()
DGtal::Viewer3D::myQuadsMapId
GLuint myQuadsMapId
Definition: Viewer3D.h:1594
DGtal::Viewer3D::GLTextureImage::myBufferHeight
unsigned int myBufferHeight
Definition: Viewer3D.h:1225
DGtal::Color::red
void red(const unsigned char aRedValue)
DGtal::Viewer3D::glCreateListLines
void glCreateListLines(const VectorLine &aVectLine, unsigned int idList)
DGtal::Viewer3D::Viewer3D
Viewer3D()
Definition: Viewer3D.h:298
DGtal::Viewer3D::TextureImage::point4
RealPoint point4
Definition: Viewer3D.h:575
DGtal::Viewer3D::myRenderingMode
RenderingMode myRenderingMode
Definition: Viewer3D.h:491
DGtal::Viewer3D::ItCube
VectorCubes::iterator ItCube
Definition: Viewer3D.h:1381
DGtal::Color::Red
static const Color Red
Definition: Color.h:392
DGtal::Viewer3D::Image2DDomainD3D::myDomainHeight
unsigned int myDomainHeight
the height of the image domain
Definition: Viewer3D.h:510
DGtal::Viewer3D::myBallSetListId
GLuint myBallSetListId
Definition: Viewer3D.h:1591
DGtal::Viewer3D::Extension::drawWithNames
virtual void drawWithNames(Viewer &viewer)
Definition: Viewer3D.h:193
DGtal::Viewer3D::GLTextureImage::point3
RealPoint point3
Definition: Viewer3D.h:1217
DGtal::Viewer3D
Definition: Viewer3D.h:135
DGtal::Viewer3D::setGLMaterialShininessCoefficient
void setGLMaterialShininessCoefficient(const GLfloat matShininessCoeff)
DGtal::Viewer3D::myGSImageList
std::vector< TextureImage > myGSImageList
flag to display the ligth source when it is moved by the user
Definition: Viewer3D.h:1666
DGtal::Viewer3D::Image2DDomainD3D::myDomainWidth
unsigned int myDomainWidth
the width of the image domain
Definition: Viewer3D.h:508
DGtal::Viewer3D::RenderingMetallic
@ RenderingMetallic
Definition: Viewer3D.h:155
DGtal::Viewer3D::TextureImage::myImageHeight
unsigned int myImageHeight
the width of the image
Definition: Viewer3D.h:580
DGtal::concepts::CDomain
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
DGtal::Viewer3D::myLigthRotationStep
double myLigthRotationStep
Definition: Viewer3D.h:1660
DGtal::Viewer3D::CompFarthestTriangleFromCamera::operator()
bool operator()(typename Viewer3D< Space, KSpace >::TriangleD3D t1, typename Viewer3D< Space, KSpace >::TriangleD3D t2)
Definition: Viewer3D.h:1076
DGtal::Viewer3D::myGLPointMinWidth
double myGLPointMinWidth
Definition: Viewer3D.h:486
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::Viewer3D::RenderingMode
RenderingMode
Definition: Viewer3D.h:152
DGtal::Viewer3D::mySelectedPoint
qglviewer::Vec mySelectedPoint
Definition: Viewer3D.h:1612
DGtal::Viewer3D::helpString
virtual QString helpString() const
DGtal::Viewer3D::rotateDomain
void rotateDomain(Image2DDomainD3D &anDom, double angle, ImageDirection rotationDir)
DGtal::Viewer3D::myDefaultColor
DGtal::Color myDefaultColor
the default color of the viewer
Definition: Viewer3D.h:481
DGtal::Viewer3D::TextureImage::point2
RealPoint point2
Definition: Viewer3D.h:573
DGtal::Viewer3D::initFromDOMElement
virtual void initFromDOMElement(const QDomElement &element)
Overload of the QGLViewer method which restores the viewer state from a QDomDocument element....
DGtal::Viewer3D::myDir
qglviewer::Vec myDir
Definition: Viewer3D.h:1612
DGtal::Viewer3D::TextureImage::className
std::string className() const
DGtal::Viewer3D::ZFar
double ZFar
zfar distance
Definition: Viewer3D.h:1649
DGtal::Viewer3D::updateTextureImage
void updateTextureImage(unsigned int imageIndex, const TImageType &image, const TFunctor &aFunctor, double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0, double rotationAngle=0.0, ImageDirection rotationDir=zDirection)
DGtal::Viewer3D::removeExtension
void removeExtension()
Definition: Viewer3D.h:325
DGtal::Viewer3D::getCurrentGLImageNumber
virtual unsigned int getCurrentGLImageNumber()
DGtal::Viewer3D::KSpace
TKSpace KSpace
Definition: Viewer3D.h:145
DGtal::Viewer3D::GLTextureImage
Definition: Viewer3D.h:1212
DGtal::Viewer3D::setGLLightSpecularCoefficients
void setGLLightSpecularCoefficients(const GLfloat lightSpecularCoeffs[4])
DGtal::Viewer3D::myPolygonSetListId
GLuint myPolygonSetListId
Definition: Viewer3D.h:1587
DGtal::Viewer3D::TextureImage::myDrawDomain
bool myDrawDomain
for each pixel of the image, color or height ?
Definition: Viewer3D.h:584
DGtal::Viewer3D::myVectTextureImage
std::vector< GLTextureImage > myVectTextureImage
list of the images textures in this viewer
Definition: Viewer3D.h:1616
DGtal::Viewer3D::getCurrentDomainNumber
virtual unsigned int getCurrentDomainNumber()
DGtal::Viewer3D::myLightR
double myLightR
the light position (azimuth)
Definition: Viewer3D.h:1627
DGtal::Viewer3D::GLTextureImage::myImageHeight
unsigned int myImageHeight
Definition: Viewer3D.h:1222
DGtal::Viewer3D::myUseGLPointsForBalls
bool myUseGLPointsForBalls
Definition: Viewer3D.h:1646
DGtal::Viewer3D::setCameraDirection
void setCameraDirection(double ax, double ay, double az)
Definition: Viewer3D.h:349
DGtal::Display3D::QuadsMap
std::map< DGtal::int32_t, std::vector< QuadD3D > > QuadsMap
The type that maps identifier name -> vector of QuadD3D.
Definition: Display3D.h:254
DGtal::Viewer3D::Viewer3D
Viewer3D(const KSpace &KSEmb)
Definition: Viewer3D.h:307
DGtal::Viewer3D::setGLLightDiffuseCoefficients
void setGLLightDiffuseCoefficients(const GLfloat lightDiffuseCoeffs[4])
DGtal::Viewer3D::operator<<
Viewer3D< Space, KSpace > & operator<<(const DGtal::Color &aColor)
DGtal::Viewer3D::postSelection
virtual void postSelection(const QPoint &point)
postSelection
DGtal::Viewer3D::VectorPolygon
std::vector< typename Viewer3D< Space, KSpace >::PolygonD3D > VectorPolygon
Definition: Viewer3D.h:1377
DGtal::Viewer3D::draw
virtual void draw()
draw
DGtal::Viewer3D::updateOrientationTextureImage
void updateOrientationTextureImage(unsigned int imageIndex, double xPosition, double yPosition, double zPosition, ImageDirection newDirection)
DGtal::Viewer3D::myDefaultBackgroundColor
DGtal::Color myDefaultBackgroundColor
the default background color of the viewer
Definition: Viewer3D.h:479
DGtal::Viewer3D::GLTextureImage::myTextureFitY
double myTextureFitY
Definition: Viewer3D.h:1235
DGtal::Viewer3D::myNbPrismSetList
unsigned int myNbPrismSetList
Definition: Viewer3D.h:1605
DGtal::Viewer3D::CompFarthestPolygonFromCamera::posCam
qglviewer::Vec posCam
Definition: Viewer3D.h:1112
DGtal::Viewer3D::closeEvent
virtual void closeEvent(QCloseEvent *e)
Overload the QWidget method to customize the viewer state auto saving. Now it save the viewer state i...
DGtal::Viewer3D::glCreateListBalls
void glCreateListBalls(const VectorBall &aVectBall, unsigned int idList)
DGtal::Viewer3D::TextureImage::myMode
TextureMode myMode
index of the image domain if exist
Definition: Viewer3D.h:586
DGtal::Display3D::LineD3D
Definition: Display3D.h:149
DGtal::Viewer3D::myMeshDefaultLineWidth
float myMeshDefaultLineWidth
Definition: Viewer3D.h:1652
DGtal::Viewer3D::glUpdateBackground
void glUpdateBackground()
DGtal::Viewer3D< Space, KSpace >::ImageDirection
ImageDirection
the 3 possible axes for the image direction
Definition: Viewer3D.h:474
DGtal::Viewer3D::GLTextureImage::myTextureImageBufferRGB
unsigned char * myTextureImageBufferRGB
Definition: Viewer3D.h:1229
DGtal::Viewer3D::glCreateListQuadD3D
void glCreateListQuadD3D(const VectorQuad &aVectQuad, unsigned int idList)
DGtal::Viewer3D::VectorLine
std::vector< typename Viewer3D< Space, KSpace >::LineD3D > VectorLine
Definition: Viewer3D.h:1374
DGtal::Viewer3D::TextureImage::myTabImage
unsigned int * myTabImage
the height of the image
Definition: Viewer3D.h:582
DGtal::Viewer3D::myLightPosition
GLfloat myLightPosition[4]
the light position (distance)
Definition: Viewer3D.h:1628
DGtal::Viewer3D::Image2DDomainD3D::Image2DDomainD3D
Image2DDomainD3D(TDomain aDomain, ImageDirection normalDir=zDirection, double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0, std::string mode="BoundingBox")
Definition: Viewer3D.h:528
DGtal::Viewer3D::mySelectionColorShift
unsigned char mySelectionColorShift
Definition: Viewer3D.h:1609
DGtal::Viewer3D::glCreateListTrianglesWired
void glCreateListTrianglesWired(const std::vector< VectorTriangle > &aVectTriangle, unsigned int idList)
DGtal::Viewer3D::sortSurfelFromCamera
void sortSurfelFromCamera()
DGtal::Viewer3D::GLTextureImage::myMode
Viewer3D< Space, KSpace >::TextureMode myMode
Definition: Viewer3D.h:1227
DGtal::Viewer3D::Extension::mousePressEvent
virtual bool mousePressEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:268
DGtal::Viewer3D::myDefaultRenderSpec
const GLfloat myDefaultRenderSpec
Definition: Viewer3D.h:1637
DGtal::Viewer3D::Display
Display3D< Space, KSpace > Display
Definition: Viewer3D.h:147
DGtal::Viewer3D::GLTextureImage::myImageWidth
unsigned int myImageWidth
Definition: Viewer3D.h:1221
DGtal::Viewer3D::GLTextureImage::point4
RealPoint point4
Definition: Viewer3D.h:1218
DGtal::Viewer3D::myRefMouseYPos
int myRefMouseYPos
the reference mouse x-position used to determince the light position change (azimuth)
Definition: Viewer3D.h:1662
DGtal::Color::green
void green(const unsigned char aGreenValue)
DGtal::Viewer3D::myImageDomainList
std::vector< Image2DDomainD3D > myImageDomainList
Used to store all the domains.
Definition: Viewer3D.h:1668
DGtal::Color::blue
void blue(const unsigned char aBlueValue)
DGtal::Viewer3D::setUseGLPointForBalls
void setUseGLPointForBalls(bool useOpenGLPt)
DGtal::Viewer3D::myPlasticRenderDiff
const GLfloat myPlasticRenderDiff
Definition: Viewer3D.h:1644
DGtal::Viewer3D::myOrig
qglviewer::Vec myOrig
information linked to the navigation in the viewer
Definition: Viewer3D.h:1612
DGtal::Viewer3D::Extension::keyPressEvent
virtual bool keyPressEvent(Viewer &viewer, QKeyEvent *event)
Definition: Viewer3D.h:181
DGtal::Viewer3D::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
DGtal::Viewer3D::updateAn2DDomainOrientation
void updateAn2DDomainOrientation(unsigned int imageIndex, double xPosition, double yPosition, double zPosition, ImageDirection newDirection)
DGtal::Viewer3D::myLightPositionFixToCamera
bool myLightPositionFixToCamera
Definition: Viewer3D.h:1624
DGtal::Viewer3D::rotatePoint
static void rotatePoint(TValues &x, TValues &y, TValues &z, double cx, double cy, double cz, double rotationAngle, ImageDirection rotationDir)
DGtal::Viewer3D::Image2DDomainD3D::myMode
std::string myMode
the mode of representation of the image domain
Definition: Viewer3D.h:514
DGtal::Viewer3D::myTriangleSetListId
GLuint myTriangleSetListId
lists of the list to draw
Definition: Viewer3D.h:1584
DGtal::Viewer3D::TextureImage::myIndexDomain
unsigned int myIndexDomain
true if the draw have a domain
Definition: Viewer3D.h:585
DGtal::Viewer3D::CompFarthestVoxelFromCamera
Definition: Viewer3D.h:1051
DGtal::Viewer3D::RenderingDefault
@ RenderingDefault
Definition: Viewer3D.h:154
DGtal::Viewer3D::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::Viewer3D::GLTextureImage::~GLTextureImage
~GLTextureImage()
Definition: Viewer3D.h:1239
DGtal::Viewer3D::myMaterialSpecularCoeffs
GLfloat myMaterialSpecularCoeffs[4]
Definition: Viewer3D.h:1632
DGtal::Viewer3D::Image2DDomainD3D::translateDomain
void translateDomain(double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0)
DGtal::Viewer3D::Image2DDomainD3D::point1
RealPoint point1
The image domain coordinates.
Definition: Viewer3D.h:501
DGtal::Viewer3D::setNearFar
void setNearFar(double _near, double _far)
Definition: Viewer3D.h:370
DGtal::Viewer3D::TextureImage::point3
RealPoint point3
Definition: Viewer3D.h:574
DGtal::Viewer3D::Image2DDomainD3D::color
DGtal::Color color
The image domain color.
Definition: Viewer3D.h:506
DGtal::Viewer3D::updateLightCoordsFromCamera
void updateLightCoordsFromCamera()
DGtal::Viewer3D::CompFarthestPolygonFromCamera::operator()
bool operator()(typename Viewer3D< Space, KSpace >::PolygonD3D q1, typename Viewer3D< Space, KSpace >::PolygonD3D q2)
Definition: Viewer3D.h:1113
DGtal::Viewer3D::TextureImage::updateImage3DEmbedding
void updateImage3DEmbedding(RealPoint aPoint1, RealPoint aPoint2, RealPoint aPoint3, RealPoint aPoint4)
Definition: Viewer3D.h:684
DGtal::Viewer3D::myDefaultRenderDiff
const GLfloat myDefaultRenderDiff
Definition: Viewer3D.h:1638
DGtal::Viewer3D::drawWithNames
virtual void drawWithNames()
drawWithNames
DGtal::Viewer3D::show
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DGtal::Display3D::SelectCallbackFct
int(* SelectCallbackFct)(void *viewer, DGtal::int32_t name, void *data)
Select callback function type.
Definition: Display3D.h:109
DGtal::Viewer3D::Image2DDomainD3D::point2
RealPoint point2
Definition: Viewer3D.h:502
DGtal::Viewer3D::setGLLightAmbientCoefficients
void setGLLightAmbientCoefficients(const GLfloat lightAmbientCoeffs[4])
DGtal::Viewer3D::mousePressEvent
virtual void mousePressEvent(QMouseEvent *e)
DGtal::Viewer3D::rotateImageVertex
static void rotateImageVertex(TImageORDomain &anImageOrDom, double angle, ImageDirection rotationDir)
Definition: Viewer3D.h:1544
DGtal::Viewer3D::setGLDoubleRenderingMode
void setGLDoubleRenderingMode(bool doubleSidedRendering)
DGtal::Viewer3D::init
virtual void init()
init
DGtal::Viewer3D::myLightDiffuseCoeffs
GLfloat myLightDiffuseCoeffs[4]
Definition: Viewer3D.h:1635
DGtal::Viewer3D::RenderingPlastic
@ RenderingPlastic
Definition: Viewer3D.h:156
DGtal::Viewer3D::Extension::~Extension
virtual ~Extension()=default
DGtal::Viewer3D::myPosSelector
QPoint myPosSelector
a point selected with postSelection
Definition: Viewer3D.h:1614
DGtal::Viewer3D::myGLScaleFactorX
float myGLScaleFactorX
Definition: Viewer3D.h:1655
DGtal::Viewer3D::Extension::helpString
virtual QString helpString(const Viewer &viewer) const
Definition: Viewer3D.h:223
DGtal::Viewer3D::sortQuadFromCamera
void sortQuadFromCamera()
DGtal::Viewer3D::xDirection
@ xDirection
Definition: Viewer3D.h:474
DGtal::Viewer3D::myNbBallSetList
unsigned int myNbBallSetList
Definition: Viewer3D.h:1604
DGtal::Viewer3D::CompFarthestSurfelFromCamera::operator()
bool operator()(typename Viewer3D< Space, KSpace >::QuadD3D q1, typename Viewer3D< Space, KSpace >::QuadD3D q2)
Definition: Viewer3D.h:1094
DGtal::Display3D::CubesMap
std::map< DGtal::int32_t, std::vector< CubeD3D > > CubesMap
The type that maps identifier name -> vector of CubeD3D.
Definition: Display3D.h:257
DGtal::Viewer3D::setGLScale
void setGLScale(float sx, float sy, float sz)
Definition: Viewer3D.h:384
DGtal::Viewer3D::myIsDoubleFaceRendering
bool myIsDoubleFaceRendering
true if is double face rendering
Definition: Viewer3D.h:1618
DGtal::Viewer3D::Self
Viewer3D< Space, KSpace > Self
Definition: Viewer3D.h:146
DGtal::Viewer3D::updateList
void updateList(bool needToUpdateBoundingBox=true)
DGtal::Viewer3D::myLightTheta
double myLightTheta
Definition: Viewer3D.h:1625
DGtal::Viewer3D::ZNear
double ZNear
znear distance
Definition: Viewer3D.h:1648
DGtal::Viewer3D::myLightPositionRefCameraDefault
GLfloat myLightPositionRefCameraDefault[3]
Definition: Viewer3D.h:1629
DGtal::Viewer3D< Space, KSpace >::TextureMode
TextureMode
the modes of representation of an image
Definition: Viewer3D.h:476
DGtal::Viewer3D::TextureImage::updateImageDataAndParam
void updateImageDataAndParam(const TImageType &image, const TFunctor &aFunctor, double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0)
Definition: Viewer3D.h:710
DGtal::Viewer3D::GLTextureImage::GLTextureImage
GLTextureImage(const typename Viewer3D< Space, KSpace >::TextureImage &aGSImage)
Definition: Viewer3D.h:1294
DGtal::Viewer3D::GLTextureImage::vectNormal
double vectNormal[3]
Definition: Viewer3D.h:1230
DGtal::concepts::CUnaryFunctor
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:89
DGtal::concepts::CConstImage
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Definition: CConstImage.h:94
DGtal::Viewer3D::myMetallicRenderDiff
const GLfloat myMetallicRenderDiff
Definition: Viewer3D.h:1642
DGtal::Viewer3D::Image2DDomainD3D::myDirection
ImageDirection myDirection
the direction of the domain (x, y or z axe)
Definition: Viewer3D.h:512
DGtal::Viewer3D::myTriangleSetListWiredId
GLuint myTriangleSetListWiredId
Definition: Viewer3D.h:1585
DGtal::Viewer3D::TextureImage::updateImageOrientation
void updateImageOrientation(ImageDirection normalDir, double xBottomLeft, double yBottomLeft, double zBottomLeft)
DGtal::Viewer3D::glCreateListQuadMapsWired
void glCreateListQuadMapsWired(const typename Display3D< Space, KSpace >::QuadsMap &aQuadMap, unsigned int idList)
DGtal::Viewer3D::Image2DDomainD3D::updateDomainOrientation
void updateDomainOrientation(ImageDirection normalDir, double xBottomLeft, double yBottomLeft, double zBottomLeft)
DGtal::Viewer3D::GLTextureImage::myTextureFitX
double myTextureFitX
Definition: Viewer3D.h:1234
DGtal::Viewer3D::isValid
bool isValid() const
DGtal::Viewer3D::updateEmbeddingTextureImage
void updateEmbeddingTextureImage(unsigned int anImageIndex, typename Space::Point aPoint1, typename Space::Point aPoint2, typename Space::Point aPoint3, typename Space::Point aPoint4)
DGtal::Viewer3D::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *e)
DGtal::Viewer3D::TextureImage::~TextureImage
~TextureImage()
the mode of representation of the image
Definition: Viewer3D.h:591
DGtal::Viewer3D::glCreateListCubesMaps
void glCreateListCubesMaps(const typename Display3D< Space, KSpace >::CubesMap &aCubeMap, unsigned int idList)
DGtal::Viewer3D::GLTextureImage::point2
RealPoint point2
Definition: Viewer3D.h:1216
DGtal::Viewer3D::myGLLineMinWidth
double myGLLineMinWidth
to improve the display of gl points
Definition: Viewer3D.h:487
DGtal::Viewer3D::myLightSpecularCoeffs
GLfloat myLightSpecularCoeffs[4]
Definition: Viewer3D.h:1633
DGtal::Viewer3D::myGLScaleFactorZ
float myGLScaleFactorZ
Definition: Viewer3D.h:1657