DGtal  1.1.0
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 #ifdef APPLE
52 #include <OpenGL/gl.h>
53 #include <OpenGL/glu.h>
54 #else
55 #include <GL/gl.h>
56 #include <GL/glu.h>
57 #endif
58 
59 #ifdef WITH_QT5
60  #include <QApplication>
61 #else
62  #include <QtGui/qapplication.h>
63 #endif
64 
65 #include <QGLViewer/qglviewer.h>
66 #include <QGLWidget>
67 #include <QKeyEvent>
68 
69 #include "DGtal/kernel/SpaceND.h"
70 #include "DGtal/topology/KhalimskySpaceND.h"
71 #include "DGtal/base/CountedPtr.h"
72 #include "DGtal/io/Display3D.h"
73 #include "DGtal/math/BasicMathFunctions.h"
74 
75 #include "DGtal/kernel/CSpace.h"
76 
78 
79 namespace DGtal
80 {
81 
83  // class Viewer3D
130  template <typename TSpace = SpaceND<3>,
131  typename TKSpace = KhalimskySpaceND<3>>
132  class Viewer3D : public QGLViewer, public Display3D<TSpace, TKSpace>
133  {
134 
136 
137  //---------------overwritting some functions of Display3D -------------------
138 
139  // ----------------------- public types ------------------------------
140  public:
141  typedef TSpace Space;
142  typedef TKSpace KSpace;
146  typedef typename Display::RealPoint RealPoint;
148 
150  {
155  };
156 
163  struct Extension
164  {
167 
168  virtual ~Extension() = default;
169 
178  virtual bool keyPressEvent( Viewer & viewer, QKeyEvent * event )
179  {
180  boost::ignore_unused_variable_warning( viewer );
181  boost::ignore_unused_variable_warning( event );
182  return false;
183  }
184 
190  virtual void drawWithNames( Viewer & viewer )
191  {
192  boost::ignore_unused_variable_warning( viewer );
193  }
194 
200  virtual void draw( Viewer & viewer )
201  {
202  boost::ignore_unused_variable_warning( viewer );
203  }
204 
209  virtual void init( Viewer & viewer )
210  {
211  boost::ignore_unused_variable_warning( viewer );
212  }
213 
220  virtual QString helpString( const Viewer & viewer ) const
221  {
222  boost::ignore_unused_variable_warning( viewer );
223  return "";
224  }
225 
235  virtual bool postSelection( const Viewer & viewer, const QPoint & point )
236  {
237  boost::ignore_unused_variable_warning( viewer );
238  boost::ignore_unused_variable_warning( point );
239  return false;
240  }
241 
250  virtual bool mouseMoveEvent( const Viewer & viewer, QMouseEvent * event )
251  {
252  boost::ignore_unused_variable_warning( viewer );
253  boost::ignore_unused_variable_warning( event );
254  return false;
255  }
256 
265  virtual bool mousePressEvent( const Viewer & viewer, QMouseEvent * event )
266  {
267  boost::ignore_unused_variable_warning( viewer );
268  boost::ignore_unused_variable_warning( event );
269  return false;
270  }
271 
281  virtual bool mouseReleaseEvent( const Viewer & viewer, QMouseEvent * event )
282  {
283  boost::ignore_unused_variable_warning( viewer );
284  boost::ignore_unused_variable_warning( event );
285  return false;
286  }
287  };
288 
289  // ----------------------- Standard services ------------------------------
290  public:
291 
295  Viewer3D() : QGLViewer(), Display3D<Space, KSpace>(), myExtension( 0 )
296  {
297  resize( 800, 600 );
298  };
299 
304  Viewer3D( const KSpace & KSEmb )
305  : QGLViewer(), Display3D<Space, KSpace>( KSEmb ), myExtension( 0 )
306  {
307  resize(800,600);
308  }
309 
313  void setExtension( Extension * ext )
314  {
315  if ( myExtension != 0 )
316  delete myExtension;
317  myExtension = ext;
318  }
319 
323  {
324  if ( myExtension != 0 )
325  delete myExtension;
326  myExtension = 0;
327  }
328 
335  void setCameraPosition(double ax, double ay, double az)
336  {
337  camera_position[0] = ax; camera_position[1] = ay; camera_position[2] = az;
338  }
339 
346  void setCameraDirection(double ax, double ay, double az)
347  {
348  camera_direction[0] = ax; camera_direction[1] = ay; camera_direction[2] = az;
349  }
350 
357  void setCameraUpVector(double ax, double ay, double az)
358  {
359  camera_upVector[0] = ax; camera_upVector[1] = ay; camera_upVector[2] = az;
360  }
361 
367  void setNearFar(double _near, double _far)
368  {
369  ZNear = _near; ZFar = _far;
370  }
371 
381  void setGLScale(float sx, float sy, float sz)
382  {
383  myGLScaleFactorX=sx;
384  myGLScaleFactorY=sy;
385  myGLScaleFactorZ=sz;
386  // In order to have the light source rendering the same as wtih the default scale 1.
387  glEnable(GL_NORMALIZE);
388  }
389 
390 
402  void setGLDoubleRenderingMode(bool doubleSidedRendering);
403 
404 
412  void setGLMaterialShininessCoefficient(const GLfloat matShininessCoeff);
413 
414 
423  void setGLLightAmbientCoefficients(const GLfloat lightAmbientCoeffs [4]);
424 
433  void setGLLightDiffuseCoefficients(const GLfloat lightDiffuseCoeffs [4]);
434 
435 
443  void setGLLightSpecularCoefficients(const GLfloat lightSpecularCoeffs [4]);
444 
445 
446 
457  void setUseGLPointForBalls(bool useOpenGLPt);
458 
459 
467  void updateRenderingCoefficients(const RenderingMode aRenderMode, bool displayState=true);
468 
469 
474 
483  double myGLPointMinWidth = 1.5;
484  double myGLLineMinWidth = 1.5;
485  bool myAutoSaveState;
487  // define the default rendering mode of the viewer
489 
495  {
496 
505  unsigned int myDomainWidth;
507  unsigned int myDomainHeight;
511  std::string myMode;
513  std::size_t myLineSetIndex;
514 
524  template<typename TDomain>
525  Image2DDomainD3D( TDomain aDomain, ImageDirection normalDir=zDirection,
526  double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0, std::string mode= "BoundingBox")
527  {
529  myMode = mode;
530  myDirection=normalDir;
531  myDomainWidth = (aDomain.upperBound())[0]-(aDomain.lowerBound())[0]+1;
532  myDomainHeight = (aDomain.upperBound())[1]-(aDomain.lowerBound())[1]+1;
533  updateDomainOrientation(normalDir, xBottomLeft, yBottomLeft, zBottomLeft);
534  }
535 
536 
547  double xBottomLeft, double yBottomLeft, double zBottomLeft);
548 
549 
556  void translateDomain(double xTranslation=0.0,
557  double yTranslation=0.0, double zTranslation=0.0);
558 
559  };
560 
561 
567  {
568 
573 
575 
576  unsigned int myImageWidth;
577  unsigned int myImageHeight;
578  //TODO complete desc attribute
579  unsigned int * myTabImage;
580 
582  unsigned int myIndexDomain;
584 
589  {
590  delete [] myTabImage;
591  };
592 
598  point3(img.point3), point4(img.point4),
601  myTabImage(img.myTabImage),
604  myMode(img.myMode)
605  {
606 
607  if(img.myImageHeight>0 && img.myImageWidth>0)
608  {
609  myTabImage = new unsigned int [img.myImageWidth*img.myImageHeight];
610  for(unsigned int i=0; i<img.myImageWidth*img.myImageHeight; i++)
611  {
612  myTabImage[i] = img.myTabImage[i];
613  }
614  }else
615  {
616  myTabImage=img.myTabImage;
617  }
618  };
619 
620 
621 
641  template <typename TImageType, typename TFunctor>
642 
643  TextureImage( const TImageType & image, const TFunctor &aFunctor,
644  ImageDirection normalDir=zDirection,
645  double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0,
646  TextureMode aMode= GrayScaleMode)
647  {
650  myDrawDomain=false;
651  myDirection=normalDir;
652  myImageWidth = (image.domain().upperBound())[0]-(image.domain().lowerBound())[0]+1;
653  myImageHeight = (image.domain().upperBound())[1]-(image.domain().lowerBound())[1]+1;
654  myTabImage = new unsigned int [myImageWidth*myImageHeight];
655  updateImageOrientation(normalDir, xBottomLeft, yBottomLeft, zBottomLeft);
656  myMode=aMode;
657  updateImageDataAndParam(image, aFunctor);
658  }
659 
670  double xBottomLeft, double yBottomLeft, double zBottomLeft);
671 
672 
680  void
682  RealPoint aPoint2,
683  RealPoint aPoint3,
684  RealPoint aPoint4)
685  {
686  point1 = aPoint1; point2 = aPoint2; point3 = aPoint3; point4 = aPoint4;
688  }
689 
690 
706  template <typename TImageType, typename TFunctor>
707  void updateImageDataAndParam(const TImageType & image, const TFunctor &aFunctor, double xTranslation=0.0,
708  double yTranslation=0.0, double zTranslation=0.0)
709  {
712  assert ( (image.domain().upperBound())[0]-(image.domain().lowerBound())[0]+1== static_cast<int>(myImageWidth) &&
713  (image.domain().upperBound())[1]-(image.domain().lowerBound())[1]+1== static_cast<int>(myImageHeight));
714 
715  point1[0] += xTranslation; point1[1] += yTranslation; point1[2] += zTranslation;
716  point2[0] += xTranslation; point2[1] +=yTranslation; point2[2] += zTranslation;
717  point3[0] += xTranslation; point3[1] += yTranslation; point3[2] += zTranslation;
718  point4[0] += xTranslation; point4[1] += yTranslation; point4[2] += zTranslation;
719 
720  unsigned int pos=0;
721  for(typename TImageType::Domain::ConstIterator it = image.domain().begin(), itend=image.domain().end();
722  it!=itend; ++it)
723  {
724  myTabImage[pos]= aFunctor(image(*it));
725  pos++;
726  }
727  }
728 
732  std::string className() const;
733 
734  private:
740  {};
741  };
742 
749 
750 
757 
758 
763 
768 
773 
778 
779 
780 
781  template <typename TDrawableWithViewer3D>
790  Viewer3D<Space, KSpace> & operator<< ( const TDrawableWithViewer3D & object );
791 
792 
793 
794  // ----------------------- Interface --------------------------------------
795  public:
796 
801  void selfDisplay ( std::ostream & out ) const;
802 
807  bool isValid() const;
808 
809 
810 
811  virtual unsigned int getCurrentDomainNumber();
812 
813  virtual unsigned int getCurrentGLImageNumber();
814 
815 
821  virtual void paintGL();
822 
823 
830  virtual void show();
831 
832 
838  void addTextureImage(const TextureImage &image);
839 
840 
853  template <typename TImageType, typename TFunctor>
854 
855  void updateTextureImage(unsigned int imageIndex, const TImageType & image, const TFunctor & aFunctor,
856  double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0,
857  double rotationAngle=0.0, ImageDirection rotationDir=zDirection);
858 
859 
860 
861 
871  void updateOrientationTextureImage(unsigned int imageIndex,
872  double xPosition, double yPosition,
873  double zPosition, ImageDirection newDirection);
874 
875 
876 
885  void updateEmbeddingTextureImage(unsigned int anImageIndex,
886  typename Space::Point aPoint1, typename Space::Point aPoint2,
887  typename Space::Point aPoint3, typename Space::Point aPoint4);
888 
889 
890 
897  template<typename TDomain>
898  void addImage2DDomainD3D(const TDomain &anImageDomain, std::string mode,
899  const DGtal::Color &aColor=DGtal::Color::Red );
900 
901 
910  void updateAn2DDomainOrientation(unsigned int imageIndex,
911  double xPosition, double yPosition,
912  double zPosition, ImageDirection newDirection);
913 
921  void translateAn2DDomain(unsigned int domainIndex, double xTranslation,
922  double yTranslation, double zTranslation);
923 
930  std::vector<typename DGtal::Viewer3D< Space , KSpace >::LineD3D>
931  compute2DDomainLineRepresentation( Image2DDomainD3D &anImageDomain, double delta );
932 
938  std::vector<typename DGtal::Viewer3D< Space , KSpace >::LineD3D>
939  compute2DDomainLineRepresentation( Image2DDomainD3D &anImageDomain);
940 
941 
950  template < typename TContainer >
952  double angleRotation, ImageDirection dirRotation);
953 
954 
955 
964  void rotateDomain(Image2DDomainD3D &anDom, double angle, ImageDirection rotationDir);
965 
966 
967 
968 
969 
970 
971  // ------------------------- Protected Datas ------------------------------
972  private:
973 
974 
975 
976  public:
978  void drawSomeLight( GLenum light ) const
979  {
980  QGLViewer::drawLight( light );
981  }
983  void drawSomeLight( GLenum light, float zoom ) const
984  {
985  QGLViewer::drawLight( light, zoom );
986  }
987 
988  // ------------------------- Hidden services ------------------------------
989  // protected:
990 
997  void updateList( bool needToUpdateBoundingBox = true );
998 
1003  void glDrawGLBall( const typename Viewer3D<Space, KSpace>::BallD3D & aBall );
1004 
1022  virtual void keyPressEvent( QKeyEvent * e );
1023 
1029  virtual void mouseMoveEvent( QMouseEvent * e );
1030 
1036  virtual void mousePressEvent( QMouseEvent * e );
1037 
1043  virtual void mouseReleaseEvent( QMouseEvent * e );
1044 
1049  {
1050  qglviewer::Vec posCam;
1052  typename Viewer3D<Space, KSpace>::CubeD3D s2 )
1053  {
1054  double dist1 =
1055  sqrt( ( posCam.x - s1.center[ 0 ] ) * ( posCam.x - s1.center[ 0 ] ) +
1056  ( posCam.y - s1.center[ 1 ] ) * ( posCam.y - s1.center[ 1 ] ) +
1057  ( posCam.z - s1.center[ 2 ] ) * ( posCam.z - s1.center[ 2 ] ) );
1058  double dist2 =
1059  sqrt( ( posCam.x - s2.center[ 0 ] ) * ( posCam.x - s2.center[ 0 ] ) +
1060  ( posCam.y - s2.center[ 1 ] ) * ( posCam.y - s2.center[ 1 ] ) +
1061  ( posCam.z - s2.center[ 2 ] ) * ( posCam.z - s2.center[ 2 ] ) );
1062  return dist1 > dist2;
1063  }
1064  };
1065 
1066 
1071  {
1072  qglviewer::Vec posCam;
1075  {
1076  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 );
1077  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 );
1078  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 ) );
1079  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 ) );
1080 
1081  return dist1>dist2;
1082  }
1083  };
1084 
1089  {
1090  qglviewer::Vec posCam;
1092  typename Viewer3D<Space,KSpace>::QuadD3D q2 )
1093  {
1094 
1095  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 );
1096  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 );
1097 
1098  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 ) );
1099  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 ) );
1100  return dist1>dist2;
1101  }
1102  };
1103 
1108  {
1109  qglviewer::Vec posCam;
1112  {
1113  double c1x=0.0, c1y=0.0, c1z=0.0;
1114  double c2x=0.0, c2y=0.0, c2z=0.0;
1115  for(unsigned int i=0; i< q1.vertices.size(); i++){
1116  c1x+=q1.vertices.at(i)[0];
1117  c1y+=q1.vertices.at(i)[1];
1118  c1z+=q1.vertices.at(i)[2];
1119  }
1120  for(unsigned int i=0; i< q2.vertices.size(); i++){
1121  c2x+=q2.vertices.at(i)[0];
1122  c2y+=q2.vertices.at(i)[1];
1123  c2z+=q2.vertices.at(i)[2];
1124  }
1125 
1126  qglviewer::Vec center1 ( c1x/(double)q1.vertices.size(),c1y/(double)q1.vertices.size(), c1z/(double)q1.vertices.size() );
1127  qglviewer::Vec center2 ( c2x/(double)q2.vertices.size(),c2y/(double)q2.vertices.size(), c2z/(double)q2.vertices.size() );
1128 
1129  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 ) );
1130  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 ) );
1131  return dist1>dist2;
1132  }
1133  };
1134 
1135 
1136 
1140  virtual void drawWithNames();
1141 
1145  virtual void draw();
1146 
1150  virtual void init();
1151 
1155  virtual QString helpString() const;
1156 
1161  virtual void postSelection ( const QPoint& point );
1162 
1163 
1164 
1174  virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
1175 
1176 
1187  virtual void initFromDOMElement(const QDomElement& element);
1188 
1189 
1197  protected: virtual void closeEvent ( QCloseEvent * e );
1198 
1199 
1200 
1201  // ------------------------- Internals ------------------------------------
1202  private:
1203 
1204 
1210  {
1216 
1218  unsigned int myImageWidth;
1219  unsigned int myImageHeight;
1220 
1221  unsigned int myBufferWidth;
1222  unsigned int myBufferHeight;
1225  unsigned char * myTextureImageBufferGS;
1226  unsigned char * myTextureImageBufferRGB;
1227  double vectNormal[3];
1228 
1229 
1230  // By definition in OpenGL the image size of texture should power of 2
1233 
1234 
1235  // Destructor
1237  {
1238  if(myMode== 1)
1239  {
1240  if(myTextureImageBufferGS!=0)
1241  delete [] myTextureImageBufferGS;
1242  }
1244  {
1246  delete [] myTextureImageBufferRGB;
1247  }
1248 
1249  }
1250 
1251  //Copy constructor from a GLTextureImage
1254  myTextureName(aGLImg.myTextureName),
1255  myMode(aGLImg.myMode),
1256  myTextureFitX(aGLImg.myTextureFitX),
1258 
1259  {
1260  point1[0]=aGLImg.point1[0]; point1[1]=aGLImg.point1[1]; point1[2]=aGLImg.point1[2];
1261  point2[0]=aGLImg.point2[0]; point2[1]=aGLImg.point2[1]; point2[2]=aGLImg.point2[2];
1262  point3[0]=aGLImg.point3[0]; point3[1]=aGLImg.point3[1]; point3[2]=aGLImg.point3[2];
1263  point4[0]=aGLImg.point4[0]; point4[1]=aGLImg.point4[1]; point4[2]=aGLImg.point4[2];
1265  myDirection = aGLImg.myDirection;
1266  vectNormal[0]=aGLImg.vectNormal[0];
1267  vectNormal[1]=aGLImg.vectNormal[1];
1268  vectNormal[2]=aGLImg.vectNormal[2];
1269 
1270  if(myMode== 1)
1271  {
1272  myTextureImageBufferGS = new unsigned char [myBufferHeight*myBufferWidth];
1273  for(unsigned int i=0; i<myBufferHeight*myBufferWidth;i++)
1274  {
1276  }
1278  {
1279  myTextureImageBufferRGB = new unsigned char [3*myBufferHeight*myBufferWidth];
1280  for(unsigned int i=0; i<3*myBufferHeight*myBufferWidth;i+=3)
1281  {
1285  }
1286  }
1287  }
1288 
1289 
1290  //Copy constructor from a TextureImage
1292  {
1293  point1[0]=aGSImage.point1[0]; point1[1]=aGSImage.point1[1]; point1[2]=aGSImage.point1[2];
1294  point2[0]=aGSImage.point2[0]; point2[1]=aGSImage.point2[1]; point2[2]=aGSImage.point2[2];
1295  point3[0]=aGSImage.point3[0]; point3[1]=aGSImage.point3[1]; point3[2]=aGSImage.point3[2];
1296  point4[0]=aGSImage.point4[0]; point4[1]=aGSImage.point4[1]; point4[2]=aGSImage.point4[2];
1297  myImageWidth=aGSImage.myImageWidth; myImageHeight=aGSImage.myImageHeight;
1298  myDirection = aGSImage.myDirection;
1299  myMode= aGSImage.myMode;
1304  RealPoint v1 = point2-point1;
1305  RealPoint v2 = point4-point1;
1306  vectNormal[0] = v1[1]*v2[2] - v1[2]*v2[1];
1307  vectNormal[1] = v1[2]*v2[0] - v1[0]*v2[2];
1308  vectNormal[2] = v1[0]*v2[1] - v1[1]*v2[0];
1309  double norm = sqrt(vectNormal[0]*vectNormal[0]+vectNormal[1]*vectNormal[1]+vectNormal[2]*vectNormal[2]);
1310  vectNormal[0] /=norm; vectNormal[1] /=norm; vectNormal[2] /=norm;
1311  }
1312 
1315 
1316  if(myMode== 1)
1317  {
1318  myTextureImageBufferGS = new unsigned char [myBufferHeight*myBufferWidth];
1319  unsigned int pos=0;
1320  for (unsigned int i=0; i<myBufferHeight; i++)
1321  {
1322  for (unsigned int j=0; j<myBufferWidth; j++)
1323  {
1324  if(i<myImageHeight && j< myImageWidth)
1325  {
1326  myTextureImageBufferGS[pos]= aGSImage.myTabImage[i*myImageWidth+j];
1327  }else{
1328  myTextureImageBufferGS[pos]=0;
1329  }
1330  pos++;
1331  }
1332  }
1334  {
1335  myTextureImageBufferRGB = new unsigned char [3*myBufferHeight*myBufferWidth];
1336  unsigned int pos=0;
1337  for (unsigned int i=0; i<myBufferHeight; i++)
1338  {
1339  for (unsigned int j=0; j<myBufferWidth; j++)
1340  {
1341  if(i<myImageHeight && j< myImageWidth)
1342  {
1343  DGtal::Color aCol(aGSImage.myTabImage[i*myImageWidth+j]);
1344  myTextureImageBufferRGB[pos]= aCol.red();
1345  myTextureImageBufferRGB[pos+1]= aCol.green();
1346  myTextureImageBufferRGB[pos+2]= aCol.blue();
1347  }else{
1348  myTextureImageBufferRGB[pos]=0;
1349  myTextureImageBufferRGB[pos+1]=0;
1350  myTextureImageBufferRGB[pos+2]=0;
1351  }
1352  pos+=3;
1353  }
1354  }
1355  }
1356 
1359  }
1360  };
1361 
1362 
1363 
1369  typedef typename std::vector<typename Viewer3D<Space, KSpace>::CubeD3D> VectorCubes;
1370  typedef typename std::vector<typename Viewer3D<Space, KSpace>::QuadD3D> VectorQuad;
1371  typedef typename std::vector<typename Viewer3D<Space, KSpace>::LineD3D> VectorLine;
1372  typedef typename std::vector<typename Viewer3D<Space, KSpace>::BallD3D> VectorBall;
1373  typedef typename std::vector<typename Viewer3D<Space, KSpace>::TriangleD3D> VectorTriangle;
1374  typedef typename std::vector<typename Viewer3D<Space, KSpace>::PolygonD3D> VectorPolygon;
1375  typedef typename std::vector<typename Viewer3D<Space, KSpace>::TextureImage> VectorTextureImage;
1376 
1377 
1378  typedef typename VectorCubes::iterator ItCube;
1379 
1380 
1390  void glCreateListCubesMaps(const typename Display3D<Space, KSpace>::CubesMap &aCubeMap, unsigned int idList);
1391 
1392 
1393 
1399  void glCreateListQuadD3D(const VectorQuad &aVectQuad, unsigned int idList);
1400 
1401 
1407  void glCreateListLines(const VectorLine &aVectLine, unsigned int idList);
1408 
1409 
1415  void glCreateListBalls(const VectorBall &aVectBall, unsigned int idList);
1416 
1417 
1427  void glCreateListQuadMaps(const typename Display3D<Space, KSpace>::QuadsMap &aQuadMap, unsigned int idList);
1428 
1429 
1439  void glCreateListQuadMapsWired(const typename Display3D<Space, KSpace>::QuadsMap &aQuadMap, unsigned int idList);
1440 
1441 
1450  void glCreateListTriangles(const std::vector<VectorTriangle> &aVectTriangle, unsigned int idList);
1451 
1452 
1461  void glCreateListTrianglesWired(const std::vector<VectorTriangle> &aVectTriangle, unsigned int idList);
1462 
1463 
1472  void glCreateListPolygons(const std::vector<VectorPolygon> &aVectPolygon, unsigned int idList);
1473 
1474 
1483  void glCreateListPolygonsWired(const std::vector<VectorPolygon> &aVectPolygon, unsigned int idList);
1484 
1485 
1492 
1493 
1501 
1507 
1515 
1523 
1524 
1525 
1526  public:
1538  template<typename TImageORDomain>
1539  static
1540  void
1541  rotateImageVertex(TImageORDomain &anImageOrDom, double angle, ImageDirection rotationDir){
1542  double xB = (anImageOrDom.point1[0]+anImageOrDom.point2[0]+anImageOrDom.point3[0]+anImageOrDom.point4[0])/4.0;
1543  double yB = (anImageOrDom.point1[1]+anImageOrDom.point2[1]+anImageOrDom.point3[1]+anImageOrDom.point4[1])/4.0;
1544  double zB = (anImageOrDom.point1[2]+anImageOrDom.point2[2]+anImageOrDom.point3[2]+anImageOrDom.point4[2])/4.0;
1545  rotatePoint( anImageOrDom.point1[0], anImageOrDom.point1[1], anImageOrDom.point1[2], xB, yB, zB, angle, rotationDir);
1546  rotatePoint( anImageOrDom.point2[0], anImageOrDom.point2[1], anImageOrDom.point2[2], xB, yB, zB, angle, rotationDir);
1547  rotatePoint( anImageOrDom.point3[0], anImageOrDom.point3[1], anImageOrDom.point3[2], xB, yB, zB, angle, rotationDir);
1548  rotatePoint( anImageOrDom.point4[0], anImageOrDom.point4[1], anImageOrDom.point4[2], xB, yB, zB, angle, rotationDir);
1549 
1550  }
1551 
1565  template <typename TValues>
1566  static
1567  void rotatePoint(TValues &x, TValues &y, TValues &z,
1568  double cx, double cy, double cz,
1569  double rotationAngle, ImageDirection rotationDir);
1570 
1571 
1572 
1573 
1574 
1575  // ------------------------- Private Datas --------------------------------
1576  private:
1577 
1579  //GLuint myListToAff;
1580 
1583 
1586 
1590 
1593 
1596 
1598 
1599  unsigned int myNbListe;
1600  unsigned int myNbLineSetList;
1601  unsigned int myNbBallSetList;
1602  unsigned int myNbPrismSetList;
1603 
1606  unsigned char mySelectionColorShift = 150;
1607 
1613  std::vector<GLTextureImage> myVectTextureImage;
1614 
1616 
1617  double camera_position[3];
1618  double camera_direction[3];
1619  double camera_upVector[3];
1620 
1621  bool myLightPositionFixToCamera = true; // when false the light position is fix according to the scene.
1622  double myLightTheta;
1623  double myLightPhi;
1624  double myLightR;
1625  GLfloat myLightPosition [4] = {0.0f, 0.0f, 1.0f, 1.0f}; // the light position in cartesian coordinate
1626  GLfloat myLightPositionRefCameraDefault [3] = {-100.0f, 100.0f, 0.0f}; // the light default position according to the camera position
1627  GLfloat myLightPositionRefCamera [3] = {0.0f, 0.0f, 0.0f}; // the light position according to the camera position
1628  GLfloat myMaterialShininessCoeff[1] = {50.0f} ; // the material shininess coefficient used in opengl rendering
1629  GLfloat myMaterialSpecularCoeffs[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; // the light specular coefficients used in opengl rendering
1630  GLfloat myLightSpecularCoeffs[4] = { 0.3f, 0.3f, 0.3f, 1.0f }; // the light specular coefficients used in opengl rendering
1631  GLfloat myLightAmbientCoeffs[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; // the material ambient coefficients used in opengl rendering
1632  GLfloat myLightDiffuseCoeffs[4] = { 0.7f, 0.7f, 0.7f, 1.0f }; // the material diffuse coefficients used in opengl rendering
1633 
1634  const GLfloat myDefaultRenderSpec = 0.3f; // default specular coefficients for default mode rendering
1635  const GLfloat myDefaultRenderDiff = 0.7f; // default diffuse coefficients for metallic mode rendering
1636  const GLfloat myLambertRenderSpec = 0.0f; // default specular coefficients for default mode rendering
1637  const GLfloat myLambertRenderDiff = 0.9f; // default diffuse coefficients for metallic mode rendering
1638  const GLfloat myMetallicRenderSpec = 0.5f; // default specular coefficients for metallic mode rendering
1639  const GLfloat myMetallicRenderDiff = 0.5f; // default diffuse coefficients for metallic mode rendering
1640  const GLfloat myPlasticRenderSpec = 0.8f; // default specular coefficients for platic mode rendering
1641  const GLfloat myPlasticRenderDiff = 0.2f; // default diffuse coefficients for platic mode rendering
1642 
1643  bool myUseGLPointsForBalls = false; // to display balls with GL points (instead real ball)
1644 
1645  double ZNear;
1646  double ZFar;
1647 
1648  //the default width of the mesh line
1650 
1651  // To apply openGL ajustment only on visualisation
1652  float myGLScaleFactorX=1.0;
1653  float myGLScaleFactorY=1.0;
1654  float myGLScaleFactorZ=1.0;
1655 
1656  // Used to apply interactive light rotation
1661 
1663  std::vector<TextureImage> myGSImageList;
1665  std::vector<Image2DDomainD3D> myImageDomainList;
1667  Extension * myExtension;
1668 
1669  }; // end of class Viewer3D
1670 
1671  template <typename TSpace, typename TKSpace>
1678  std::ostream & operator<<( std::ostream & out,
1679  const Viewer3D<TSpace, TKSpace> & object );
1680 } // namespace DGtal
1681 
1682 
1684 // Includes inline functions.
1685 #include "DGtal/io/viewers/Viewer3D.ih"
1686 
1687 // //
1689 
1690 #endif // !defined Viewer3D_h
1691 
1692 #undef Viewer3D_RECURSES
1693 #endif // else defined(Viewer3D_RECURSES)
DGtal::Viewer3D::TextureImage::point1
RealPoint point1
Definition: Viewer3D.h:569
DGtal::Viewer3D::SelectCallbackFct
Display::SelectCallbackFct SelectCallbackFct
Definition: Viewer3D.h:145
DGtal::Viewer3D::GLTextureImage::myTextureName
GLuint myTextureName
Definition: Viewer3D.h:1223
ConstIterator
MyDigitalSurface::ConstIterator ConstIterator
Definition: greedy-plane-segmentation-ex2.cpp:93
DGtal::Viewer3D::Space
TSpace Space
Definition: Viewer3D.h:141
DGtal::Viewer3D::sortTriangleFromCamera
void sortTriangleFromCamera()
DGtal::Viewer3D::TextureImage::TextureImage
TextureImage()
Definition: Viewer3D.h:739
DGtal::Viewer3D::TextureImage::TextureImage
TextureImage(const TextureImage &img)
Copy constructor (needed due to myTabImage)
Definition: Viewer3D.h:597
DGtal::Viewer3D::setCameraPosition
void setCameraPosition(double ax, double ay, double az)
Definition: Viewer3D.h:335
DGtal::Viewer3D::myGLScaleFactorY
float myGLScaleFactorY
Definition: Viewer3D.h:1653
DGtal::Viewer3D::myPolygonSetListWiredId
GLuint myPolygonSetListWiredId
Definition: Viewer3D.h:1585
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:473
DGtal::Viewer3D::CompFarthestVoxelFromCamera::posCam
qglviewer::Vec posCam
Definition: Viewer3D.h:1050
DGtal::Viewer3D::Extension::mouseReleaseEvent
virtual bool mouseReleaseEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:281
image
Image image(domain)
DGtal::Viewer3D::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
DGtal::Viewer3D::myCubesMapId
GLuint myCubesMapId
Definition: Viewer3D.h:1594
DGtal::concepts::CSpace
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:106
DGtal::Display3D
Aim: This semi abstract class defines the stream mechanism to display 3d primitive (like BallVector,...
Definition: Display3D.h:93
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:166
DGtal::Viewer3D::camera_direction
double camera_direction[3]
camera direction
Definition: Viewer3D.h:1618
DGtal::Viewer3D::VectorTriangle
std::vector< typename Viewer3D< Space, KSpace >::TriangleD3D > VectorTriangle
Definition: Viewer3D.h:1373
DGtal::Viewer3D::myLineSetListId
GLuint myLineSetListId
Definition: Viewer3D.h:1587
DGtal::Viewer3D::glDrawGLBall
void glDrawGLBall(const typename Viewer3D< Space, KSpace >::BallD3D &aBall)
DGtal::Viewer3D::GLTextureImage::myDirection
Viewer3D< Space, KSpace >::ImageDirection myDirection
Definition: Viewer3D.h:1217
DGtal::Viewer3D::Extension::postSelection
virtual bool postSelection(const Viewer &viewer, const QPoint &point)
Definition: Viewer3D.h:235
DGtal::Viewer3D::myQuadsMapWiredId
GLuint myQuadsMapWiredId
Definition: Viewer3D.h:1592
DGtal::Viewer3D::undefDirection
@ undefDirection
Definition: Viewer3D.h:471
DGtal::Viewer3D::myNbListe
unsigned int myNbListe
number of lists in myListToAff
Definition: Viewer3D.h:1599
DGtal::Viewer3D::glUpdateTextureImages
void glUpdateTextureImages(const VectorTextureImage &aVectImage)
DGtal::Viewer3D::GLTextureImage::myBufferWidth
unsigned int myBufferWidth
Definition: Viewer3D.h:1221
DGtal::Viewer3D::myLightPositionRefCamera
GLfloat myLightPositionRefCamera[3]
Definition: Viewer3D.h:1627
DGtal::Viewer3D::VectorTextureImage
std::vector< typename Viewer3D< Space, KSpace >::TextureImage > VectorTextureImage
Definition: Viewer3D.h:1375
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::Viewer3D::CompFarthestVoxelFromCamera::operator()
bool operator()(typename Viewer3D< Space, KSpace >::CubeD3D s1, typename Viewer3D< Space, KSpace >::CubeD3D s2)
Definition: Viewer3D.h:1051
DGtal::Viewer3D::myAutoSaveState
bool myAutoSaveState
flag to save automatically or not the Viewer3d state when closing the viewer
Definition: Viewer3D.h:486
DGtal::Viewer3D::drawSomeLight
void drawSomeLight(GLenum light) const
To call the protected method drawLight.
Definition: Viewer3D.h:978
DGtal::Viewer3D::myLambertRenderSpec
const GLfloat myLambertRenderSpec
Definition: Viewer3D.h:1636
DGtal::Viewer3D::CompFarthestPolygonFromCamera
Definition: Viewer3D.h:1108
DGtal::Viewer3D::Image2DDomainD3D
Definition: Viewer3D.h:495
DGtal::Viewer3D::TextureImage::myDirection
ImageDirection myDirection
Definition: Viewer3D.h:574
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:513
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:643
DGtal::Viewer3D::GrayScaleMode
@ GrayScaleMode
Definition: Viewer3D.h:473
DGtal::Viewer3D::myNbLineSetList
unsigned int myNbLineSetList
Definition: Viewer3D.h:1600
DGtal::Viewer3D::TextureImage
Definition: Viewer3D.h:567
DGtal::Viewer3D::Image2DDomainD3D::point4
RealPoint point4
Definition: Viewer3D.h:501
DGtal::Viewer3D::myExtension
Extension * myExtension
Stored a possible extension to the viewer (pointer owned).
Definition: Viewer3D.h:1667
DGtal::Viewer3D::myLightAmbientCoeffs
GLfloat myLightAmbientCoeffs[4]
Definition: Viewer3D.h:1631
DGtal::Viewer3D::Extension::mouseMoveEvent
virtual bool mouseMoveEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:250
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:1370
DGtal::Viewer3D::myPlasticRenderSpec
const GLfloat myPlasticRenderSpec
Definition: Viewer3D.h:1640
DGtal::Viewer3D::TextureImage::myImageWidth
unsigned int myImageWidth
direction of the image (x, y or z axe)
Definition: Viewer3D.h:576
DGtal::Viewer3D::Extension::draw
virtual void draw(Viewer &viewer)
Definition: Viewer3D.h:200
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:1090
DGtal::Viewer3D::CompFarthestSurfelFromCamera
Definition: Viewer3D.h:1089
DGtal::Viewer3D::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *e)
DGtal::Viewer3D::GLTextureImage::myTextureImageBufferGS
unsigned char * myTextureImageBufferGS
Definition: Viewer3D.h:1225
DGtal::Viewer3D::GLTextureImage::GLTextureImage
GLTextureImage(const GLTextureImage &aGLImg)
Definition: Viewer3D.h:1252
DGtal::Viewer3D::setCameraUpVector
void setCameraUpVector(double ax, double ay, double az)
Definition: Viewer3D.h:357
DGtal::Viewer3D::myLightPhi
double myLightPhi
the light position (inclination)
Definition: Viewer3D.h:1623
DGtal::Viewer3D::GLTextureImage::point1
RealPoint point1
coordinates
Definition: Viewer3D.h:1212
DGtal::Viewer3D::myMetallicRenderSpec
const GLfloat myMetallicRenderSpec
Definition: Viewer3D.h:1638
DGtal::Viewer3D::mySelectedElementId
int mySelectedElementId
used to displayed selected elements
Definition: Viewer3D.h:1605
DGtal::Viewer3D::CompFarthestTriangleFromCamera
Definition: Viewer3D.h:1071
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:1595
DGtal::Viewer3D::Extension
Definition: Viewer3D.h:164
DGtal::Viewer3D::glCreateListTriangles
void glCreateListTriangles(const std::vector< VectorTriangle > &aVectTriangle, unsigned int idList)
DGtal::Viewer3D::myMaterialShininessCoeff
GLfloat myMaterialShininessCoeff[1]
Definition: Viewer3D.h:1628
DGtal::Viewer3D::VectorCubes
std::vector< typename Viewer3D< Space, KSpace >::CubeD3D > VectorCubes
Definition: Viewer3D.h:1369
DGtal::Viewer3D::Extension::init
virtual void init(Viewer &viewer)
Definition: Viewer3D.h:209
DGtal::Viewer3D::translateAn2DDomain
void translateAn2DDomain(unsigned int domainIndex, double xTranslation, double yTranslation, double zTranslation)
DGtal::Viewer3D::myPrismListId
GLuint myPrismListId
Definition: Viewer3D.h:1589
DGtal::Viewer3D::myLambertRenderDiff
const GLfloat myLambertRenderDiff
Definition: Viewer3D.h:1637
DGtal::Viewer3D::myRefMouseXPos
int myRefMouseXPos
the angle rotation increment used for interactive light move
Definition: Viewer3D.h:1658
DGtal::Viewer3D::VectorBall
std::vector< typename Viewer3D< Space, KSpace >::BallD3D > VectorBall
Definition: Viewer3D.h:1372
DGtal::Viewer3D::RenderingLambertian
@ RenderingLambertian
Definition: Viewer3D.h:154
DGtal::Viewer3D::setExtension
void setExtension(Extension *ext)
Definition: Viewer3D.h:313
DGtal::Viewer3D::camera_upVector
double camera_upVector[3]
camera up-vector
Definition: Viewer3D.h:1619
DGtal::Viewer3D::myViewWire
bool myViewWire
objects have shadows which follow the camera if false
Definition: Viewer3D.h:482
DGtal::Viewer3D::CompFarthestTriangleFromCamera::posCam
qglviewer::Vec posCam
Definition: Viewer3D.h:1072
DGtal::Viewer3D::myDirSelector
qglviewer::Vec myDirSelector
Definition: Viewer3D.h:1609
DGtal::Viewer3D::myIsBackgroundDefault
bool myIsBackgroundDefault
true if the background is default
Definition: Viewer3D.h:480
DGtal::Viewer3D::glCreateListQuadMaps
void glCreateListQuadMaps(const typename Display3D< Space, KSpace >::QuadsMap &aQuadMap, unsigned int idList)
DGtal::Viewer3D::Image2DDomainD3D::point3
RealPoint point3
Definition: Viewer3D.h:500
DGtal::Viewer3D::glCreateListPolygonsWired
void glCreateListPolygonsWired(const std::vector< VectorPolygon > &aVectPolygon, unsigned int idList)
DGtal::Viewer3D::yDirection
@ yDirection
Definition: Viewer3D.h:471
DGtal::Viewer3D::myIsMovingLight
bool myIsMovingLight
the reference mouse y-position used to determince the light position change (inclination)
Definition: Viewer3D.h:1660
DGtal::Viewer3D::camera_position
double camera_position[3]
camera position
Definition: Viewer3D.h:1617
DGtal::Viewer3D::zDirection
@ zDirection
Definition: Viewer3D.h:471
DGtal::Viewer3D::drawSomeLight
void drawSomeLight(GLenum light, float zoom) const
To call the protected method drawLight.
Definition: Viewer3D.h:983
DGtal::Viewer3D::RealPoint
Display::RealPoint RealPoint
Definition: Viewer3D.h:146
DGtal::Viewer3D::updateRelativeCameraFromLightPosition
void updateRelativeCameraFromLightPosition()
DGtal::Viewer3D::myQuadsMapId
GLuint myQuadsMapId
Definition: Viewer3D.h:1591
DGtal::Viewer3D::GLTextureImage::myBufferHeight
unsigned int myBufferHeight
Definition: Viewer3D.h:1222
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:295
DGtal::Viewer3D::TextureImage::point4
RealPoint point4
Definition: Viewer3D.h:572
DGtal::Viewer3D::myRenderingMode
RenderingMode myRenderingMode
Definition: Viewer3D.h:488
DGtal::Viewer3D::ItCube
VectorCubes::iterator ItCube
Definition: Viewer3D.h:1378
DGtal::Color::Red
static const Color Red
Definition: Color.h:400
DGtal::Viewer3D::Image2DDomainD3D::myDomainHeight
unsigned int myDomainHeight
the height of the image domain
Definition: Viewer3D.h:507
DGtal::Viewer3D::myBallSetListId
GLuint myBallSetListId
Definition: Viewer3D.h:1588
DGtal::Viewer3D::Extension::drawWithNames
virtual void drawWithNames(Viewer &viewer)
Definition: Viewer3D.h:190
DGtal::Viewer3D::GLTextureImage::point3
RealPoint point3
Definition: Viewer3D.h:1214
DGtal::Viewer3D
Definition: Viewer3D.h:133
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:1663
DGtal::Viewer3D::Image2DDomainD3D::myDomainWidth
unsigned int myDomainWidth
the width of the image domain
Definition: Viewer3D.h:505
DGtal::Viewer3D::RenderingMetallic
@ RenderingMetallic
Definition: Viewer3D.h:152
DGtal::Viewer3D::TextureImage::myImageHeight
unsigned int myImageHeight
the width of the image
Definition: Viewer3D.h:577
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:130
DGtal::Viewer3D::myLigthRotationStep
double myLigthRotationStep
Definition: Viewer3D.h:1657
DGtal::Viewer3D::CompFarthestTriangleFromCamera::operator()
bool operator()(typename Viewer3D< Space, KSpace >::TriangleD3D t1, typename Viewer3D< Space, KSpace >::TriangleD3D t2)
Definition: Viewer3D.h:1073
DGtal::Viewer3D::myGLPointMinWidth
double myGLPointMinWidth
Definition: Viewer3D.h:483
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::Viewer3D< Space, KSpace >::RenderingMode
RenderingMode
Definition: Viewer3D.h:150
DGtal::Viewer3D::mySelectedPoint
qglviewer::Vec mySelectedPoint
Definition: Viewer3D.h:1609
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:478
DGtal::Viewer3D::TextureImage::point2
RealPoint point2
Definition: Viewer3D.h:570
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:1609
DGtal::Viewer3D::TextureImage::className
std::string className() const
DGtal::Viewer3D::ZFar
double ZFar
zfar distance
Definition: Viewer3D.h:1646
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:322
DGtal::Viewer3D::getCurrentGLImageNumber
virtual unsigned int getCurrentGLImageNumber()
DGtal::Viewer3D::KSpace
TKSpace KSpace
Definition: Viewer3D.h:142
DGtal::Viewer3D::GLTextureImage
Definition: Viewer3D.h:1210
DGtal::Viewer3D::setGLLightSpecularCoefficients
void setGLLightSpecularCoefficients(const GLfloat lightSpecularCoeffs[4])
DGtal::Viewer3D::myPolygonSetListId
GLuint myPolygonSetListId
Definition: Viewer3D.h:1584
DGtal::Viewer3D::TextureImage::myDrawDomain
bool myDrawDomain
for each pixel of the image, color or height ?
Definition: Viewer3D.h:581
DGtal::Viewer3D::myVectTextureImage
std::vector< GLTextureImage > myVectTextureImage
list of the images textures in this viewer
Definition: Viewer3D.h:1613
DGtal::Viewer3D::getCurrentDomainNumber
virtual unsigned int getCurrentDomainNumber()
DGtal::Viewer3D::myLightR
double myLightR
the light position (azimuth)
Definition: Viewer3D.h:1624
DGtal::Viewer3D::GLTextureImage::myImageHeight
unsigned int myImageHeight
Definition: Viewer3D.h:1219
DGtal::Viewer3D::myUseGLPointsForBalls
bool myUseGLPointsForBalls
Definition: Viewer3D.h:1643
DGtal::Viewer3D::setCameraDirection
void setCameraDirection(double ax, double ay, double az)
Definition: Viewer3D.h:346
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:304
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:1374
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:476
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::Viewer3D::GLTextureImage::myTextureFitY
double myTextureFitY
Definition: Viewer3D.h:1232
DGtal::Viewer3D::myNbPrismSetList
unsigned int myNbPrismSetList
Definition: Viewer3D.h:1602
DGtal::Viewer3D::CompFarthestPolygonFromCamera::posCam
qglviewer::Vec posCam
Definition: Viewer3D.h:1109
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:583
DGtal::Display3D::LineD3D
Definition: Display3D.h:149
DGtal::Viewer3D::myMeshDefaultLineWidth
float myMeshDefaultLineWidth
Definition: Viewer3D.h:1649
DGtal::Viewer3D::glUpdateBackground
void glUpdateBackground()
DGtal::Viewer3D< Space, KSpace >::ImageDirection
ImageDirection
the 3 possible axes for the image direction
Definition: Viewer3D.h:471
DGtal::Viewer3D::GLTextureImage::myTextureImageBufferRGB
unsigned char * myTextureImageBufferRGB
Definition: Viewer3D.h:1226
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:1371
DGtal::Viewer3D::TextureImage::myTabImage
unsigned int * myTabImage
the height of the image
Definition: Viewer3D.h:579
DGtal::Viewer3D::myLightPosition
GLfloat myLightPosition[4]
the light position (distance)
Definition: Viewer3D.h:1625
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:525
DGtal::Viewer3D::mySelectionColorShift
unsigned char mySelectionColorShift
Definition: Viewer3D.h:1606
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:1224
DGtal::Viewer3D::Extension::mousePressEvent
virtual bool mousePressEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:265
DGtal::Viewer3D::myDefaultRenderSpec
const GLfloat myDefaultRenderSpec
Definition: Viewer3D.h:1634
DGtal::Viewer3D::Display
Display3D< Space, KSpace > Display
Definition: Viewer3D.h:144
DGtal::Viewer3D::GLTextureImage::myImageWidth
unsigned int myImageWidth
Definition: Viewer3D.h:1218
DGtal::Viewer3D::GLTextureImage::point4
RealPoint point4
Definition: Viewer3D.h:1215
DGtal::Viewer3D::myRefMouseYPos
int myRefMouseYPos
the reference mouse x-position used to determince the light position change (azimuth)
Definition: Viewer3D.h:1659
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:1665
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:1641
DGtal::Viewer3D::myOrig
qglviewer::Vec myOrig
information linked to the navigation in the viewer
Definition: Viewer3D.h:1609
DGtal::Viewer3D::Extension::keyPressEvent
virtual bool keyPressEvent(Viewer &viewer, QKeyEvent *event)
Definition: Viewer3D.h:178
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:1621
DGtal::Viewer3D::rotatePoint
static void rotatePoint(TValues &x, TValues &y, TValues &z, double cx, double cy, double cz, double rotationAngle, ImageDirection rotationDir)
DGtal::Viewer3D::compute2DDomainLineRepresentation
std::vector< typename DGtal::Viewer3D< Space, KSpace >::LineD3D > compute2DDomainLineRepresentation(Image2DDomainD3D &anImageDomain)
DGtal::Viewer3D::Image2DDomainD3D::myMode
std::string myMode
the mode of representation of the image domain
Definition: Viewer3D.h:511
DGtal::Viewer3D::myTriangleSetListId
GLuint myTriangleSetListId
lists of the list to draw
Definition: Viewer3D.h:1581
DGtal::Viewer3D::TextureImage::myIndexDomain
unsigned int myIndexDomain
true if the draw have a domain
Definition: Viewer3D.h:582
DGtal::Viewer3D::CompFarthestVoxelFromCamera
Definition: Viewer3D.h:1049
DGtal::Viewer3D::RenderingDefault
@ RenderingDefault
Definition: Viewer3D.h:151
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:593
DGtal::Viewer3D::GLTextureImage::~GLTextureImage
~GLTextureImage()
Definition: Viewer3D.h:1236
DGtal::Viewer3D::myMaterialSpecularCoeffs
GLfloat myMaterialSpecularCoeffs[4]
Definition: Viewer3D.h:1629
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:498
DGtal::Viewer3D::setNearFar
void setNearFar(double _near, double _far)
Definition: Viewer3D.h:367
DGtal::Viewer3D::TextureImage::point3
RealPoint point3
Definition: Viewer3D.h:571
DGtal::Viewer3D::Image2DDomainD3D::color
DGtal::Color color
The image domain color.
Definition: Viewer3D.h:503
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:1110
DGtal::Viewer3D::TextureImage::updateImage3DEmbedding
void updateImage3DEmbedding(RealPoint aPoint1, RealPoint aPoint2, RealPoint aPoint3, RealPoint aPoint4)
Definition: Viewer3D.h:681
DGtal::Viewer3D::myDefaultRenderDiff
const GLfloat myDefaultRenderDiff
Definition: Viewer3D.h:1635
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:499
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:1541
DGtal::Viewer3D::setGLDoubleRenderingMode
void setGLDoubleRenderingMode(bool doubleSidedRendering)
DGtal::Viewer3D::init
virtual void init()
init
DGtal::Viewer3D::myLightDiffuseCoeffs
GLfloat myLightDiffuseCoeffs[4]
Definition: Viewer3D.h:1632
DGtal::Viewer3D::RenderingPlastic
@ RenderingPlastic
Definition: Viewer3D.h:153
DGtal::Viewer3D::Extension::~Extension
virtual ~Extension()=default
DGtal::Viewer3D::myPosSelector
QPoint myPosSelector
a point selected with postSelection
Definition: Viewer3D.h:1611
DGtal::Viewer3D::myGLScaleFactorX
float myGLScaleFactorX
Definition: Viewer3D.h:1652
DGtal::Viewer3D::Extension::helpString
virtual QString helpString(const Viewer &viewer) const
Definition: Viewer3D.h:220
DGtal::Viewer3D::sortQuadFromCamera
void sortQuadFromCamera()
DGtal::Viewer3D::xDirection
@ xDirection
Definition: Viewer3D.h:471
DGtal::Viewer3D::myNbBallSetList
unsigned int myNbBallSetList
Definition: Viewer3D.h:1601
DGtal::Viewer3D::CompFarthestSurfelFromCamera::operator()
bool operator()(typename Viewer3D< Space, KSpace >::QuadD3D q1, typename Viewer3D< Space, KSpace >::QuadD3D q2)
Definition: Viewer3D.h:1091
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:381
DGtal::Viewer3D::myIsDoubleFaceRendering
bool myIsDoubleFaceRendering
true if is double face rendering
Definition: Viewer3D.h:1615
DGtal::Viewer3D::Self
Viewer3D< Space, KSpace > Self
Definition: Viewer3D.h:143
DGtal::Viewer3D::updateList
void updateList(bool needToUpdateBoundingBox=true)
DGtal::Viewer3D::myLightTheta
double myLightTheta
Definition: Viewer3D.h:1622
DGtal::Viewer3D::ZNear
double ZNear
znear distance
Definition: Viewer3D.h:1645
DGtal::Viewer3D::myLightPositionRefCameraDefault
GLfloat myLightPositionRefCameraDefault[3]
Definition: Viewer3D.h:1626
DGtal::Viewer3D< Space, KSpace >::TextureMode
TextureMode
the modes of representation of an image
Definition: Viewer3D.h:473
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:707
DGtal::Viewer3D::GLTextureImage::GLTextureImage
GLTextureImage(const typename Viewer3D< Space, KSpace >::TextureImage &aGSImage)
Definition: Viewer3D.h:1291
DGtal::Viewer3D::GLTextureImage::vectNormal
double vectNormal[3]
Definition: Viewer3D.h:1227
DGtal::concepts::CUnaryFunctor
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:90
DGtal::concepts::CConstImage
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Definition: CConstImage.h:95
DGtal::Viewer3D::myMetallicRenderDiff
const GLfloat myMetallicRenderDiff
Definition: Viewer3D.h:1639
DGtal::Viewer3D::Image2DDomainD3D::myDirection
ImageDirection myDirection
the direction of the domain (x, y or z axe)
Definition: Viewer3D.h:509
DGtal::Viewer3D::myTriangleSetListWiredId
GLuint myTriangleSetListWiredId
Definition: Viewer3D.h:1582
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:1231
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:588
DGtal::Viewer3D::glCreateListCubesMaps
void glCreateListCubesMaps(const typename Display3D< Space, KSpace >::CubesMap &aCubeMap, unsigned int idList)
DGtal::Viewer3D::GLTextureImage::point2
RealPoint point2
Definition: Viewer3D.h:1213
DGtal::Viewer3D::myGLLineMinWidth
double myGLLineMinWidth
to improve the display of gl points
Definition: Viewer3D.h:484
DGtal::Viewer3D::myLightSpecularCoeffs
GLfloat myLightSpecularCoeffs[4]
Definition: Viewer3D.h:1630
DGtal::Viewer3D::myGLScaleFactorZ
float myGLScaleFactorZ
Definition: Viewer3D.h:1654