Orfeo Toolbox  3.16
otbVectorDataGlComponent.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbVectorDataGlComponent_h
19 #define __otbVectorDataGlComponent_h
20 
21 #include "otbGlComponent.h"
23 
24 # ifdef __APPLE__
25 # include <OpenGL/glu.h>
26 # else
27 # include <GL/glu.h>
28 # endif
29 
30 // There are function prototype conflits under cygwin between standard w32 API
31 // and standard C ones
32 #ifndef CALLBACK
33 #if defined(_WINDOWS) || defined(__CYGWIN__)
34 #define CALLBACK __stdcall
35 #else
36 #define CALLBACK
37 #endif
38 #endif
39 
40 namespace otb
41 {
51 template <class TVectorData>
53  : public GlComponent
54 {
55 public:
62 
63  // affine transform
68 
70  typedef TVectorData VectorDataType;
71  typedef typename VectorDataType::Pointer VectorDataPointerType;
72  typedef typename VectorDataType::DataNodeType DataNodeType;
73  typedef typename DataNodeType::Pointer DataNodePointerType;
74  typedef typename DataNodeType::ConstPointer DataNodeConstPointerType;
75  typedef typename VectorDataType::DataTreeType DataTreeType;
76  typedef typename DataNodeType::LineType LineType;
77  typedef typename DataNodeType::PolygonType PolygonType;
78  typedef typename DataNodeType::PolygonListType PolygonListType;
79  typedef typename DataTreeType::TreeNodeType InternalTreeNodeType;
80  typedef typename InternalTreeNodeType::ChildrenListType ChildrenListType;
81 
83  itkTypeMacro(VectorDataGlComponent, GlComponent);
84 
86  itkNewMacro(Self);
87 
89  virtual void Render(const RegionType& extent, const AffineTransformType * space2ScreenTransform);
90 
92  itkSetMacro(Spacing, VectorType);
93  itkGetConstReferenceMacro(Spacing, VectorType);
94 
96  itkSetMacro(Origin, PointType);
97  itkGetConstReferenceMacro(Origin, PointType);
98 
100  itkSetObjectMacro(VectorData, VectorDataType);
101  itkGetObjectMacro(VectorData, VectorDataType);
102 
104  itkSetMacro(Color, ColorType);
105  itkGetConstReferenceMacro(Color, ColorType);
106 
108  itkSetMacro(LineWidth, double);
109  itkGetMacro(LineWidth, double);
110 
112  itkSetMacro(CrossWidth, double);
113  itkGetMacro(CrossWidth, double);
114 
116  itkSetMacro(RenderPolygonBoundariesOnly, bool);
117  itkGetMacro(RenderPolygonBoundariesOnly, bool);
118  itkBooleanMacro(RenderPolygonBoundariesOnly);
119 
120 protected:
124  virtual ~VectorDataGlComponent();
126  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const
127  {
128  Superclass::PrintSelf(os, indent);
129  }
130 
132  virtual void RenderPoint(DataNodePointerType dataNode,
133  const RegionType& extent,
134  const AffineTransformType * transform);
136  virtual void RenderLine(DataNodePointerType dataNode, const RegionType& extent, const AffineTransformType * transform);
137  // Render a complex polygon (with holes)
138  virtual void RenderPolygon(DataNodePointerType dataNode,
139  const RegionType& extent,
140  const AffineTransformType * transform);
141 
142  // Recursive rendering method
143  virtual void Render(InternalTreeNodeType * node,
144  const RegionType& extent,
145  const AffineTransformType * space2ScreenTransform);
146 
149  //void FramePoint(const PointType & p);
150 
151 private:
152  VectorDataGlComponent(const Self&); // purposely not implemented
153  void operator =(const Self&); // purposely not implemented
154 
155  // Function pointer typedef
156  typedef GLvoid (CALLBACK * FunctionPointerType)();
157 
158  // Static Combine callback for tesselation
159  static void CALLBACK TesselationCombineCallback(GLdouble coords[3],
160  GLdouble * /*data*/[4],
161  GLfloat /*weights*/[4],
162  GLdouble **dataOut)
163  {
164  GLdouble * vertex = new GLdouble[3];
165  vertex[0] = coords[0];
166  vertex[1] = coords[1];
167  vertex[2] = coords[2];
168  *dataOut = vertex;
169  }
170 
171  // Static error callback fir tesselation
172  static void CALLBACK TesselationErrorCallback(GLenum errorCode)
173  {
174  const GLubyte * estring = gluErrorString(errorCode);
175  otbMsgDevMacro(<< "Glu Tesselation error: " << estring);
176  //estring = 0; // avoid unused variable warning
177  }
178 
179  // Static begin callback for tesselation
180  static void CALLBACK BeginCallback(GLenum prim)
181  {
182  glBegin(prim);
183  }
184 
185  // Static end callback for tesselation
186  static void CALLBACK EndCallback()
187  {
188  glEnd();
189  }
190 
191  // static vertex callback for tesselation
192  static void CALLBACK VertexCallback(void * data)
193  {
194  glVertex3dv((GLdouble*) data);
195  }
196 
199 
202 
205 
207  GLUtesselator * m_GluTesselator;
208 
211 
213  double m_LineWidth;
214 
216  double m_CrossWidth;
217 
220 
221 }; // end class
222 } // end namespace otb
223 
224 #ifndef OTB_MANUAL_INSTANTIATION
226 #endif
227 
228 #endif

Generated at Sun Feb 3 2013 00:54:01 for Orfeo Toolbox with doxygen 1.8.1.1