DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DrawWithDisplay3DModifier.h
1 
17 #pragma once
18 
31 #if defined(DrawWithDisplay3DModifier_RECURSES)
32 #error Recursive header files inclusion detected in DrawWithDisplay3DModifier.h
33 #else // defined(DrawWithDisplay3DModifier_RECURSES)
34 
35 #define DrawWithDisplay3DModifier_RECURSES
36 
37 #if !defined DrawWithDisplay3DModifier_h
38 
39 #define DrawWithDisplay3DModifier_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/CountedPtr.h"
46 #include "DGtal/helpers/StdDefs.h"
47 
48 
50 
51 namespace DGtal
52 {
53 
60  std::string className() const
61  {
62  return "DrawWithDisplay3DModifier";
63  }
64 
65  /*DrawableWithDisplay3D* defaultStyleDisplay3D( std::string = "" ) const
66  {
67  return 0;
68  }*/
69 
70  /*virtual void setStyleDisplay3D( Display3D & ) const
71  {}*/
72  };
73 
74 
75 
76 
77 
78 
91  SetMode3D( std::string classname, std::string mode )
92  : myClassname( classname ), myMode( mode )
93  {}
94 
95  /*void setStyleDisplay3D( Display3D & display ) const
96  {
97  display.myModes[ myClassname ] = myMode;
98  }*/
99 
100  std::string myClassname;
101  std::string myMode;
102  };
103 
104 
105 
106 
119  CustomStyle3D( std::string classname, DrawableWithDisplay3D* style )
120  : myClassname( classname ), myStyle( style )
121  {}
122 
123  std::string className() const
124  {
125  return "CustomStyle3D";
126  }
127 
128  /*void setStyleDisplay3D( Display3D & display ) const
129  {
130  display.myStyles[ myClassname ] = myStyle;
131  }*/
132 
133  std::string myClassname;
135  };
136 
137 
138 
139 
154  {
157 
164  CustomColors3D( const Color & penColor,
165  const Color & fillColor )
166  : myPenColor( penColor ), myFillColor( fillColor )
167  {}
168 
169  /*virtual void setStyleDisplay3D( Display3D & display) const
170  {
171  display.setFillColor(myFillColor);
172  display.setLineColor(myPenColor);
173  }*/
174  };
175 
176 
177 
178 
191  ClippingPlane( double a, double b, double c, double d, bool drawPlane=true )
192  : myA( a ), myB( b ), myC( c ), myD ( d ), myDrawPlane(drawPlane)
193  {}
194 
195  // MT: why setStyleViewer3D here and not setStyleDisplay3D ???
196  /*void setStyleViewer3D( Display3D & display ) const
197  {
198  display.addClippingPlane(myA, myB, myC, myD, myDrawPlane);
199  }*/
200 
201  double * getEquation(){
202  double *r = new double[4];
203  r[0] = myA;
204  r[1] = myB;
205  r[2] = myC;
206  r[3] = myD;
207  return r;
208  }
209 
210  double myA;
211  double myB;
212  double myC;
213  double myD;
215  };
216 
217 
222  {
230  CameraPosition( const double x, const double y, const double z )
231  {
232  eyex=x; eyey=y; eyez=z;
233  }
234 
235  /*void setStyleDisplay3D( Display3D & display) const
236  {
237  display.setCameraPosition(eyex, eyey, eyez);
238  }*/
239 
240  double eyex, eyey, eyez;
241  };
242 
247  {
255  CameraDirection( const double x, const double y, const double z )
256  {
257  dirx=x; diry=y; dirz=z;
258  }
259 
260  /*virtual void setStyleDisplay3D( Display3D & display) const
261  {
262  display.setCameraDirection(dirx, diry, dirz);
263  }*/
264 
265  double dirx, diry, dirz;
266  };
267 
272  {
280  CameraUpVector( const double x, const double y, const double z )
281  {
282  upx=x; upy=y; upz=z;
283  }
284 
285  /*virtual void setStyleDisplay3D( Display3D & viewer) const
286  {
287  viewer.setCameraUpVector(upx, upy, upz);
288  }*/
289 
290  double upx, upy, upz;
291  };
292 
297  {
304  CameraZNearFar( const double _near, const double _far )
305  {
306  ZNear=_near; ZFar=_far;
307  }
308 
309  /*virtual void setStyleDisplay3D( Display3D & viewer) const
310  {
311  viewer.setNearFar(ZNear, ZFar);
312  }*/
313 
314  double ZNear, ZFar;
315  };
316 
317 
318 
324  {
332  TransformedKSSurfel( const DGtal::Z3i::SCell & aSurfel, double aShift, double aSizeFactor=1.0 )
333  {
334  mySurfel= aSurfel;
335  myShift = aShift;
336  mySizeFactor=aSizeFactor;
337  }
338 
347  TransformedKSSurfel( const DGtal::Z3i::SCell & aSurfel, const DGtal::Z3i::SCell & aVoxel,
348  double aShift=0.05, double aSizeFactor=0.75 )
349  {
350  mySurfel= aSurfel;
351  myShift = aShift;
352  mySizeFactor = aSizeFactor;
353  bool xodd = (mySurfel.myCoordinates[ 0 ] & 1 );
354  bool yodd = (mySurfel.myCoordinates[ 1 ] & 1 );
355  bool zodd = (mySurfel.myCoordinates[ 2 ] & 1 );
356  if(!xodd ){
357  myShift*= ((aVoxel.myCoordinates[ 0 ]-mySurfel.myCoordinates[ 0 ] <0)? -1.0: 1.0);
358  }else if(!yodd ){
359  myShift*=((aVoxel.myCoordinates[ 1 ]-mySurfel.myCoordinates[ 1 ] <0)? -1.0: 1.0);
360  }else if(!zodd ){
361  myShift*=((aVoxel.myCoordinates[ 2 ]-mySurfel.myCoordinates[ 2 ] <0)? -1.0: 1.0);
362  }
363  }
364 
366  double myShift;
367  double mySizeFactor;
368  };
369 
370 
371 
372 
373 
374 } // namespace DGtal
375 
376 
377 
378 
379 // //
381 
382 #endif // !defined DrawWithDisplay3DModifier_h
383 
384 #undef DrawWithDisplay3DModifier_RECURSES
385 #endif // else defined(DrawWithDisplay3DModifier_RECURSES)