18 #ifndef __otbVectorDataGlComponent_txx
19 #define __otbVectorDataGlComponent_txx
29 template <
class TVectorData>
32 m_Color(), m_LineWidth(1.5), m_CrossWidth(10), m_RenderPolygonBoundariesOnly(false)
44 m_GluTesselator = gluNewTess();
49 gluTessCallback(m_GluTesselator, GLU_TESS_ERROR, (
FunctionPointerType) TesselationErrorCallback);
51 gluTessCallback(m_GluTesselator, GLU_TESS_COMBINE, (
FunctionPointerType) TesselationCombineCallback);
54 template <
class TVectorData>
59 gluDeleteTess(m_GluTesselator);
62 template <
class TVectorData>
67 if (m_VectorData.IsNull())
75 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
76 glColor4d(m_Color[0], m_Color[1], m_Color[2], m_Color[3]);
79 double previousWidth = 0.;
80 glGetDoublev(GL_LINE_WIDTH, &previousWidth);
84 imageLineWidth.
Fill(m_LineWidth);
86 glLineWidth(screenLineWidth[0]);
88 gluTessProperty(m_GluTesselator, GLU_TESS_BOUNDARY_ONLY, m_RenderPolygonBoundariesOnly);
91 glEnable(GL_LINE_SMOOTH);
97 this->Render(inputRoot, extent, space2ScreenTransform);
101 glDisable(GL_LINE_SMOOTH);
103 glLineWidth(previousWidth);
105 template <
class TVectorData>
111 PointType spacePoint = dataNode->GetPoint();
112 spacePoint[0] -= m_Origin[0];
113 spacePoint[1] -= m_Origin[1];
114 spacePoint[0] /= m_Spacing[0];
115 spacePoint[1] /= m_Spacing[1];
122 glVertex2d(screenPoint[0] - m_CrossWidth, screenPoint[1]);
123 glVertex2d(screenPoint[0] + m_CrossWidth, screenPoint[1]);
124 glVertex2d(screenPoint[0], screenPoint[1] - m_CrossWidth);
125 glVertex2d(screenPoint[0], screenPoint[1] + m_CrossWidth);
129 template <
class TVectorData>
134 const LineType * l = dataNode->GetLine();
136 typename LineType::VertexListType::ConstIterator vIt = l->GetVertexList()->Begin();
138 glBegin(GL_LINE_STRIP);
140 while (vIt != l->GetVertexList()->End())
144 spacePoint[0] -= m_Origin[0];
145 spacePoint[1] -= m_Origin[1];
146 spacePoint[0] /= m_Spacing[0];
147 spacePoint[1] /= m_Spacing[1];
153 glVertex2d(screenPoint[0], screenPoint[1]);
159 template <
class TVectorData>
164 const PolygonType * extRing = dataNode->GetPolygonExteriorRing();
165 const PolygonListType * intRings = dataNode->GetPolygonInteriorRings();
166 typedef std::vector<GLdouble *> VertexVectorType;
169 VertexVectorType vertexBuffer;
172 gluTessBeginPolygon(m_GluTesselator,
NULL);
175 gluTessBeginContour(m_GluTesselator);
178 typename PolygonType::VertexListType::ConstIterator vIt = extRing->GetVertexList()->Begin();
180 while (vIt != extRing->GetVertexList()->End())
185 spacePoint[0] -= m_Origin[0];
186 spacePoint[1] -= m_Origin[1];
187 spacePoint[0] /= m_Spacing[0];
188 spacePoint[1] /= m_Spacing[1];
193 GLdouble * glp =
new GLdouble[3];
194 glp[0] = screenPoint[0];
195 glp[1] = screenPoint[1];
197 vertexBuffer.push_back(glp);
200 gluTessVertex(m_GluTesselator, glp, glp);
205 gluTessEndContour(m_GluTesselator);
208 typename PolygonListType::ConstIterator pIt = intRings->Begin();
211 while (pIt != intRings->End())
213 vIt = pIt.Get()->GetVertexList()->Begin();
216 gluTessBeginContour(m_GluTesselator);
219 while (vIt != pIt.Get()->GetVertexList()->End())
223 spacePoint[0] -= m_Origin[0];
224 spacePoint[1] -= m_Origin[1];
225 spacePoint[0] /= m_Spacing[0];
226 spacePoint[1] /= m_Spacing[1];
232 GLdouble * glp =
new GLdouble[3];
233 glp[0] = screenPoint[0];
234 glp[1] = screenPoint[1];
236 vertexBuffer.push_back(glp);
239 gluTessVertex(m_GluTesselator, glp, glp);
244 gluTessEndContour(m_GluTesselator);
249 gluTessEndPolygon(m_GluTesselator);
252 for (
typename VertexVectorType::iterator it = vertexBuffer.begin();
253 it != vertexBuffer.end(); ++it)
259 template <
class TVectorData>
265 switch (node->Get()->GetNodeType())
270 this->RenderPoint(node->Get(), extent, space2ScreenTransform);
276 this->RenderLine(node->Get(), extent, space2ScreenTransform);
281 this->RenderPolygon(node->Get(), extent, space2ScreenTransform);
295 for (
typename ChildrenListType::iterator it = children.begin(); it != children.end(); ++it)
298 this->Render(*it, extent, space2ScreenTransform);